linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* question about preempt_disable()
@ 2003-11-30  0:59 Chris Peterson
  2003-11-30 17:39 ` Matthias Urlichs
  2003-12-03 23:12 ` George Anzinger
  0 siblings, 2 replies; 5+ messages in thread
From: Chris Peterson @ 2003-11-30  0:59 UTC (permalink / raw)
  To: linux-kernel

I just bought Robert Love's new book "Linux Kernel Development". The book
has been very informative, but I have some unanswered questions about kernel
preemption.

>From what I understand, SMP-safe code is also preempt-safe. The preempt
count is the number of spinlocks held by the current kernel thread. If the
preempt code is greater zero, then the kernel thread cannot be preempted.

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? Is it just
an optimization for accessing per-cpu data? Or is it necessary to prevent
priority inversion of kernel threads, when a low priority thread holds
spinlock X and is preempted by a high priority thread that hogs the CPU,
forever spinning in spin_lock(&X)?


chris


^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2003-12-08 16:39 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2003-11-30  0:59 question about preempt_disable() Chris Peterson
2003-11-30 17:39 ` Matthias Urlichs
2003-12-01  3:53   ` Rob Love
2003-12-08 16:31     ` Matthias Urlichs
2003-12-03 23:12 ` George Anzinger

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).