Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

sched/fair: Combine EAS check with root_domain::overutilized access

Access to root_domainoverutilized is always used with sched_energy_enabled in
the pattern:

if (sched_energy_enabled && !overutilized)
do something

So modify the helper function to utilize this pattern. This is more
readable code as it would say, do something when root domain is not
overutilized. This function always return true when EAS is disabled.

No change in functionality intended.

Suggested-by: Vincent Guittot <vincent.guittot@linaro.org>
Signed-off-by: Shrikanth Hegde <sshegde@linux.ibm.com>
Signed-off-by: Ingo Molnar <mingo@kernel.org>
Link: https://lore.kernel.org/r/20240326152616.380999-1-sshegde@linux.ibm.com

authored by

Shrikanth Hegde and committed by
Ingo Molnar
902e786c c829d681

+7 -13
+7 -13
kernel/sched/fair.c
··· 6686 6686 } 6687 6687 6688 6688 /* 6689 - * Ensure that caller can do EAS. overutilized value 6690 - * make sense only if EAS is enabled 6689 + * overutilized value make sense only if EAS is enabled 6691 6690 */ 6692 6691 static inline int is_rd_overutilized(struct root_domain *rd) 6693 6692 { 6694 - return READ_ONCE(rd->overutilized); 6693 + return !sched_energy_enabled() || READ_ONCE(rd->overutilized); 6695 6694 } 6696 6695 6697 6696 static inline void set_rd_overutilized_status(struct root_domain *rd, ··· 6709 6710 * overutilized field is used for load balancing decisions only 6710 6711 * if energy aware scheduler is being used 6711 6712 */ 6712 - if (!sched_energy_enabled()) 6713 - return; 6714 6713 6715 6714 if (!is_rd_overutilized(rq->rd) && cpu_overutilized(rq->cpu)) 6716 6715 set_rd_overutilized_status(rq->rd, SG_OVERUTILIZED); ··· 7996 7999 7997 8000 rcu_read_lock(); 7998 8001 pd = rcu_dereference(rd->pd); 7999 - if (!pd || is_rd_overutilized(rd)) 8002 + if (!pd) 8000 8003 goto unlock; 8001 8004 8002 8005 /* ··· 8199 8202 cpumask_test_cpu(cpu, p->cpus_ptr)) 8200 8203 return cpu; 8201 8204 8202 - if (sched_energy_enabled()) { 8205 + if (!is_rd_overutilized(this_rq()->rd)) { 8203 8206 new_cpu = find_energy_efficient_cpu(p, prev_cpu); 8204 8207 if (new_cpu >= 0) 8205 8208 return new_cpu; ··· 10900 10903 if (busiest->group_type == group_misfit_task) 10901 10904 goto force_balance; 10902 10905 10903 - if (sched_energy_enabled()) { 10904 - struct root_domain *rd = env->dst_rq->rd; 10905 - 10906 - if (rcu_dereference(rd->pd) && !is_rd_overutilized(rd)) 10907 - goto out_balanced; 10908 - } 10906 + if (!is_rd_overutilized(env->dst_rq->rd) && 10907 + rcu_dereference(env->dst_rq->rd->pd)) 10908 + goto out_balanced; 10909 10909 10910 10910 /* ASYM feature bypasses nice load balance check */ 10911 10911 if (busiest->group_type == group_asym_packing)