cpufreq: schedutil: Skip busy-CPU hold when NOHZ is disabled
Subsystems (2)
PATCH 1/1 cpufreq: schedutil: Skip busy-CPU hold when NOHZ is disabled
With nohz=off, tick_nohz_idle_stop_tick() can return without incrementing idle_calls. sugov_hold_freq() then treats an unchanged counter as continuous CPU activity and can prevent frequency reductions even after the CPU has been idle.
Skip the busy-CPU hold heuristic when NOHZ is disabled.
--- kernel/sched/cpufreq_schedutil.c | 3 +++ 1 file changed, 3 insertions(+)
kernel/sched/cpufreq_schedutil.c +3 -0
@@ -397,6 +397,9 @@ static bool sugov_hold_freq(struct sugov_cpu *sg_cpu)if (uclamp_rq_is_capped (cpu_rq (sg_cpu->cpu)))return false; +if (!tick_nohz_enabled) +return false; +/* * Maintain the frequency if the CPU has not been idle recently, as * reduction is likely to be premature.
base-commit: 6628e7d4c6b25c8d18f1345e3a20d21829aae7e4
Signature · 1 line
2.53.0
Hi Avi,
kernel/sched/cpufreq_schedutil.c static bool sugov_hold_freq(struct sugov_cpu *sg_cpu) · line 401
Quoted 2 lines · Avi Weiss
kernel/sched/cpufreq_schedutil.c +2
-0+if (!tick_nohz_enabled) +return false;
idle_calls also never moves when nohz is enabled but was never activated, because tick_check_oneshot_change() found no oneshot clock event device or no clocksource valid for high resolution. TS_FLAG_NOHZ then stays clear, as with nohz=off. tick_nohz_is_active() covers both:
if (!tick_nohz_is_active()) return false;
Thanks,
Zhan Xusheng
Quoted 11 lines · Zhan Xusheng
Hi Avi,
kernel/sched/cpufreq_schedutil.c static bool sugov_hold_freq(struct sugov_cpu *sg_cpu) · line 401
Quoted 2 lines · Avi Weiss
kernel/sched/cpufreq_schedutil.c +2
-0+if (!tick_nohz_enabled) +return false;
idle_callsalso never moves when nohz is enabled but was never activated, becausetick_check_oneshot_change()found no oneshot clock event device or no clocksource valid for high resolution.TS_FLAG_NOHZthen stays clear, as with nohz=off.tick_nohz_is_active()covers both:
Quoted 2 lines
if (!tick_nohz_is_active()) return false;
Agree with Xusheng, tick_nohz_is_active() is one more reasonable check, it also covers NOHZ never getting activated. Besides please Cc: stable, and Cc the scheduler maintainers (scripts/get_maintainer.pl).
Note that this still leaves the nohz_full timekeeping CPU and idle=poll, where NOHZ is active but idle_calls never moves either. That's a deeper issue with using a tick-stop counter as an "idle recently" signal and it may be addressed separately.
Quoted 4 lines
Thanks,
Zhan Xusheng
Signature · 2 lines
Thx and BRs, Zhongqiu Han