Re: [RFC PATCH v2 4/7] sched/fair: Use CFS util_avg_uclamp for utilization and frequency

From: Dietmar Eggemann
Date: Fri Mar 15 2024 - 08:31:27 EST


On 01/02/2024 14:12, Hongyan Xia wrote:

[...]

> @@ -7685,11 +7697,13 @@ static int select_idle_sibling(struct task_struct *p, int prev, int target)
> static unsigned long
> cpu_util(int cpu, struct task_struct *p, int dst_cpu, int boost)
> {
> - struct cfs_rq *cfs_rq = &cpu_rq(cpu)->cfs;
> - unsigned long util = READ_ONCE(cfs_rq->avg.util_avg);
> + struct rq *rq = cpu_rq(cpu);
> + struct cfs_rq *cfs_rq = &rq->cfs;
> + unsigned long util = root_cfs_util(rq);
> + bool capped = uclamp_rq_is_capped(rq);

I try to rerun your tests in your 2 ipynbs (cover letter) but this let's
the sum aggr stack go sideways ...

if 'sched_uclamp_used' then uclamp_rq_is_capped() will call
cpu_util_cfs()->cpu_util() which then calls uclamp_rq_is_capped()
recursively resulting in a stack overflow.

Do you have a fix for that you can share? For the time I remove the call
to uclamp_rq_is_capped() in cpu_util().

[...]