Which types of locking should I use?

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hello, Jan.

(NOTE: I listed some functions where I want to use 'current',
and the following is Jan's answer.
Not applicable to all functions defined in fs/*.c !)
"Jan Hudec <bulb@ucw.cz>" wrote:
> Summary: All of the functions can safely use current without any special
> precautions whatsoever. All of them may (and usualy do) sleep, since
> they need 

I'm relieved to hear that. Thank you very much.

Now I can proceed to the next and the final problem,
"Which types of locking should I use". Until now I was using
spin_lock_irqsave() and spin_unlock_irqrestore() because (I thought)
functions I listed may be called from interrupt context.

But now it turned out functions I listed are called only from processes,
I no longer need to disable hardware IRQ, software IRQ, tasklets or BHs.

Functions I wrote don't call functions that may sleep.
(I use kmalloc(GFP_ATOMIC) to not to sleep.)
So I can use spin_lock() instead of spin_lock_irqsave(), can't I?
Or (since functions I listed may sleep,) should I use semaphores
to avoid using kmalloc(GFP_ATOMIC) ?

If I'm wrong please mention it.


Thanks in advance.

--
    Tetsuo    (a5497108 _at_ anet.ne.jp)

--
Kernelnewbies: Help each other learn about the Linux kernel.
Archive:       http://mail.nl.linux.org/kernelnewbies/
FAQ:           http://kernelnewbies.org/faq/


[Index of Archives]     [Newbies FAQ]     [Linux Kernel Mentors]     [Linux Kernel Development]     [IETF Annouce]     [Git]     [Networking]     [Security]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux RAID]     [Linux SCSI]     [Linux ACPI]
  Powered by Linux