History

sched/numa: Allow a floating imbalance between NUMA nodes

Currently, an imbalance is only allowed when a destination node is almost completely idle. This solved one basic class of problems and was the cautious approach. This patch revisits the possibility that NUMA nodes can be imbalanced until 25% of the CPUs are occupied. The reasoning behind 25% is somewhat superficial -- it's half the cores when HT is enabled. At higher utilisations, balancing should continue as normal and keep things even until scheduler domains are fully busy or over utilised. Note that this is not expected to be a universal win. Any benchmark that prefers spreading as wide as possible with limited communication will favour the old behaviour as there is more memory bandwidth. Workloads that communicate heavily in pairs such as netperf or tbench benefit. For the tests I ran, the vast majority of workloads saw a benefit so it seems to be a worthwhile trade-off.

Mel Gorman committed 5 years ago

Commit 7d2b5dd1 parent 5c339001 file · +11 −10Browse files

Unified · Split

kernel/sched/fair.c+11−10
@@ -1559,7 +1559,8 @@ struct task_numa_env { · 1558 unmodified lines
1559static unsigned long cpu_load(struct rq *rq);1559static unsigned long cpu_load(struct rq *rq);
1560static unsigned long cpu_runnable(struct rq *rq);1560static unsigned long cpu_runnable(struct rq *rq);
1561static unsigned long cpu_util(int cpu);1561static unsigned long cpu_util(int cpu);
1562static inline long adjust_numa_imbalance(int imbalance, int dst_running);1562static inline long adjust_numa_imbalance(int imbalance,
1563 int dst_running, int dst_weight);
1563 1564
1564static inline enum1565static inline enum
1565numa_type numa_classify(unsigned int imbalance_pct,1566numa_type numa_classify(unsigned int imbalance_pct,
@@ -1939,7 +1940,8 @@ static void task_numa_find_cpu(struct task_numa_env *env, · 373 unmodified lines
1939 src_running = env->src_stats.nr_running - 1;1940 src_running = env->src_stats.nr_running - 1;
1940 dst_running = env->dst_stats.nr_running + 1;1941 dst_running = env->dst_stats.nr_running + 1;
1941 imbalance = max(0, dst_running - src_running);1942 imbalance = max(0, dst_running - src_running);
1942 imbalance = adjust_numa_imbalance(imbalance, dst_running);1943 imbalance = adjust_numa_imbalance(imbalance, dst_running,
1944 env->dst_stats.weight);
1943 1945
1944 /* Use idle CPU if there is no imbalance */1946 /* Use idle CPU if there is no imbalance */
1945 if (!imbalance) {1947 if (!imbalance) {
@@ -8995,16 +8997,14 @@ next_group: · 7049 unmodified lines
8995 8997
8996#define NUMA_IMBALANCE_MIN 28998#define NUMA_IMBALANCE_MIN 2
8997 8999
8998static inline long adjust_numa_imbalance(int imbalance, int dst_running)9000static inline long adjust_numa_imbalance(int imbalance,
9001 int dst_running, int dst_weight)
8999{9002{
9000 unsigned int imbalance_min;
9001
9002 /*9003 /*
9003 * Allow a small imbalance based on a simple pair of communicating9004 * Allow a small imbalance based on a simple pair of communicating
9004 * tasks that remain local when the source domain is almost idle.9005 * tasks that remain local when the destination is lightly loaded.
9005 */9006 */
9006 imbalance_min = NUMA_IMBALANCE_MIN;9007 if (dst_running < (dst_weight >> 2) && imbalance <= NUMA_IMBALANCE_MIN)
9007 if (dst_running <= imbalance_min)
9008 return 0;9008 return 0;
9009 9009
9010 return imbalance;9010 return imbalance;
@@ -9106,9 +9106,10 @@ static inline void calculate_imbalance(struct lb_env *env, struct sd_lb_stats *s · 95 unmodified lines
9106 }9106 }
9107 9107
9108 /* Consider allowing a small imbalance between NUMA groups */9108 /* Consider allowing a small imbalance between NUMA groups */
9109 if (env->sd->flags & SD_NUMA)9109 if (env->sd->flags & SD_NUMA) {
9110 env->imbalance = adjust_numa_imbalance(env->imbalance,9110 env->imbalance = adjust_numa_imbalance(env->imbalance,
9111 busiest->sum_nr_running);9111 busiest->sum_nr_running, busiest->group_weight);
9112 }
9112 9113
9113 return;9114 return;
9114 }9115 }

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t