mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Rusty Russell <rusty@rustcorp.com.au>
To: Nathan Lynch <nathanl@austin.ibm.com>
Cc: Andrew Morton <akpm@osdl.org>,
	lkml - Kernel Mailing List <linux-kernel@vger.kernel.org>,
	Nick Piggin <nickpiggin@yahoo.com.au>,
	Ingo Molnar <mingo@elte.hu>,
	Zwane Mwaikambo <zwane@linuxpower.ca>
Subject: [PATCH 1/2] Neaten migrate_all_tasks
Date: Thu, 26 Aug 2004 17:57:19 +1000	[thread overview]
Message-ID: <1093507039.13516.2508.camel@bach> (raw)
In-Reply-To: <1093475339.7056.6.camel@pants.austin.ibm.com>

Name: Neaten migrate_all_tasks
Status: Tested on 2.6.8.1-mm4
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
Version: -mm

A followup patch wants to do forced migration, so separate that part
of the code out of migrate_all_tasks().

diff -urpN --exclude TAGS -X /home/rusty/devel/kernel/kernel-patches/current-dontdiff --minimal .13565-linux-2.6.8.1-mm4/kernel/sched.c .13565-linux-2.6.8.1-mm4.updated/kernel/sched.c
--- .13565-linux-2.6.8.1-mm4/kernel/sched.c	2004-08-23 10:11:51.000000000 +1000
+++ .13565-linux-2.6.8.1-mm4.updated/kernel/sched.c	2004-08-26 16:58:45.000000000 +1000
@@ -3784,52 +3784,55 @@ wait_to_die:
 }
 
 #ifdef CONFIG_HOTPLUG_CPU
