public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Robert Love <rml@tech9.net>
To: Thunder from the hill <thunder@lightweight.ods.org>
Cc: Ralf Baechle <ralf@uni-koblenz.de>,
	Oliver Neukum <oliver@neukum.name>,
	linux-kernel@vger.kernel.org
Subject: Re: question on spinlocks
Date: 01 Sep 2002 18:08:12 -0400	[thread overview]
Message-ID: <1030918094.11553.3121.camel@phantasy> (raw)
In-Reply-To: <Pine.LNX.4.44.0209011553140.3234-100000@hawkeye.luckynet.adm>

On Sun, 2002-09-01 at 17:53, Thunder from the hill wrote:

> If it was his least problem! He'll run straight into a "schedule w/IRQs 
> disabled" bug.

No, the "schedule with irqs disabled" message is on involuntary
reschedule (e.g. kernel preemption) when interrupts are disabled.

It "safe" (maybe not sane) to call schedule() with interrupts disabled -
some system calls and scheduler code do it since interrupts will be
unconditionally enabled when rescheduled or upon returning to
user-space.  E.g., see sys_sched_yield().

The actual problem with the above is that when schedule() returns,
interrupts will be on and that is probably not the intention of the
author.  What Oliver probably wants to do is:

	spin_lock_irq(&lck);
	...
	spin_unlock(&lck);
	schedule();
	spin_lock_irq(&lck);
	...
	spin_unlock_irq(&lck);

The first unlock not having the irq-enable is an optimization as
described above.  Also note I did not use irqsave... if there is a
chance interrupts were previously disabled and you have who-knows-what
sort of call-chain behind you, it is probably not safe to go calling
schedule() and reenabling interrupts anyhow.

	Robert Love


  parent reply	other threads:[~2002-09-01 22:03 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2002-09-01 17:27 question on spinlocks Oliver Neukum
2002-09-01 19:05 ` Ralf Baechle
2002-09-01 21:53   ` Thunder from the hill
2002-09-01 22:02     ` Oliver Neukum
2002-09-01 22:09       ` Thunder from the hill
2002-09-01 22:11         ` Robert Love
2002-09-01 22:33         ` Oliver Neukum
2002-09-02 22:30           ` Jan Hudec
2002-09-03 22:13           ` george anzinger
2002-09-01 22:11       ` Robert Love
2002-09-01 22:08     ` Robert Love [this message]
2002-09-01 22:16       ` Thunder from the hill
     [not found]     ` <mailman.1030918200.24262.linux-kernel2news@redhat.com>
2002-09-03 20:09       ` Pete Zaitcev

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=1030918094.11553.3121.camel@phantasy \
    --to=rml@tech9.net \
    --cc=linux-kernel@vger.kernel.org \
    --cc=oliver@neukum.name \
    --cc=ralf@uni-koblenz.de \
    --cc=thunder@lightweight.ods.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