sched, doc: Beef up load balancing description
Correct all function names pertaining to load balancing and explain shortly how load balancing is performed. Signed-off-by: Borislav Petkov <bp@alien8.de> Signed-off-by: Peter Zijlstra <a.p.zijlstra@chello.nl> LKML-Reference: <1301241433-3790-1-git-send-email-bp@alien8.de> Signed-off-by: Ingo Molnar <mingo@elte.hu>
This commit is contained in:
parent
a51e919818
commit
e2495b5773
1 changed files with 23 additions and 9 deletions
|
@ -1,8 +1,7 @@
|
||||||
Each CPU has a "base" scheduling domain (struct sched_domain). These are
|
Each CPU has a "base" scheduling domain (struct sched_domain). The domain
|
||||||
accessed via cpu_sched_domain(i) and this_sched_domain() macros. The domain
|
|
||||||
hierarchy is built from these base domains via the ->parent pointer. ->parent
|
hierarchy is built from these base domains via the ->parent pointer. ->parent
|
||||||
MUST be NULL terminated, and domain structures should be per-CPU as they
|
MUST be NULL terminated, and domain structures should be per-CPU as they are
|
||||||
are locklessly updated.
|
locklessly updated.
|
||||||
|
|
||||||
Each scheduling domain spans a number of CPUs (stored in the ->span field).
|
Each scheduling domain spans a number of CPUs (stored in the ->span field).
|
||||||
A domain's span MUST be a superset of it child's span (this restriction could
|
A domain's span MUST be a superset of it child's span (this restriction could
|
||||||
|
@ -26,11 +25,26 @@ is treated as one entity. The load of a group is defined as the sum of the
|
||||||
load of each of its member CPUs, and only when the load of a group becomes
|
load of each of its member CPUs, and only when the load of a group becomes
|
||||||
out of balance are tasks moved between groups.
|
out of balance are tasks moved between groups.
|
||||||
|
|
||||||
In kernel/sched.c, rebalance_tick is run periodically on each CPU. This
|
In kernel/sched.c, trigger_load_balance() is run periodically on each CPU
|
||||||
function takes its CPU's base sched domain and checks to see if has reached
|
through scheduler_tick(). It raises a softirq after the next regularly scheduled
|
||||||
its rebalance interval. If so, then it will run load_balance on that domain.
|
rebalancing event for the current runqueue has arrived. The actual load
|
||||||
rebalance_tick then checks the parent sched_domain (if it exists), and the
|
balancing workhorse, run_rebalance_domains()->rebalance_domains(), is then run
|
||||||
parent of the parent and so forth.
|
in softirq context (SCHED_SOFTIRQ).
|
||||||
|
|
||||||
|
The latter function takes two arguments: the current CPU and whether it was idle
|
||||||
|
at the time the scheduler_tick() happened and iterates over all sched domains
|
||||||
|
our CPU is on, starting from its base domain and going up the ->parent chain.
|
||||||
|
While doing that, it checks to see if the current domain has exhausted its
|
||||||
|
rebalance interval. If so, it runs load_balance() on that domain. It then checks
|
||||||
|
the parent sched_domain (if it exists), and the parent of the parent and so
|
||||||
|
forth.
|
||||||
|
|
||||||
|
Initially, load_balance() finds the busiest group in the current sched domain.
|
||||||
|
If it succeeds, it looks for the busiest runqueue of all the CPUs' runqueues in
|
||||||
|
that group. If it manages to find such a runqueue, it locks both our initial
|
||||||
|
CPU's runqueue and the newly found busiest one and starts moving tasks from it
|
||||||
|
to our runqueue. The exact number of tasks amounts to an imbalance previously
|
||||||
|
computed while iterating over this sched domain's groups.
|
||||||
|
|
||||||
*** Implementing sched domains ***
|
*** Implementing sched domains ***
|
||||||
The "base" domain will "span" the first level of the hierarchy. In the case
|
The "base" domain will "span" the first level of the hierarchy. In the case
|
||||||
|
|
Loading…
Reference in a new issue