linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Matthias Urlichs <smurf@smurf.noris.de>
To: linux-kernel@vger.kernel.org
Subject: Re: question about preempt_disable()
Date: Sun, 30 Nov 2003 18:39:48 +0100	[thread overview]
Message-ID: <pan.2003.11.30.17.39.47.71027@smurf.noris.de> (raw)
In-Reply-To: 000d01c3b6dd$30ab34a0$8a04a943@bananacabana

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@smurf.noris.de
Disclaimer: The quote was selected randomly. Really. | http://smurf.noris.de
 - -
You will have many recoverable tape errors.


  reply	other threads:[~2003-11-30 17:40 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2003-11-30  0:59 question about preempt_disable() Chris Peterson
2003-11-30 17:39 ` Matthias Urlichs [this message]
2003-12-01  3:53   ` Rob Love
2003-12-08 16:31     ` Matthias Urlichs
2003-12-03 23:12 ` George Anzinger

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=pan.2003.11.30.17.39.47.71027@smurf.noris.de \
    --to=smurf@smurf.noris.de \
    --cc=linux-kernel@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).