linux-fbdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Stephen Rothwell <sfr@canb.auug.org.au>
To: Andrew Morton <akpm@osdl.org>
Cc: jt@bougret.hpl.hp.com, javier@tudela.mad.ttd.net,
	roland@topspin.com, linux-kernel@vger.kernel.org,
	acpi-devel@lists.sourceforge.net, paulus@samba.org,
	linuxppc64-dev@ozlabs.org,
	linux-fbdev-devel@lists.sourceforge.net,
	linux1394-devel@lists.sourceforge.net
Subject: Re: inappropriate use of in_atomic()
Date: Fri, 11 Mar 2005 17:25:11 +1100	[thread overview]
Message-ID: <20050311172511.1fa0919e.sfr@canb.auug.org.au> (raw)
In-Reply-To: <20050310204006.48286d17.akpm@osdl.org>


[-- Attachment #1.1: Type: text/plain, Size: 1932 bytes --]

Hi Andrew,

On Thu, 10 Mar 2005 20:40:06 -0800 Andrew Morton <akpm@osdl.org> wrote:
>
> in_atomic() is not a reliable indication of whether it is currently safe
> to call schedule().
>
> 	arch/ppc64/kernel/viopath.c

in_atomic() in viopath.c was just used to determine if we had initialised
enough to be able to wait in a semaphore (i.e. schedule).  Thus it can be
replaced now with checking system_state for SYSTEM_RUNNING.

Signed-off-by: Stephen Rothwell <sfr@canb.auug.org.au>

Test booted on iSeries (which is the only place it is used).
-- 
Cheers,
Stephen Rothwell                    sfr@canb.auug.org.au
http://www.canb.auug.org.au/~sfr/

diff -ruNp linus/arch/ppc64/kernel/viopath.c linus-in_atomic/arch/ppc64/kernel/viopath.c
--- linus/arch/ppc64/kernel/viopath.c	2005-01-22 06:09:01.000000000 +1100
+++ linus-in_atomic/arch/ppc64/kernel/viopath.c	2005-03-11 17:19:45.000000000 +1100
@@ -79,7 +79,7 @@ static void handleMonitorEvent(struct Hv
 /*
  * We use this structure to handle asynchronous responses.  The caller
  * blocks on the semaphore and the handler posts the semaphore.  However,
- * if in_atomic() is true in the caller, then wait_atomic is used ...
+ * if system_state is not SYSTEM_RUNNING, then wait_atomic is used ...
  */
 struct doneAllocParms_t {
 	struct semaphore *sem;
@@ -465,7 +465,7 @@ static int allocateEvents(HvLpIndex remo
 	DECLARE_MUTEX_LOCKED(Semaphore);
 	atomic_t wait_atomic;
 
-	if (in_atomic()) {
+	if (system_state != SYSTEM_RUNNING) {
 		parms.used_wait_atomic = 1;
 		atomic_set(&wait_atomic, 1);
 		parms.wait_atomic = &wait_atomic;
@@ -475,7 +475,7 @@ static int allocateEvents(HvLpIndex remo
 	}
 	mf_allocate_lp_events(remoteLp, HvLpEvent_Type_VirtualIo, 250,	/* It would be nice to put a real number here! */
 			    numEvents, &viopath_donealloc, &parms);
-	if (in_atomic()) {
+	if (system_state != SYSTEM_RUNNING) {
 		while (atomic_read(&wait_atomic))
 			mb();
 	} else

[-- Attachment #1.2: Type: application/pgp-signature, Size: 189 bytes --]

[-- Attachment #2: Type: text/plain, Size: 161 bytes --]

_______________________________________________
Linuxppc64-dev mailing list
Linuxppc64-dev@ozlabs.org
https://ozlabs.org/cgi-bin/mailman/listinfo/linuxppc64-dev

  reply	other threads:[~2005-03-11  6:25 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2005-03-11  4:40 inappropriate use of in_atomic() Andrew Morton
2005-03-11  6:25 ` Stephen Rothwell [this message]
     [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=20050311172511.1fa0919e.sfr@canb.auug.org.au \
    --to=sfr@canb.auug.org.au \
    --cc=acpi-devel@lists.sourceforge.net \
    --cc=akpm@osdl.org \
    --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=linuxppc64-dev@ozlabs.org \
    --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).