Skip to contentSkip to conversation

in_atomic() & spin_lock / spin_unlock in different functions

DISCUSSION Pavel Machek 2 participants 2 messages Oct 13, 2002

lore
Share & tools
lore
#0 lore raw

Hi!

What is it that in_atomic counts? Obviously spinlocks and get_cpu/put_cpu. Anything else?

Is there easy way to find out which spinlock causes "scheduling in atomic" warning? [It happens a *lot* in swsusp].

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

Signature · 1 line
When do you have heart between your knees?
#1 lore raw
Quoted 3 lines · Pavel Machek

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