History

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. ]

Vincent Guittot committed 2 years ago

Commit e37617c1 parent bfe8eb31 file · +5 −1Browse files

Unified · Split

kernel/sched/cpufreq_schedutil.c+5−1
@@ -133,7 +133,11 @@ unsigned long get_capacity_ref_freq(struct cpufreq_policy *policy) · 132 unmodified lines
133133 if (arch_scale_freq_invariant())
134134 return policy->cpuinfo.max_freq;
135135
136− return policy->cur;
136+ /*
137+ * Apply a 25% margin so that we select a higher frequency than
138+ * the current one before the CPU is fully busy:
139+ */
140+ return policy->cur + (policy->cur >> 2);
137141 }
138142
139143 /**

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t