mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Andreas Mohr <andi@rhlx01.fht-esslingen.de>
To: Liu haixiang <liu.haixiang@gmail.com>
Cc: linux-kernel@vger.kernel.org
Subject: Re: Question on Schedule and Preemption
Date: Tue, 18 Apr 2006 11:17:24 +0200	[thread overview]
Message-ID: <20060418091724.GA7258@rhlx01.fht-esslingen.de> (raw)
In-Reply-To: <bf3792800604180023r2a2111b4ude5ef15f9dd855a@mail.gmail.com>

Hi,

On Tue, Apr 18, 2006 at 03:23:01PM +0800, Liu haixiang wrote:
> Hi All,
> 
> Now I am developing the driver on Linux kernel 2.6.11. And I met the
> problem that kernel will dump my stack from time to time. And the
> kernel log will give me messages like "scheduling while atomic: ...".
> 
> Then I found the code in sched.c:
> 
> if (likely(!current->exit_state)) {
> 	if (unlikely(in_atomic())) {
> 		printk(KERN_ERR "scheduling while atomic: "
> 			"%s/0x%08x/%d\n",
> 			current->comm, preempt_count(), current->pid);
> 		dump_stack();
> 	}
> }
> 
> Anybody can explain above code for me?

OK, I'll try, but there should be many references and explanations to it
on the internet already (did you look?).

If the current task is running and thus not yet exiting (!current->exit_state)
and is also in an atomic code section (i.e. under lock), it shouldn't call
any reschedule function (which also happens by just calling msleep(): use
mdelay() instead in that case!).

Generally spoken you should leave locked code sections ASAP (don't waste
too much time in there), and not call any functions that schedule to the
next task in there (msleep(), ...).

BTW, the code above is an old unoptimized version, fixed by me recently.

Andreas Mohr

  reply	other threads:[~2006-04-18  9:17 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2006-04-18  7:23 Liu haixiang
2006-04-18  9:17 ` Andreas Mohr [this message]
2006-04-18  9:23   ` Arjan van de Ven
2006-04-18  9:28     ` Andreas Mohr
2006-04-18 12:55   ` Liu haixiang
2006-04-18 14:56     ` Steven Rostedt
2006-04-18 17:21       ` Liu haixiang
2006-04-18 17:32         ` Steven Rostedt
  -- strict thread matches above, loose matches on Subject: below --
2006-04-18 13:31 Michael Guo
2006-04-18  7:12 Liu haixiang

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=20060418091724.GA7258@rhlx01.fht-esslingen.de \
    --to=andi@rhlx01.fht-esslingen.de \
    --cc=linux-kernel@vger.kernel.org \
    --cc=liu.haixiang@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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®