aboutsummaryrefslogtreecommitdiffstats
path: root/kernel/sched
diff options
context:
space:
mode:
authorRik van Riel <riel@redhat.com>2013-10-07 06:29:41 -0400
committerIngo Molnar <mingo@kernel.org>2013-10-09 08:48:25 -0400
commit2739d3eef3a93a92c366a3a0bb85a0afe09e8b8c (patch)
tree74f70c1af9469a659758d8caaacaafafe17df28f /kernel/sched
parent989348b5fc2367d6880d23a1c779a90bbb6f9baf (diff)
sched/numa: Retry task_numa_migrate() periodically
Short spikes of CPU load can lead to a task being migrated away from its preferred node for temporary reasons. It is important that the task is migrated back to where it belongs, in order to avoid migrating too much memory to its new location, and generally disturbing a task's NUMA location. This patch fixes NUMA placement for 4 specjbb instances on a 4 node system. Without this patch, things take longer to converge, and processes are not always completely on their own node. Signed-off-by: Rik van Riel <riel@redhat.com> Signed-off-by: Mel Gorman <mgorman@suse.de> Cc: Andrea Arcangeli <aarcange@redhat.com> Cc: Johannes Weiner <hannes@cmpxchg.org> Cc: Srikar Dronamraju <srikar@linux.vnet.ibm.com> Signed-off-by: Peter Zijlstra <peterz@infradead.org> Link: http://lkml.kernel.org/r/1381141781-10992-64-git-send-email-mgorman@suse.de Signed-off-by: Ingo Molnar <mingo@kernel.org>
Diffstat (limited to 'kernel/sched')
-rw-r--r--kernel/sched/fair.c22
1 files changed, 13 insertions, 9 deletions
diff --git a/kernel/sched/fair.c b/kernel/sched/fair.c
index 5b2208e504a4..e9149305c5fa 100644
--- a/kernel/sched/fair.c
+++ b/kernel/sched/fair.c
@@ -1259,18 +1259,19 @@ static int task_numa_migrate(struct task_struct *p)
1259/* Attempt to migrate a task to a CPU on the preferred node. */ 1259/* Attempt to migrate a task to a CPU on the preferred node. */
1260static void numa_migrate_preferred(struct task_struct *p) 1260static void numa_migrate_preferred(struct task_struct *p)
1261{ 1261{
1262 /* Success if task is already running on preferred CPU */ 1262 /* This task has no NUMA fault statistics yet */
1263 p->numa_migrate_retry = 0; 1263 if (unlikely(p->numa_preferred_nid == -1 || !p->numa_faults))
1264 if (cpu_to_node(task_cpu(p)) == p->numa_preferred_nid)
1265 return; 1264 return;
1266 1265
1267 /* This task has no NUMA fault statistics yet */ 1266 /* Periodically retry migrating the task to the preferred node */
1268 if (unlikely(p->numa_preferred_nid == -1)) 1267 p->numa_migrate_retry = jiffies + HZ;
1268
1269 /* Success if task is already running on preferred CPU */
1270 if (cpu_to_node(task_cpu(p)) == p->numa_preferred_nid)
1269 return; 1271 return;
1270 1272
1271 /* Otherwise, try migrate to a CPU on the preferred node */ 1273 /* Otherwise, try migrate to a CPU on the preferred node */
1272 if (task_numa_migrate(p) != 0) 1274 task_numa_migrate(p);
1273 p->numa_migrate_retry = jiffies + HZ*5;
1274} 1275}
1275 1276
1276/* 1277/*
@@ -1629,8 +1630,11 @@ void task_numa_fault(int last_cpupid, int node, int pages, int flags)
1629 1630
1630 task_numa_placement(p); 1631 task_numa_placement(p);
1631 1632
1632 /* Retry task to preferred node migration if it previously failed */ 1633 /*
1633 if (p->numa_migrate_retry && time_after(jiffies, p->numa_migrate_retry)) 1634 * Retry task to preferred node migration periodically, in case it
1635 * case it previously failed, or the scheduler moved us.
1636 */
1637 if (time_after(jiffies, p->numa_migrate_retry))
1634 numa_migrate_preferred(p); 1638 numa_migrate_preferred(p);
1635 1639
1636 if (migrated) 1640 if (migrated)