mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Rusty Russell <rusty@rustcorp.com.au>
To: lkml - Kernel Mailing List <linux-kernel@vger.kernel.org>
Cc: Srivatsa Vaddagiri <vatsa@in.ibm.com>,
	lkml - Kernel Mailing List <linux-kernel@vger.kernel.org>,
	Stephen Rothwell <sfr@canb.auug.org.au>
Subject: [PATCH] Fix Occasional stop_machine() Lockup with > 2 CPUs
Date: Tue, 30 Nov 2004 15:42:30 +1100	[thread overview]
Message-ID: <1101789751.14565.25.camel@localhost.localdomain> (raw)

Name: Fix Occasional stop_machine() Lockup
Status: Tested on 2.6.10-rc2-bk13
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>

Stephen Rothwell noted a case where one CPU was sitting in userspace,
one in stop_machine() waiting for everyone to enter stopmachine().
This can happen if migration occurs at exactly the wrong time with
more than 2 CPUS.  Say we have 4 CPUS:

1) stop_machine() on CPU 0creates stopmachine() threads for CPUS 1, 2
   and 3, and yields waiting for them to migrate to their CPUs and
   ack.

2) stopmachine(2) gets rebalanced (probably on exec) to CPU 1.

3) stopmachine(2) calls set_cpus_allowed on CPU 1, sleeps awaiting
   migration thread.

4) stopmachine(1) calls set_cpus_allowed on CPU 0, moves onto CPU1 and
   starts spinning.

Now the migration thread never runs, and we deadlock.  The simplest
solution is for stopmachine() to yield until they are all in place.

Index: linux-2.6.10-rc2-bk13-Misc/kernel/stop_machine.c
===================================================================
--- linux-2.6.10-rc2-bk13-Misc.orig/kernel/stop_machine.c	2004-11-30 13:48:40.000000000 +1100
+++ linux-2.6.10-rc2-bk13-Misc/kernel/stop_machine.c	2004-11-30 14:07:00.089957464 +1100
@@ -52,7 +52,10 @@
 			mb(); /* Must read state first. */
 			atomic_inc(&stopmachine_thread_ack);
 		}
-		cpu_relax();
+		if (!prepared && !irqs_disabled)
+			yield();
+		else
+			cpu_relax();
 	}
 
 	/* Ack: we are exiting. */

-- 
A bad analogy is like a leaky screwdriver -- Richard Braakman


                 reply	other threads:[~2004-11-30  4:42 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

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=1101789751.14565.25.camel@localhost.localdomain \
    --to=rusty@rustcorp.com.au \
    --cc=linux-kernel@vger.kernel.org \
    --cc=sfr@canb.auug.org.au \
    --cc=vatsa@in.ibm.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

Powered by JetHome