spin_lock and scheduler confusion

Rajat Sharma fs.rajat at gmail.com
Fri Jan 7 08:58:16 EST 2011


> As I remember timer interrupt as well is an NMI so, it is
> possible (although not advised) to call schedule function while
> holding spinlock on same core.
>
> spin_lock_irqsave();
> schedule();
> spin_lock_irqrestore();

sorry for confusion created by my last mail, looks like its only watchdog
timer which are NMI and above function call to schedule() does not require
any help from scheduler's timer interrupts (not sure if same timer hardware
is used for watchdog and scheduler timer interrupts, my guess is both may
share the hardware, but different IRQL line, one maskable other
non-maskable). However it is still possible to voluntarily schedule the CPU
core by currently executing code even with spin_locks disabled.

Rajat

On Fri, Jan 7, 2011 at 3:01 PM, nilesh <nilesh.tayade at netscout.com> wrote:

> On Fri, 2011-01-07 at 13:33 +0530, anish singh wrote:
> >
> >
> > On Fri, Jan 7, 2011 at 1:19 PM, nilesh <nilesh.tayade at netscout.com>
> > wrote:
> >         On Fri, 2011-01-07 at 13:05 +0530, Rajat Sharma wrote:
> >         > As I remember timer interrupt as well is an NMI so, it is
> >         possible
> >         > (although not advised) to call schedule function while
> >         holding
> >         > spinlock on same core.
> >         >
> >         > spin_lock_irqsave();
> >         > schedule();
> >         > spin_lock_irqrestore();
> >         >
> >         > however if you have debugging options turned on like
> >         > CONFIG_DEBUG_SPINLOCK, you may likely get kernel warning for
> >         > 'scheduling in atomic context'.
> >         >
> >         > Then what can happen if this core is allowed to switched to
> >         new
> >         > process? Consider the case where new process as well tries
> >         to aquire
> >         > same spin_lock() which new process can not aquire and start
> >         spinning
> >         > for the lock for ever :). Likewise, other cores will also
> >         get locked
> >         > down.
> >         >
> >         > However stil you can detect softlockup through NMI watchdog.
> >
> >
> >         >>Sorry if I am building up the confusion here. But as Dave
> >         Hylands
> >         >>initially mentioned, there will be no timer interrupt. So
> >         shouldn't the
> >         >>NMI watchdog get triggered then? No interrupts -> system
> >         freeze -> NMI
> >         >>Wdt reboot.
> >
> > In my opinion(uninformed ) NMI watchdog will be triggered only in case
> > where you are holding a spinlock.It will not be triggered just because
> > timer interrupts are disabled due to holding a spinlock.
> >
> No, what I meant is - we have masked all the interrupts before holding
> the spinlock (and not even getting the timer interrupts) so it's as good
> as system freeze. And we should trigger the NMI watchdog, isn't it?
>
> --
> Thanks,
> Nilesh
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.kernelnewbies.org/pipermail/kernelnewbies/attachments/20110107/112a60ea/attachment-0001.html 


More information about the Kernelnewbies mailing list