Re: question about schedule_timeout

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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."
--
To unsubscribe from this list: send the line "unsubscribe kernel-janitors" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[Index of Archives]     [Kernel Development]     [Kernel Announce]     [Kernel Newbies]     [Linux Networking Development]     [Share Photos]     [IDE]     [Security]     [Git]     [Netfilter]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Device Mapper]

  Powered by Linux