Hello,
In the implementation of mempools (in mm/mempool.c in 2.6 kernels, for example at http://lxr.linux.no/source/mm/mempool.c), interrupts are disabled when accessing the mempool_t structure using the spin_lock_irqsave() and irq_unlock_irqrestore() functions.
Why is it necessary to disable interrupts ? Isn't it enough to use spin_lock() and spin_unlock() ?
Thanks,
Thomas
Someone feel free to correct me if I am wrong. Spinlocks only really provide useful protection in an SMP environment. In a uniprocessor environment spinlocks compile away to nothing because if a thread were spinning in a busy loop waiting to acquire a lock (spinlock) the thread holding the lock would never have a chance to release it. So by disabling (local) interrupts also, the code/data intended to be protected by the spinlock are protected for the duration of interrupts being disabled.
-- kr
-- Kernelnewbies: Help each other learn about the Linux kernel. Archive: http://mail.nl.linux.org/kernelnewbies/ FAQ: http://kernelnewbies.org/faq/