Commit 688b7585 authored by Mel Gorman's avatar Mel Gorman Committed by Ingo Molnar

sched/numa: Select a preferred node with the most numa hinting faults

This patch selects a preferred node for a task to run on based on the
NUMA hinting faults. This information is later used to migrate tasks
towards the node during balancing.
Signed-off-by: default avatarMel Gorman <mgorman@suse.de>
Reviewed-by: default avatarRik van Riel <riel@redhat.com>
Cc: Andrea Arcangeli <aarcange@redhat.com>
Cc: Johannes Weiner <hannes@cmpxchg.org>
Cc: Srikar Dronamraju <srikar@linux.vnet.ibm.com>
Signed-off-by: default avatarPeter Zijlstra <peterz@infradead.org>
Link: http://lkml.kernel.org/r/1381141781-10992-21-git-send-email-mgorman@suse.deSigned-off-by: default avatarIngo Molnar <mingo@kernel.org>
parent f809ca9a
...@@ -1344,6 +1344,7 @@ struct task_struct { ...@@ -1344,6 +1344,7 @@ struct task_struct {
struct callback_head numa_work; struct callback_head numa_work;
unsigned long *numa_faults; unsigned long *numa_faults;
int numa_preferred_nid;
#endif /* CONFIG_NUMA_BALANCING */ #endif /* CONFIG_NUMA_BALANCING */
struct rcu_head rcu; struct rcu_head rcu;
......
...@@ -1633,6 +1633,7 @@ static void __sched_fork(struct task_struct *p) ...@@ -1633,6 +1633,7 @@ static void __sched_fork(struct task_struct *p)
p->numa_scan_seq = p->mm ? p->mm->numa_scan_seq : 0; p->numa_scan_seq = p->mm ? p->mm->numa_scan_seq : 0;
p->numa_migrate_seq = p->mm ? p->mm->numa_scan_seq - 1 : 0; p->numa_migrate_seq = p->mm ? p->mm->numa_scan_seq - 1 : 0;
p->numa_scan_period = sysctl_numa_balancing_scan_delay; p->numa_scan_period = sysctl_numa_balancing_scan_delay;
p->numa_preferred_nid = -1;
p->numa_work.next = &p->numa_work; p->numa_work.next = &p->numa_work;
p->numa_faults = NULL; p->numa_faults = NULL;
#endif /* CONFIG_NUMA_BALANCING */ #endif /* CONFIG_NUMA_BALANCING */
......
...@@ -879,7 +879,8 @@ static unsigned int task_scan_max(struct task_struct *p) ...@@ -879,7 +879,8 @@ static unsigned int task_scan_max(struct task_struct *p)
static void task_numa_placement(struct task_struct *p) static void task_numa_placement(struct task_struct *p)
{ {
int seq; int seq, nid, max_nid = -1;
unsigned long max_faults = 0;
if (!p->mm) /* for example, ksmd faulting in a user's mm */ if (!p->mm) /* for example, ksmd faulting in a user's mm */
return; return;
...@@ -889,7 +890,19 @@ static void task_numa_placement(struct task_struct *p) ...@@ -889,7 +890,19 @@ static void task_numa_placement(struct task_struct *p)
p->numa_scan_seq = seq; p->numa_scan_seq = seq;
p->numa_scan_period_max = task_scan_max(p); p->numa_scan_period_max = task_scan_max(p);
/* FIXME: Scheduling placement policy hints go here */ /* Find the node with the highest number of faults */
for_each_online_node(nid) {
unsigned long faults = p->numa_faults[nid];
p->numa_faults[nid] >>= 1;
if (faults > max_faults) {
max_faults = faults;
max_nid = nid;
}
}
/* Update the tasks preferred node if necessary */
if (max_faults && max_nid != p->numa_preferred_nid)
p->numa_preferred_nid = max_nid;
} }
/* /*
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment