Commit 7a0f3083 authored by Mel Gorman's avatar Mel Gorman Committed by Ingo Molnar

sched/numa: Resist moving tasks towards nodes with fewer hinting faults

Just as "sched: Favour moving tasks towards the preferred node" favours
moving tasks towards nodes with a higher number of recorded NUMA hinting
faults, this patch resists moving tasks towards nodes with lower faults.
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-24-git-send-email-mgorman@suse.deSigned-off-by: default avatarIngo Molnar <mingo@kernel.org>
parent 3a7053b3
...@@ -4107,12 +4107,43 @@ static bool migrate_improves_locality(struct task_struct *p, struct lb_env *env) ...@@ -4107,12 +4107,43 @@ static bool migrate_improves_locality(struct task_struct *p, struct lb_env *env)
return false; return false;
} }
static bool migrate_degrades_locality(struct task_struct *p, struct lb_env *env)
{
int src_nid, dst_nid;
if (!sched_feat(NUMA) || !sched_feat(NUMA_RESIST_LOWER))
return false;
if (!p->numa_faults || !(env->sd->flags & SD_NUMA))
return false;
src_nid = cpu_to_node(env->src_cpu);
dst_nid = cpu_to_node(env->dst_cpu);
if (src_nid == dst_nid ||
p->numa_migrate_seq >= sysctl_numa_balancing_settle_count)
return false;
if (p->numa_faults[dst_nid] < p->numa_faults[src_nid])
return true;
return false;
}
#else #else
static inline bool migrate_improves_locality(struct task_struct *p, static inline bool migrate_improves_locality(struct task_struct *p,
struct lb_env *env) struct lb_env *env)
{ {
return false; return false;
} }
static inline bool migrate_degrades_locality(struct task_struct *p,
struct lb_env *env)
{
return false;
}
#endif #endif
/* /*
...@@ -4177,6 +4208,8 @@ int can_migrate_task(struct task_struct *p, struct lb_env *env) ...@@ -4177,6 +4208,8 @@ int can_migrate_task(struct task_struct *p, struct lb_env *env)
* 3) too many balance attempts have failed. * 3) too many balance attempts have failed.
*/ */
tsk_cache_hot = task_hot(p, rq_clock_task(env->src_rq), env->sd); tsk_cache_hot = task_hot(p, rq_clock_task(env->src_rq), env->sd);
if (!tsk_cache_hot)
tsk_cache_hot = migrate_degrades_locality(p, env);
if (migrate_improves_locality(p, env)) { if (migrate_improves_locality(p, env)) {
#ifdef CONFIG_SCHEDSTATS #ifdef CONFIG_SCHEDSTATS
......
...@@ -74,4 +74,12 @@ SCHED_FEAT(NUMA, false) ...@@ -74,4 +74,12 @@ SCHED_FEAT(NUMA, false)
* balancing. * balancing.
*/ */
SCHED_FEAT(NUMA_FAVOUR_HIGHER, true) SCHED_FEAT(NUMA_FAVOUR_HIGHER, true)
/*
* NUMA_RESIST_LOWER will resist moving tasks towards nodes where a
* lower number of hinting faults have been recorded. As this has
* the potential to prevent a task ever migrating to a new node
* due to CPU overload it is disabled by default.
*/
SCHED_FEAT(NUMA_RESIST_LOWER, false)
#endif #endif
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