All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Paul E. McKenney" <paulmck@linux.vnet.ibm.com>
To: ratheesh k <ratheesh.ksz@gmail.com>
Cc: Sven-Thorsten Dietrich <thebigcorporation@gmail.com>,
	linux-kernel@vger.kernel.org, linux-rt-users@vger.kernel.org
Subject: Re: preempt_disable and sleep()
Date: Thu, 13 May 2010 20:37:32 -0700	[thread overview]
Message-ID: <20100514033732.GA2418@linux.vnet.ibm.com> (raw)
In-Reply-To: <AANLkTilMrwdaLrTAUVETYZLYSpoqVFVXfKZ2lZit6uG3@mail.gmail.com>

On Fri, May 14, 2010 at 08:16:07AM +0530, ratheesh k wrote:
> On Fri, May 14, 2010 at 12:13 AM, Sven-Thorsten Dietrich
> <thebigcorporation@gmail.com> wrote:
> 
> > Why would you do this?
> I was reading some linux kernel journel about preempt_disable() . This
> a doubt came to me .
> 
> 
> > If you had tried this code, you would have seen the corresponding stack
> > dump on the console.
> 
> 
> Why it so .? could you explain a little more ? .sleep() will schedule
> () , which inturn give back control to kernel .

Sleeping in the kernel with preemption disabled is considered to be a
bug.  So the scheduler will print an error and a stack dump when this
happens.

In contrast, it is OK to do the following:

	preempt_disable();
	do_something();
	preempt_enable();
	schedule();
	preempt_disable();
	do_something_else();
	preempt_enable();

							Thanx, Paul

> Thank,
> Ratheesh
> 
> On Fri, May 14, 2010 at 12:13 AM, Sven-Thorsten Dietrich
> <thebigcorporation@gmail.com> wrote:
> > On Fri, 2010-05-14 at 00:02 +0530, ratheesh k wrote:
> >> I am running RT linux .
> >>
> >> /* code snippet */
> >>
> >> preempt_disable()
> >> ...........
> >> sleep(10);
> >> '............
> >> preempt_enable()
> >>
> >>
> >> will this sleep() will cause reschedule ?.
> >>
> >
> > Why would you do this?
> >
> > If you had tried this code, you would have seen the corresponding stack
> > dump on the console.
> >
> >> if an interrupt comes  while premption is disabled , how it is handled ?.
> >>
> >
> > Depends on the number of (idle) cores, the setting of CONFIG_PREEMPT_[]
> > and the type of interrupt.
> >
> > RT threaded IRQs would not run until preemption is enabled on a single
> > core system.
> >
> >
> >
> >> Thanks,
> >> Ratheesh
> >> --
> >> To unsubscribe from this list: send the line "unsubscribe linux-rt-users" in
> >> the body of a message to majordomo@vger.kernel.org
> >> More majordomo info at  http://vger.kernel.org/majordomo-info.html
> >
> >
> >
> --
> To unsubscribe from this list: send the line "unsubscribe linux-rt-users" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html
--
To unsubscribe from this list: send the line "unsubscribe linux-rt-users" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

WARNING: multiple messages have this Message-ID (diff)
From: "Paul E. McKenney" <paulmck@linux.vnet.ibm.com>
To: ratheesh k <ratheesh.ksz@gmail.com>
Cc: Sven-Thorsten Dietrich <thebigcorporation@gmail.com>,
	linux-kernel@vger.kernel.org, linux-rt-users@vger.kernel.org
Subject: Re: preempt_disable and sleep()
Date: Thu, 13 May 2010 20:37:32 -0700	[thread overview]
Message-ID: <20100514033732.GA2418@linux.vnet.ibm.com> (raw)
In-Reply-To: <AANLkTilMrwdaLrTAUVETYZLYSpoqVFVXfKZ2lZit6uG3@mail.gmail.com>

On Fri, May 14, 2010 at 08:16:07AM +0530, ratheesh k wrote:
> On Fri, May 14, 2010 at 12:13 AM, Sven-Thorsten Dietrich
> <thebigcorporation@gmail.com> wrote:
> 
> > Why would you do this?
> I was reading some linux kernel journel about preempt_disable() . This
> a doubt came to me .
> 
> 
> > If you had tried this code, you would have seen the corresponding stack
> > dump on the console.
> 
> 
> Why it so .? could you explain a little more ? .sleep() will schedule
> () , which inturn give back control to kernel .

Sleeping in the kernel with preemption disabled is considered to be a
bug.  So the scheduler will print an error and a stack dump when this
happens.

In contrast, it is OK to do the following:

	preempt_disable();
	do_something();
	preempt_enable();
	schedule();
	preempt_disable();
	do_something_else();
	preempt_enable();

							Thanx, Paul

> Thank,
> Ratheesh
> 
> On Fri, May 14, 2010 at 12:13 AM, Sven-Thorsten Dietrich
> <thebigcorporation@gmail.com> wrote:
> > On Fri, 2010-05-14 at 00:02 +0530, ratheesh k wrote:
> >> I am running RT linux .
> >>
> >> /* code snippet */
> >>
> >> preempt_disable()
> >> ...........
> >> sleep(10);
> >> '............
> >> preempt_enable()
> >>
> >>
> >> will this sleep() will cause reschedule ?.
> >>
> >
> > Why would you do this?
> >
> > If you had tried this code, you would have seen the corresponding stack
> > dump on the console.
> >
> >> if an interrupt comes  while premption is disabled , how it is handled ?.
> >>
> >
> > Depends on the number of (idle) cores, the setting of CONFIG_PREEMPT_[]
> > and the type of interrupt.
> >
> > RT threaded IRQs would not run until preemption is enabled on a single
> > core system.
> >
> >
> >
> >> Thanks,
> >> Ratheesh
> >> --
> >> To unsubscribe from this list: send the line "unsubscribe linux-rt-users" in
> >> the body of a message to majordomo@vger.kernel.org
> >> More majordomo info at  http://vger.kernel.org/majordomo-info.html
> >
> >
> >
> --
> To unsubscribe from this list: send the line "unsubscribe linux-rt-users" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html

  reply	other threads:[~2010-05-14  3:37 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-05-13 18:32 preempt_disable and sleep() ratheesh k
2010-05-13 18:43 ` Sven-Thorsten Dietrich
2010-05-14  2:46   ` ratheesh k
2010-05-14  2:46     ` ratheesh k
2010-05-14  3:37     ` Paul E. McKenney [this message]
2010-05-14  3:37       ` Paul E. McKenney

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=20100514033732.GA2418@linux.vnet.ibm.com \
    --to=paulmck@linux.vnet.ibm.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-rt-users@vger.kernel.org \
    --cc=ratheesh.ksz@gmail.com \
    --cc=thebigcorporation@gmail.com \
    /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.