linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] migration_thread preempt fix
@ 2002-04-15 18:57 Robert Love
  0 siblings, 0 replies; only message in thread
From: Robert Love @ 2002-04-15 18:57 UTC (permalink / raw)
  To: torvalds; +Cc: linux-kernel

Linus,

Attached is a resend of a patch to fix a race in migration_thread which
results in a deadlock on boot for some SMP systems.  The fix is to to
disable preemption inside of set_cpus_allowed.

Andrew Morton first noticed the problem and provided the following patch
a few weeks back.  I was not affected until the recent migration_init
fix, for some odd reason.  Neither Andrew nor I think this is actually
kernel preemption's fault but perhaps a race in the tricky behavior of
the migration code.

Patch is against 2.5.8, please apply.

	Robert Love

diff -urN linux-2.5.8/kernel/sched.c linux/kernel/sched.c
--- linux-2.5.8/kernel/sched.c	Sun Apr 14 15:18:47 2002
+++ linux/kernel/sched.c	Mon Apr 15 14:47:18 2002
@@ -1649,6 +1649,7 @@
 	if (!new_mask)
 		BUG();
 
+	preempt_disable();
 	rq = task_rq_lock(p, &flags);
 	p->cpus_allowed = new_mask;
 	/*
@@ -1657,7 +1658,7 @@
 	 */
 	if (new_mask & (1UL << p->thread_info->cpu)) {
 		task_rq_unlock(rq, &flags);
-		return;
+		goto out;
 	}
 
 	init_MUTEX_LOCKED(&req.sem);
@@ -1667,6 +1668,8 @@
 	wake_up_process(rq->migration_thread);
 
 	down(&req.sem);
+out:
+	preempt_enable();
 }
 
 static volatile unsigned long migration_mask;




^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2002-04-15 18:57 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2002-04-15 18:57 [PATCH] migration_thread preempt fix Robert Love

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).