sched: decrease number of load balances
PATCH 1/1 sched: decrease number of load balances
This patch goes on top of the Christoph's sched patches in -mm. Thanks.
---
Currently at a particular domain, each cpu in the sched group will do a load balance at the frequency of balance_interval. More the cores and threads, more the cpus will be in each sched group at SMP and NUMA domain. And we endup spending quite a bit of time doing load balancing in those domains.
Fix this by making only one cpu(first idle cpu or first cpu in the group if all the cpus are busy) in the sched group do the load balance at that particular sched domain and this load will slowly percolate down to the other cpus with in that group(when they do load balancing at lower domains).
---
include/linux/sched.h +1 -0
@@ -706,6 +706,7 @@ struct sched_domain {unsigned long lb_hot_gained[MAX_IDLE_TYPES ];unsigned long lb_nobusyg[MAX_IDLE_TYPES ];unsigned long lb_nobusyq[MAX_IDLE_TYPES ]; +unsigned long lb_stopbalance[MAX_IDLE_TYPES ];/* Active load balancing */ unsigned long alb_cnt;
kernel/sched.c +47 -12
149 lines not on this page · raw message
kernel/sched.c find_busiest_group(struct sched_domain * · line 2324
Quoted 1 line · Suresh B
kernel/sched.c +1
-0+if (local_group && balance_cpu != this_cpu && balance) {
^^^^^
This would need to be *balance right? balance is always != 0.
kernel/sched.c find_busiest_group(struct sched_domain * · line 2327
Quoted 3 lines
kernel/sched.c +3
-0+ *balance =0 ; + goto ret; + }
How well was this patch tested?
We already have idle processors pulling processes from elsewhere in the system. Load balancing on an idle processor could only replicate the balance on idle logic.
Quoted 5 lines · Christoph Lameter
kernel/sched.c find_busiest_group(struct sched_domain * · line 2324
Quoted 1 line · Suresh B
kernel/sched.c +1
-0+if (local_group && balance_cpu != this_cpu && balance) {This would need to be *balance right? balance is always != 0.
No. In newly idle case it is NULL. In newly idle case there is likely some imbalance and hence wanted to go through normal logic of doing load balance till it finds something. newly idle balance anyhow won't do load balance at NUMA domain.
Quoted 1 line
How well was this patch tested?
We have run it through workloads which are used to identify kernel perf regressions and ran on several DP and MP systems with HT and MC. (workloads and system info can be found at http://kernel-perf.sourceforge.net)
We didn't find any regression with this patch.
We are also doing more testing with this patch and also wanted to get it tested in -mm.
Quoted 3 lines
We already have idle processors pulling processes from elsewhere in the system. Load balancing on an idle processor could only replicate the balance on idle logic.
My patch is not changing any idle load balancing logic and hence it is no less/more aggressive as the current one.
What do you mean by "balance on idle logic"? Are you referring to load_idx that gets used, based on the processor is idle/busy?
Even with out this patch, if there is an idle processor in a group at domain level 'x', then the idle processor will do an idle load balance between the groups at level 'x'. This patch just cuts down the load balances done by the busy and other idle cpus in the group.
thanks,
suresh
Quoted 2 lines · Suresh B
My patch is not changing any idle load balancing logic and hence it is no less/more aggressive as the current one.
But you cannot do anything in addition to idle balancing. You can only draw a process to the cpu you are balancing on. And we are already doing that. So this cuts down the frequency of idle balance? And only the first idle processor of a group of idle processors does balancing?
Quoted 8 lines · Christoph Lameter
Quoted 2 lines · Suresh B
My patch is not changing any idle load balancing logic and hence it is no less/more aggressive as the current one.
But you cannot do anything in addition to idle balancing. You can only draw a process to the cpu you are balancing on. And we are already doing that.
Yes. The above logic is not changed.
Once an idle processor('P') picked up some load(based on load differences of groups at level 'X) at level 'X', group of cpus(containing 'P') in level 'X-1' will try to distribute that load among them depending on their groups load at that level. And this repeats till we reach the lowest level..
Quoted 1 line
So this cuts down the frequency of idle balance?
Frequency of idle processor doing balance is same as today but what we reduce is number of processors doing that load balance.
Quoted 1 line
And only the first idle processor of a group of idle processors does balancing?
That is correct. If all the cpus in a group are busy, then only the first cpu in the group will do load balance between the groups. We really don't have to calculate who in the group is leastly loaded, as we can assume that load is equally balanced at level 'X-1' while doing load balancing at level 'X'.
thanks,
suresh