Re: question about preempt_disable()

From: Matthias Urlichs
Date: Sun Nov 30 2003 - 12:42:48 EST


Hi, Chris Peterson wrote:

> My question is: if the code is already SMP-safe and holding the necessary
> spinlocks, why is the preempt count necessary? Why must preemption be
> disabled and re-enabled as spinlocks are acquired and released?

You need to prevent deadlocks. Imagine process A grabbing a spinlock, then
getting preempted. Process B now sits there and waits on the spinlock.
Forward progress may or may not happen when the scheduler preempts B and
restarts A, some indeterminate time later.

Scheduling when waiting for a spinlock doesn't make sense because usually
the spinlock is held for just a few cycles (that's why it's a spin lock
and not a semaphore / wait queue / whatever), and rescheduling would take
more time than just waiting.

--
Matthias Urlichs | {M:U} IT Design @ m-u-it.de | smurf@xxxxxxxxxxxxxx
Disclaimer: The quote was selected randomly. Really. | http://smurf.noris.de
- -
You will have many recoverable tape errors.

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