linux-fbdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Andrew Morton <akpm@osdl.org>
To: Paul Mackerras <paulus@samba.org>,
	Jean Tourrilhes <jt@bougret.hpl.hp.com>,
	javier@tudela.mad.ttd.net,
	linux-fbdev-devel@lists.sourceforge.net,
	acpi-devel@lists.sourceforge.net,
	linux1394-devel@lists.sourceforge.net,
	Roland Dreier <roland@topspin.com>
Cc: linux-kernel@vger.kernel.org
Subject: inappropriate use of in_atomic()
Date: Thu, 10 Mar 2005 20:40:06 -0800	[thread overview]
Message-ID: <20050310204006.48286d17.akpm@osdl.org> (raw)


in_atomic() is not a reliable indication of whether it is currently safe
to call schedule().

This is because the lockdepth beancounting which in_atomic() uses is only
accumulated if CONFIG_PREEMPT=y.  in_atomic() will return false inside
spinlocks if CONFIG_PREEMPT=n.

Consequently the use of in_atomic() in the below files is probably
deadlocky if CONFIG_PREEMPT=n:

	arch/ppc64/kernel/viopath.c
	drivers/net/irda/sir_kthread.c
	drivers/net/wireless/airo.c
	drivers/video/amba-clcd.c
	drivers/acpi/osl.c
	drivers/ieee1394/ieee1394_transactions.c
	drivers/infiniband/core/mad.c

Note that the same beancounting is used for the "scheduling while atomic"
warning, so if the code calls schedule with locks held, we won't get a
warning.  Both are tied to CONFIG_PREEMPT=y.

The kernel provides no reliable runtime way of detecting whether or not it
is safe to call schedule().

Can we please find ways to change the above code to not use in_atomic()? 
Then we can whack #ifndef MODULE around its definition to reduce
reoccurrences.  Will probably rename it to something more scary as well.

Thanks.


-------------------------------------------------------
SF email is sponsored by - The IT Product Guide
Read honest & candid reviews on hundreds of IT Products from real users.
Discover which products truly live up to the hype. Start reading now.
http://ads.osdn.com/?ad_id=6595&alloc_id=14396&op=click

             reply	other threads:[~2005-03-11  4:40 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2005-03-11  4:40 Andrew Morton [this message]
2005-03-11  6:25 ` inappropriate use of in_atomic() Stephen Rothwell
     [not found] ` <20050310204006.48286d17.akpm-3NddpPZAyC0@public.gmane.org>
2005-03-11  9:11   ` Jan Kasprzak
2005-03-11  9:46     ` [ACPI] " Andrew Morton
     [not found]       ` <20050311014601.166ae43d.akpm-3NddpPZAyC0@public.gmane.org>
2005-03-11 12:26         ` [Linux-fbdev-devel] " Benjamin Herrenschmidt
2005-03-12  0:13           ` [Linux-fbdev-devel] Re: [ACPI] " Andrew Morton
2005-03-12  0:22             ` Benjamin Herrenschmidt

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=20050310204006.48286d17.akpm@osdl.org \
    --to=akpm@osdl.org \
    --cc=acpi-devel@lists.sourceforge.net \
    --cc=javier@tudela.mad.ttd.net \
    --cc=jt@bougret.hpl.hp.com \
    --cc=linux-fbdev-devel@lists.sourceforge.net \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux1394-devel@lists.sourceforge.net \
    --cc=paulus@samba.org \
    --cc=roland@topspin.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;
as well as URLs for NNTP newsgroup(s).