All of lore.kernel.org
 help / color / mirror / Atom feed
* [RFC][PATCH] avoid cpu hot remove of cpus which have special RT tasks.
@ 2006-06-16  7:23 KAMEZAWA Hiroyuki
  2006-06-16  9:14 ` Andi Kleen
                   ` (2 more replies)
  0 siblings, 3 replies; 19+ messages in thread
From: KAMEZAWA Hiroyuki @ 2006-06-16  7:23 UTC (permalink / raw)
  To: LKML; +Cc: ashok.raj

When cpu hot remove happens, tasks on the target cpu will be migrated even if
no available cpus in tsk->cpus_allowed. (See: move_task_off_dead_cpu().)

Usually, it looks ok (I think not good but may be ok.) But forced migration
should be avoided if there is RT task which is designed to run only on
specified cpu.

This patch checks there is no such RT task on the target cpu at CPU_DOWN_PREPARE.
(Hot remove can fail at this point.) If found, cpu hot remove will fail.
By printing messages, I expect system admin will do proper ops.

This is a bit pessimistic. But forecd migration of RT task which is bounded
to the special cpu will cause unpredictable trouble, I think.

Signed-Off-By: KAMEZAWA Hiroyuki <kamezawa.hiroyu@jp.fujitsu.com>

 kernel/sched.c |   34 ++++++++++++++++++++++++++++++++++
 1 files changed, 34 insertions(+)

Index: linux-2.6.17-rc6-mm2/kernel/sched.c
===================================================================
--- linux-2.6.17-rc6-mm2.orig/kernel/sched.c
+++ linux-2.6.17-rc6-mm2/kernel/sched.c
@@ -5006,6 +5006,36 @@ static void migrate_nr_uninterruptible(r
 	local_irq_restore(flags);
 }
 
+/*
+ * Verify there is no RT tasks which is tightly bound to the cpu
+ * which is going to be removed.
+ */
+static int test_migratable_rt_tasks(int cpu)
+{
+	struct task_struct *tsk, *t;
+	int ret = 0;
+
+	read_lock_irq(&tasklist_lock);
+	do_each_thread(t, tsk) {
+		if (tsk == current)
+			continue;
+		if ((task_cpu(tsk) == cpu) &&
+		    rt_task(tsk) &&
+		    cpus_weight(tsk->cpus_allowed) == 1) {
+			ret = 1;
+			goto out;
+		}
+	} while_each_thread(t, tsk);
+out:
+	read_unlock_irq(&tasklist_lock);
+
+	if (ret)
+		printk("cpu hot remove: there are some cpu-bound rt tasks on"
+	        	"cpu%d\n",cpu);
+
+	return ret;
+}
+
 /* Run through task list and migrate tasks from the dead cpu. */
 static void migrate_live_tasks(int src_cpu)
 {
@@ -5257,6 +5287,10 @@ static int migration_call(struct notifie
 		kthread_stop(cpu_rq(cpu)->migration_thread);
 		cpu_rq(cpu)->migration_thread = NULL;
 		break;
+	case CPU_DOWN_PREPARE:
+		if (test_migratable_rt_tasks(cpu))
+			return NOTIFY_BAD;
+		break;
 	case CPU_DEAD:
 		migrate_live_tasks(cpu);
 		rq = cpu_rq(cpu);


^ permalink raw reply	[flat|nested] 19+ messages in thread

end of thread, other threads:[~2006-06-19  1:10 UTC | newest]

Thread overview: 19+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2006-06-16  7:23 [RFC][PATCH] avoid cpu hot remove of cpus which have special RT tasks KAMEZAWA Hiroyuki
2006-06-16  9:14 ` Andi Kleen
2006-06-16 10:26   ` KAMEZAWA Hiroyuki
2006-06-16 10:36     ` Andi Kleen
2006-06-16 10:58       ` KAMEZAWA Hiroyuki
2006-06-16 11:20         ` Andi Kleen
2006-06-16 11:25           ` KAMEZAWA Hiroyuki
2006-06-17  3:46       ` Nick Piggin
2006-06-17  5:12         ` KAMEZAWA Hiroyuki
2006-06-17  7:29           ` Nick Piggin
2006-06-17  7:53             ` KAMEZAWA Hiroyuki
2006-06-17  8:48               ` Nick Piggin
2006-06-17  8:58                 ` KAMEZAWA Hiroyuki
2006-06-16 16:09 ` Christoph Lameter
2006-06-16 16:46   ` KAMEZAWA Hiroyuki
2006-06-16 17:29     ` Ashok Raj
2006-06-16 23:47       ` KAMEZAWA Hiroyuki
2006-06-18 16:46 ` Pavel Machek
2006-06-19  1:12   ` KAMEZAWA Hiroyuki

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.