Skip to contentSkip to conversation

explict migrate tasks for cpu removal

PATCH In review Shaohua Li 2 participants 2 messages May 8, 2006

Subsystems (2)
lore
Share & tools
lore

Shaohua Li

author
#0 lore raw

PATCH 3/10 explict migrate tasks for cpu removal

Make cpu_down explictly migrate tasks off dead cpus, this is to fix a dead lock in bulk cpu hotremoval (An example of the deadlock is one dead cpu is notifing udev the cpu is dead and khelper thread is on another dead cpu). Detail info is in the code.

---

 linux-2.6.17-rc3-root/include/linux/sched.h |    1 
 linux-2.6.17-rc3-root/kernel/cpu.c          |    7 ++
 linux-2.6.17-rc3-root/kernel/sched.c        |   67 +++++++++++++++++-----------
 3 files changed, 48 insertions(+), 27 deletions(-)
include/linux/sched.h renamed from include/linux/sched.h~explict-migrate-tasks +1 -0
diff -puN include/linux/sched.h~explict-migrate-tasks include/linux/sched.h
@@ -997,6 +997,7 @@ extern void sched_exec(void);
 
 #ifdef CONFIG_HOTPLUG_CPU
 extern void idle_task_exit(void);
+extern void migrate_tasks_off_dead_cpu(int cpu);
 #else
 static inline void idle_task_exit(void) {}
 #endif
kernel/cpu.c renamed from kernel/cpu.c~explict-migrate-tasks +6 -1
diff -puN kernel/cpu.c~explict-migrate-tasks kernel/cpu.c
@@ -173,7 +173,12 @@ int cpu_down(unsigned int cpu)
 	kthread_bind(p, get_cpu());
 	put_cpu();
 
-	/* CPU is completely dead: tell everyone.  Too late to complain. */
+	/*
+	 * CPU is completely dead: tell everyone.  Too late to complain.
+	 * we explictly call migrate_tasks here, otherwise there is a deadlock,
+	 * one cpu's notifier handler is waiting for tasks in other dead CPUs
+	 */
+	migrate_tasks_off_dead_cpu(cpu);
 	if (blocking_notifier_call_chain(&cpu_chain, CPU_DEAD,
 			(void *)(long)cpu) == NOTIFY_BAD)
 		BUG();
kernel/sched.c renamed from kernel/sched.c~explict-migrate-tasks +41 -26

79 lines not on this page · raw message

_

#1 lore raw
Quoted 4 lines · Shaohua Li

Make cpu_down explictly migrate tasks off dead cpus, this is to fix a dead lock in bulk cpu hotremoval (An example of the deadlock is one dead cpu is notifing udev the cpu is dead and khelper thread is on another dead cpu). Detail info is in the code.

looks good, except some style issues:

kernel/sched.c static void migrate_dead_tasks(unsigned · line 4764

Quoted 3 lines
kernel/sched.c renamed from kernel/sched.c~explict-migrate-tasks +3 -0
+	/* No need to migrate the tasks: it was best-effort if
+	 * they didn't do lock_cpu_hotplug().  Just wake up
+	 * the requestors. */

needs proper comment style.

kernel/sched.c static void migrate_dead_tasks(unsigned · line 4769

Quoted 3 lines
kernel/sched.c renamed from kernel/sched.c~explict-migrate-tasks +3 -0
+		migration_req_t *req;
+		req = list_entry(rq->migration_queue.next,
+				 migration_req_t, list);

missing newline between variables and code.

Ingo