sched/numa: Do not set preferred_node on migration to a second choice node
[deliverable/linux.git] / kernel / sched / fair.c
index ecea8d9f957c1eaf3aa9bc9a9103207280de021a..051903f33eecda03da3c27afdbf14617c1aaa61d 100644 (file)
@@ -1301,7 +1301,16 @@ static int task_numa_migrate(struct task_struct *p)
        if (env.best_cpu == -1)
                return -EAGAIN;
 
-       sched_setnuma(p, env.dst_nid);
+       /*
+        * If the task is part of a workload that spans multiple NUMA nodes,
+        * and is migrating into one of the workload's active nodes, remember
+        * this node as the task's preferred numa node, so the workload can
+        * settle down.
+        * A task that migrated to a second choice node will be better off
+        * trying for a better one later. Do not set the preferred node here.
+        */
+       if (p->numa_group && node_isset(env.dst_nid, p->numa_group->active_nodes))
+               sched_setnuma(p, env.dst_nid);
 
        /*
         * Reset the scan period if the task is being rescheduled on an
This page took 0.025548 seconds and 5 git commands to generate.