From: Matthew Wilcox <matthew@wil.cx>
To: kernel-janitors@vger.kernel.org
Subject: Re: question about schedule_timeout
Date: Wed, 15 Dec 2010 12:48:26 +0000 [thread overview]
Message-ID: <20101215124825.GD21909@parisc-linux.org> (raw)
In-Reply-To: <Pine.LNX.4.64.1012151256280.8557@pc-004.diku.dk>
On Wed, Dec 15, 2010 at 12:58:49PM +0100, Julia Lawall wrote:
> I am wondering about the interaction between schedule_timeout and
> functions like local_irq_save, that turn off interrupts. To my
> understanding, with schedule_timeout one sleeps until a timer interrupt is
> received. But how can that be received if interrupts have been turned
> off? I find this mostly in older code, but there are still some
> occurrences, and even in older code, I'm not sure to understand how it
> could have worked.
My memory was that interrupts were reenabled when you called schedule(),
then restored when schedule() returned to you. That turns out not to
be true today, and I don't know whether it was ever true.
What actually happens is this:
asmlinkage void __sched schedule(void)
{
...
preempt_disable();
...
raw_spin_lock_irq(&rq->lock);
...
raw_spin_unlock_irq(&rq->lock);
...
preempt_enable_no_resched();
}
(there are two paths which lead to the rq->lock being dropped, the other one
is slightly more complex than this).
So in plain english, if you call schedule(), or schedule_timeout(),
when it returns interrupts will be enabled. It's almost certainly
a bug, and it'd be good to put a test for it in schedule(), possibly
under DEBUG_SPINLOCK_SLEEP.
--
Matthew Wilcox Intel Open Source Technology Centre
"Bill, look, we understand that you're interested in selling us this
operating system, but compare it to ours. We can't possibly take such
a retrograde step."
next prev parent reply other threads:[~2010-12-15 12:48 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-12-15 11:58 question about schedule_timeout Julia Lawall
2010-12-15 12:48 ` Matthew Wilcox [this message]
2010-12-15 13:01 ` Julia Lawall
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=20101215124825.GD21909@parisc-linux.org \
--to=matthew@wil.cx \
--cc=kernel-janitors@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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.