Skip to contentSkip to conversation

2.4-ac: migration_thread locking fix

PATCH In review Robert Love 1 participant 2 messages May 11, 2002

Subsystems (7)
Arm (32-bit) MIPS s390 SuperH +3 more subsystems
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 2.4-ac: migration_thread locking fix

Alan,

Anton Blanchard reported a lock vs. interrupt-off ordering bug in migration_thread. The bug is already fixed in 2.5. A patch is attached to fix O(1) in your tree.

See the comments above double_rq_lock and double_rq_unlock (which, sadly, I wrote)! Without this patch there is a possibility to hang, which Anton observed.

Patch is against 2.4.19-pre8-ac1, please apply.

Robert Love

kernel/sched.c +2 -2
diff -urN linux-2.4.19-pre8-ac1/kernel/sched.c linux/kernel/sched.c
@@ -1640,8 +1640,8 @@
 		local_irq_save(flags);
 		double_rq_lock(rq_src, rq_dest);
 		if (p->cpu != cpu_src) {
-			local_irq_restore(flags);
 			double_rq_unlock(rq_src, rq_dest);
+			local_irq_restore(flags);
 			goto repeat;
 		}
 		if (rq_src == rq) {
@@ -1651,8 +1651,8 @@
 				activate_task(p, rq_dest);
 			}
 		}
-		local_irq_restore(flags);
 		double_rq_unlock(rq_src, rq_dest);
+		local_irq_restore(flags);
 
 		up(&req->sem);
 	}
#1 lore raw
Quoted 3 lines · Robert Love

Anton Blanchard reported a lock vs. interrupt-off ordering bug in migration_thread. The bug is already fixed in 2.5. A patch is attached to fix O(1) in your tree.

Oh, this fix was included in the migration_thread cleanup in the latest batch of fixes I sent you against -ac1. I have attached an all-in-one patch if you missed it. Otherwise you can get the chunks at the usual kernel.org location.

Thanks,

Robert Love

arch/alpha/mm/fault.c +1 -2
diff -urN linux-2.4.19-pre8-ac1/arch/alpha/mm/fault.c linux/arch/alpha/mm/fault.c
@@ -196,8 +196,7 @@
  */
 out_of_memory:
 	if (current->pid == 1) {
-		current->policy |= SCHED_YIELD;
-		schedule();
+		yield();
 		down_read(&mm->mmap_sem);
 		goto survive;
 	}
arch/arm/mm/fault-common.c +1 -2
diff -urN linux-2.4.19-pre8-ac1/arch/arm/mm/fault-common.c linux/arch/arm/mm/fault-common.c
@@ -225,8 +225,7 @@
 	 * If we are out of memory for pid1,
 	 * sleep for a while and retry
 	 */
-	tsk->policy |= SCHED_YIELD;
-	schedule();
+	yield();
 	goto survive;
 
 check_stack:
arch/ia64/mm/fault.c +1 -2
diff -urN linux-2.4.19-pre8-ac1/arch/ia64/mm/fault.c linux/arch/ia64/mm/fault.c
@@ -196,8 +196,7 @@
   out_of_memory:
 	up_read(&mm->mmap_sem);
 	if (current->pid == 1) {
-		current->policy |= SCHED_YIELD;
-		schedule();
+		yield();
 		down_read(&mm->mmap_sem);
 		goto survive;
 	}
arch/m68k/mm/fault.c +1 -2
diff -urN linux-2.4.19-pre8-ac1/arch/m68k/mm/fault.c linux/arch/m68k/mm/fault.c
@@ -181,8 +181,7 @@
 out_of_memory:
 	up_read(&mm->mmap_sem);
 	if (current->pid == 1) {
-		current->policy |= SCHED_YIELD;
-		schedule();
+		yield();
 		down_read(&mm->mmap_sem);
 		goto survive;
 	}
arch/mips/mm/fault.c +1 -2
diff -urN linux-2.4.19-pre8-ac1/arch/mips/mm/fault.c linux/arch/mips/mm/fault.c
@@ -211,8 +211,7 @@
 out_of_memory:
 	up_read(&mm->mmap_sem);
 	if (tsk->pid == 1) {
-		tsk->policy |= SCHED_YIELD;
-		schedule();
+		yield();
 		down_read(&mm->mmap_sem);
 		goto survive;
 	}
arch/mips64/mm/fault.c +1 -2
diff -urN linux-2.4.19-pre8-ac1/arch/mips64/mm/fault.c linux/arch/mips64/mm/fault.c
@@ -240,8 +240,7 @@
 out_of_memory:
 	up_read(&mm->mmap_sem);
 	if (tsk->pid == 1) {
-		tsk->policy |= SCHED_YIELD;
-		schedule();
+		yield();
 		down_read(&mm->mmap_sem);
 		goto survive;
 	}
arch/ppc/mm/fault.c +1 -2
diff -urN linux-2.4.19-pre8-ac1/arch/ppc/mm/fault.c linux/arch/ppc/mm/fault.c
@@ -197,8 +197,7 @@
 out_of_memory:
 	up_read(&mm->mmap_sem);
 	if (current->pid == 1) {
-		current->policy |= SCHED_YIELD;
-		schedule();
+		yield();
 		down_read(&mm->mmap_sem);
 		goto survive;
 	}
arch/s390/mm/fault.c +1 -2
diff -urN linux-2.4.19-pre8-ac1/arch/s390/mm/fault.c linux/arch/s390/mm/fault.c
@@ -290,8 +290,7 @@
 out_of_memory:
 	up_read(&mm->mmap_sem);
 	if (tsk->pid == 1) {
-		tsk->policy |= SCHED_YIELD;
-		schedule();
+		yield();
 		down_read(&mm->mmap_sem);
 		goto survive;
 	}
arch/s390x/mm/fault.c +1 -2
diff -urN linux-2.4.19-pre8-ac1/arch/s390x/mm/fault.c linux/arch/s390x/mm/fault.c
@@ -290,8 +290,7 @@
 out_of_memory:
 	up_read(&mm->mmap_sem);
 	if (tsk->pid == 1) {
-		tsk->policy |= SCHED_YIELD;
-		schedule();
+		yield();
 		down_read(&mm->mmap_sem);
 		goto survive;
 	}
arch/sh/mm/fault.c +1 -2
diff -urN linux-2.4.19-pre8-ac1/arch/sh/mm/fault.c linux/arch/sh/mm/fault.c
@@ -207,8 +207,7 @@
 out_of_memory:
 	up_read(&mm->mmap_sem);
 	if (current->pid == 1) {
-		current->policy |= SCHED_YIELD;
-		schedule();
+		yield();
 		down_read(&mm->mmap_sem);
 		goto survive;
 	}
kernel/sched.c +40 -91

218 lines not on this page · raw message