+/* Figure out where task on dead CPU should go, use force if neccessary. */
+static void move_task_off_dead_cpu(int dead_cpu, struct task_struct *tsk)
+{
+	int dest_cpu;
+	cpumask_t mask = node_to_cpumask(cpu_to_node(dead_cpu));
+
+	/* On same node? */
+	mask = node_to_cpumask(node);
+	cpus_and(mask, mask, tsk->cpus_allowed);
+	dest_cpu = any_online_cpu(mask);
+
+	/* On any allowed CPU? */
+	if (dest_cpu == NR_CPUS)
+		dest_cpu = any_online_cpu(tsk->cpus_allowed);
+
+	/* No more Mr. Nice Guy. */
+	if (dest_cpu == NR_CPUS) {
+		/* Anything online CPU set?  If not, allow on anything. */
+		tsk->cpus_allowed = cpuset_cpus_allowed(tsk);
+		if (!cpus_intersects(tsk->cpus_allowed, cpu_online_map))
+			cpus_setall(tsk->cpus_allowed);
+		dest_cpu = any_online_cpu(tsk->cpus_allowed);
+
+		/* 
+		 * Don't tell them about moving exiting tasks or
+		 * kernel threads (both mm NULL), since they never
+		 * leave kernel.
+		 */
+		if (tsk->mm && printk_ratelimit())
+			printk(KERN_INFO "process %d (%s) no "
+			       "longer affine to cpu%d\n",
+			       tsk->pid, tsk->comm, task_cpu(tsk));
+	}
+	__migrate_task(tsk, dead_cpu, dest_cpu);
+}
+
 /* migrate_all_tasks - function to migrate all tasks from the dead cpu. */
 static void migrate_all_tasks(int src_cpu)
 {
 	struct task_struct *tsk, *t;
-	int dest_cpu;
-	unsigned int node;
 
 	write_lock_irq(&tasklist_lock);
 
-	/* watch out for per node tasks, let's stay on this node */
-	node = cpu_to_node(src_cpu);
-
 	do_each_thread(t, tsk) {
-		cpumask_t mask;
 		if (tsk == current)
 			continue;
 
-		if (task_cpu(tsk) != src_cpu)
-			continue;
-
-		/* Figure out where this task should go (attempting to
-		 * keep it on-node), and check if it can be migrated
-		 * as-is.  NOTE that kernel threads bound to more than
-		 * one online cpu will be migrated. */
-		mask = node_to_cpumask(node);
-		cpus_and(mask, mask, tsk->cpus_allowed);
-		dest_cpu = any_online_cpu(mask);
-		if (dest_cpu == NR_CPUS)
-			dest_cpu = any_online_cpu(tsk->cpus_allowed);
-		if (dest_cpu == NR_CPUS) {
-			tsk->cpus_allowed = cpuset_cpus_allowed(tsk);
-			if (!cpus_intersects(tsk->cpus_allowed, cpu_online_map))
-				cpus_setall(tsk->cpus_allowed);
-			dest_cpu = any_online_cpu(tsk->cpus_allowed);
-
-			/*
-			 * Don't tell them about moving exiting tasks
-			 * or kernel threads (both mm NULL), since
-			 * they never leave kernel.
-			 */
-			if (tsk->mm && printk_ratelimit())
-				printk(KERN_INFO "process %d (%s) no "
-				       "longer affine to cpu%d\n",
-				       tsk->pid, tsk->comm, src_cpu);
-		}
-		__migrate_task(tsk, src_cpu, dest_cpu);
+		if (task_cpu(tsk) == src_cpu)
+			move_task_off_dead_cpu(src_cpu, tsk);
 	} while_each_thread(t, tsk);
 
 	write_unlock_irq(&tasklist_lock);


-- 
Anyone who quotes me in their signature is an idiot -- Rusty Russell


  parent reply	other threads:[~2004-08-26  8:01 UTC|newest]

Thread overview: 36+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2004-08-22  8:34 2.6.8.1-mm4 Andrew Morton
2004-08-22 14:20 ` 2.6.8.1-mm4 (strange behavior on dual Opteron w/ NUMA) R. J. Wysocki
2004-08-23  2:18 ` 2.6.8.1-mm4 - failed opcode was: 0xe7 Ed Tomlinson
2004-08-23  5:00 ` 2.6.8.1-mm4 Eric W. Biederman
2004-08-23 12:00   ` 2.6.8.1-mm4 Alan Cox
2004-08-23 14:24     ` 2.6.8.1-mm4 Eric W. Biederman
2004-08-23 14:11 ` 2.6.8.1-mm4 (compile stats) John Cherry
2004-08-23 15:29 ` 2.6.8.1-mm4 (strange behavior on dual Opteron w/ NUMA) David Howells
2004-08-23 15:46   ` Randy.Dunlap
2004-08-23 18:27     ` Andrew Morton
2004-08-23 18:57       ` Randy.Dunlap
2004-08-23 18:21 ` 2.6.8.1-mm4 Tomasz Torcz
2004-08-23 18:31   ` 2.6.8.1-mm4 Alan Cox
2004-08-23 19:40     ` 2.6.8.1-mm4 Andrew Morton
2004-08-23 19:15       ` 2.6.8.1-mm4 Alan Cox
2004-08-23 21:19         ` 2.6.8.1-mm4 David S. Miller
2004-08-23 20:21 ` 2.6.8.1-mm4 wli
2004-08-24  6:14   ` 2.6.8.1-mm4 Andrew Morton
2004-08-24  7:55     ` O(1) proc_pid_statm() William Lee Irwin III
2004-08-24 17:05       ` fix text reporting in " William Lee Irwin III
2004-08-25  0:06     ` [PATCH] advice to use good patch subject, for SubmittingPatches Tim Bird
2004-08-23 22:18 ` 2.6.8.1-mm4 - more cpu hotplug breakage Nathan Lynch
2004-08-25  3:57   ` Nathan Lynch
2004-08-25 23:09   ` Nathan Lynch
2004-08-26  2:54     ` Rusty Russell
2004-08-26  7:57     ` Rusty Russell [this message]
2004-08-26  7:58     ` [PATCH 2/2] Hotplug CPU vs TASK_ZOMBIEs: The Sequel to Hotplug CPU vs TASK_DEAD Rusty Russell
2004-08-26 15:29       ` Nathan Lynch
2004-08-27  1:38         ` Rusty Russell
2004-08-24 20:56 ` 2.6.8.1-mm4 William Lee Irwin III
2004-08-24 20:57   ` 2.6.8.1-mm4 William Lee Irwin III
2004-08-24 21:23   ` 2.6.8.1-mm4 William Lee Irwin III
2004-08-24 21:26     ` 2.6.8.1-mm4 William Lee Irwin III
2004-08-24 21:37     ` 2.6.8.1-mm4 William Lee Irwin III
2004-08-24 21:48   ` 2.6.8.1-mm4 William Lee Irwin III
2004-08-24 21:06 ` WAITQUEUE_DEBUG crapectomy William Lee Irwin III

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=1093507039.13516.2508.camel@bach \
    --to=rusty@rustcorp.com.au \
    --cc=akpm@osdl.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mingo@elte.hu \
    --cc=nathanl@austin.ibm.com \
    --cc=nickpiggin@yahoo.com.au \
    --cc=zwane@linuxpower.ca \
    /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

all inboxes | Powered by JetHome®