sched/fair: Fix frequency selection for non-invariant case
PATCH 1/1 sched/fair: Fix frequency selection for non-invariant case
Hi,
Please apply the commit e37617c8e53a1f7fcba6d5e1041f4fd8a2425c27,
it fix the REGRESSION by ada8d7fa0ad49a2a078f97f7f6e02d24d3c357a3 ("sched/cpufreq: Rework schedutil governor performance estimation") which introduced in v6.6.89.
Best Regards
Wentao Guan
gregkh
maintainerQuoted 5 lines · Wentao Guan
Hi,
Please apply the commit e37617c8e53a1f7fcba6d5e1041f4fd8a2425c27,it fix the REGRESSION by
ada8d7fa0ad49a2a078f97f7f6e02d24d3c357a3("sched/cpufreq: Rework schedutil governor performance estimation") which introduced in v6.6.89.
Please provide a working, and tested, backport of that commit and we will be glad to queue it up.
thanks,
greg k-h
Wentao Guan
Tested-by Wyes KarnyFrom ddd3f1ed6e88d88502d2b42e159ac976b4194b78 Mon Sep 17 00:00:00 2001
From: Vincent Guittot <[email protected]>
Date: Sun, 14 Jan 2024 19:36:00 +0100
Subject: [PATCH] sched/fair: Fix frequency selection for non-invariant case
Linus reported a ~50% performance regression on single-threaded workloads on his AMD Ryzen system, and bisected it to:
9c0b4bb7f630 ("sched/cpufreq: Rework schedutil governor performance estimation")
When frequency invariance is not enabled, get_capacity_ref_freq(policy) is supposed to return the current frequency and the performance margin applied by map_util_perf(), enabling the utilization to go above the maximum compute capacity and to select a higher frequency than the current one.
After the changes in 9c0b4bb7f630, the performance margin was applied earlier in the path to take into account utilization clampings and we couldn't get a utilization higher than the maximum compute capacity, and the CPU remained 'stuck' at lower frequencies.
To fix this, we must use a frequency above the current frequency to get a chance to select a higher OPP when the current one becomes fully used. Apply the same margin and return a frequency 25% higher than the current one in order to switch to the next OPP before we fully use the CPU at the current one.
[ mingo: Clarified the changelog. ]
---
I tested the patch two days ago, and the upstream commit can be directly apply.
---
--- kernel/sched/cpufreq_schedutil.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-)
kernel/sched/cpufreq_schedutil.c +5 -1
@@ -156,7 +156,11 @@ unsigned long get_capacity_ref_freq(struct cpufreq_policy *policy)if (arch_scale_freq_invariant ())return policy->cpuinfo.max_freq; -return policy->cur; +/* +* Apply a 25% margin so that we select a higher frequency than +* the current one before the CPU is fully busy: +*/ +return policy->cur + (policy->cur >>2 ); }/**
Greg KH
maintainerQuoted 52 lines · Wentao Guan
From
ddd3f1ed6e88d88502d2b42e159ac976b4194b78Mon Sep 17 00:00:00 2001
From: Vincent Guittot <[email protected]>
Date: Sun, 14 Jan 2024 19:36:00 +0100
Subject: [PATCH] sched/fair: Fix frequency selection for non-invariant caseLinus reported a ~50% performance regression on single-threaded workloads on his AMD Ryzen system, and bisected it to:
9c0b4bb7f630("sched/cpufreq: Rework schedutil governor performance estimation")When frequency invariance is not enabled,
get_capacity_ref_freq(policy)is supposed to return the current frequency and the performance margin applied bymap_util_perf(), enabling the utilization to go above the maximum compute capacity and to select a higher frequency than the current one.After the changes in
9c0b4bb7f630, the performance margin was applied earlier in the path to take into account utilization clampings and we couldn't get a utilization higher than the maximum compute capacity, and the CPU remained 'stuck' at lower frequencies.To fix this, we must use a frequency above the current frequency to get a chance to select a higher OPP when the current one becomes fully used. Apply the same margin and return a frequency 25% higher than the current one in order to switch to the next OPP before we fully use the CPU at the current one.
[ mingo: Clarified the changelog. ]
Fixes 9c0b4bb7f630 ("sched/cpufreq: Rework schedutil governor performance estimation")Reported-by Linus Torvalds <[email protected]>Bisected-by Linus Torvalds <[email protected]>Reported-by Wyes Karny <[email protected]>Signed-off-by Vincent Guittot <[email protected]>Signed-off-by Ingo Molnar <[email protected]>Tested-by Wyes Karny <[email protected]>(cherry picked from commit e37617c8e53a1f7fcba6d5e1041f4fd8a2425c27)Signed-off-by Wentao Guan <[email protected]>---
I tested the patch two days ago, and the upstream commit can be directly apply.
------ kernel/sched/cpufreq_schedutil.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-)kernel/sched/cpufreq_schedutil.c +0
-0@@ -156,7 +156,11 @@ unsigned long get_capacity_ref_freq(struct cpufreq_policy *policy)if (arch_scale_freq_invariant ())return policy->cpuinfo.max_freq;
kernel/sched/cpufreq_schedutil.c unsigned long get_capacity_ref_freq(struct cpufreq_policy *policy) · line 166
Quoted 10 lines
kernel/sched/cpufreq_schedutil.c +5
-1-return policy->cur; +/* +* Apply a 25% margin so that we select a higher frequency than +* the current one before the CPU is fully busy: +*/ +return policy->cur + (policy->cur >>2 ); }/**
Does not apply against the latest 6.6.y kernel release :(
thanks,
greg k-h
Dear Greg,
Oh, I miss the thing which first apply b3edde44e5d4504c23a176819865cd603fd16d6c
("cpufreq/schedutil: Use a fixed reference frequency"), then apply e37617c8e53a1f7fcba6d5e1041f4fd8a2425c27
("sched/fair: Fix frequency selection for non-invariant case").
sorry...
Best Regards
Wentao Guan.
Dear Greg,
Oops, I missed the whole things, it will build failed, i will send the full patches series later.
Best Regards
Wentao Guan