sched/fair: correct llc shared domain's number of busy CPUs
A message that is not in the archive (sent off-list or not yet received): [email protected]
Quoted 8 lines · Hillf Danton
The comment says, if there is an imbalance between LLC domains (IOW we could increase the overall cache use), we need some less-loaded LLC domain to pull some load.
To show that imbalance, record busy CPUs as they come and go by doing a minor cleanup for
sd::nohz_idle.
Your comment failed to explain why we can get rid of sd->nohz_idle
Quoted 11 lines
Cc Mel Gorman <[email protected]>Cc Vincent Guittot <[email protected]>Cc Valentin Schneider <[email protected]>Cc Dietmar Eggemann <[email protected]>Signed-off-by Hillf Danton <[email protected]>---
kernel/sched/fair.c static void set_cpu_sd_state_busy(int cp · line 10144
Quoted 7 lines
kernel/sched/fair.c +0
-4@@ -10138,13 +10138,8 @@ static void set_cpu_sd_state_busy(int cprcu_read_lock (); sd =rcu_dereference (per_cpu (sd_llc, cpu)); - -if (!sd || !sd->nohz_idle) - goto unlock; - sd->nohz_idle =0 ;
you remove the use of sd->nohz_idle but you don't remove it from struct sched_domain
Quoted 25 lines
kernel/sched/fair.c +4
-10- -atomic_inc (&sd->shared->nr_busy_cpus); -unlock: +if (sd) +atomic_inc (&sd->shared->nr_busy_cpus);rcu_read_unlock (); }@@ -10168,13 +10163,8 @@ static void set_cpu_sd_state_idle(int cprcu_read_lock (); sd =rcu_dereference (per_cpu (sd_llc, cpu)); - -if (!sd || sd->nohz_idle) - goto unlock; - sd->nohz_idle =1 ; - -atomic_dec (&sd->shared->nr_busy_cpus); -unlock: +if (sd) +atomic_dec (&sd->shared->nr_busy_cpus);rcu_read_unlock (); }
A message that is not in the archive (sent off-list or not yet received): [email protected]
Quoted 10 lines · Hillf Danton
Quoted 7 lines · On Mon, 4 May 2020 09:53:36 Vincent Guittot wrote:
Quoted 5 lines · Hillf Danton
The comment says, if there is an imbalance between LLC domains (IOW we could increase the overall cache use), we need some less-loaded LLC domain to pull some load.
Quoted 8 lines
Quoted 5 lines
Quoted 2 lines
To show that imbalance, record busy CPUs as they come and go by doing a minor cleanup for
sd::nohz_idle.Your comment failed to explain why we can get rid of
sd->nohz_idleThe serialization added in
25f55d9d01ad("sched: Fix initNOHZ_IDLEflag") to updatingnr_busy_cpusis no longer needed after0e369d757578("sched/core:
Replace sd_busy/nr_busy_cpus withsched_domain_shared") AFAICT because a
I don't see the link between commit 0e369d757578 and the fact that we can remove the nohz_idle field.
Quoted 2 lines
recorded idle/busy CPU does not mean the current CPU could not become idle or busy. The right thing is to update the counter if we have a valid sd under rcu.
No it's not the root cause because the sd is per cpu so each cpu has its own sd->nohz_idle so if cpu A set sd->nohz_idle, cpu B will not be impact and will have to set its own.
We must ensure that nr_busy_cpus is inc/dec only once when transitioning from/to idle/busy state in order to keep the shared nr_busy_cpus correct. But set_cpu_sd_state_busy() is called from scheduler_tick() which means potentially every tick:
scheduler_tick() -> trigger_load_balance() -> nohz_balancer_kick() -> nohz_balance_exit_idle() -> set_cpu_sd_state_busy()
The nohz_idle field is there to prevent incrementing nr_busy_cpus at every tick. But set_cpu_sd_state_busy() is called from nohz_balance_exit_idle() since 00357f5ec5d6 ("sched/nohz: Clean up nohz enter/exit") and the latter has a similar mechanism with rq->nohz_tick_stopped so sd_llc->nohz_idle is useless
Quoted 5 lines
Quoted 3 lines
you remove the use of
sd->nohz_idlebut you don't remove it from structsched_domainA seperate cleanup for it is needed if it's no longer used somewhere else.
Please remove it in the same patch
Quoted 3 lines
Hillf