Skip to content

Commit 02d0902

Browse files
Yaxiong Tianrafaeljw
authored andcommitted
cpufreq: intel_pstate: Use likely() optimization in intel_pstate_sample()
The comment above the condition `if (cpu->last_sample_time)` clearly indicates that the branch is taken for the vast majority of invocations after the first sample in a cycle. The first sample is a one-time initialization case. Add likely() hint to the condition to improve branch prediction for this performance-critical path in intel_pstate_sample(). Signed-off-by: Yaxiong Tian <[email protected]> Signed-off-by: Rafael J. Wysocki <[email protected]>
1 parent 7c0dde8 commit 02d0902

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

drivers/cpufreq/intel_pstate.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2542,7 +2542,7 @@ static inline bool intel_pstate_sample(struct cpudata *cpu, u64 time)
25422542
* that sample.time will always be reset before setting the utilization
25432543
* update hook and make the caller skip the sample then.
25442544
*/
2545-
if (cpu->last_sample_time) {
2545+
if (likely(cpu->last_sample_time)) {
25462546
intel_pstate_calc_avg_perf(cpu);
25472547
return true;
25482548
}

0 commit comments

Comments
 (0)