Re: in_atomic() & spin_lock / spin_unlock in different functions

From: Robert Love (rml@tech9.net)
Date: Sun Oct 13 2002 - 14:40:09 EST


On Sun, 2002-10-13 at 14:38, Pavel Machek wrote:

> I'm doing spin_lock_irqsave() then in another function
> spin_unlock_irqrestore. Is that okay? If no, can it cause "scheduling
> in atomic"?

It is not OK if the function is run by a different process. Then one
process will have a preempt_count one larger than it should and one
would have a preempt_count one smaller.

The task with the one smaller preempt_count will probably cause a crash
when it preemptively reschedules erroneously.

In other words, you have:

        Process A Process B
        preempt_count++
                                preempt_count--

When both of those routines need to be done by the same process.

Also, you cannot use spin_lock_irqsave() in different functions at all
on sparc as it contains stack information.

        Robert Love

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/



This archive was generated by hypermail 2b29 : Tue Oct 15 2002 - 22:00:47 EST