From: Yaxiong Tian Date: Fri, 12 Sep 2025 07:35:02 +0000 (+0800) Subject: cpufreq: intel_pstate: Use likely() optimization in intel_pstate_sample() X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=02d09026a88f227aa1f4687bd31d6ffc4970e8be;p=thirdparty%2Fkernel%2Fstable.git 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 Signed-off-by: Rafael J. Wysocki --- diff --git a/drivers/cpufreq/intel_pstate.c b/drivers/cpufreq/intel_pstate.c index 285051e4a5dd8..05e440a6aa4a2 100644 --- a/drivers/cpufreq/intel_pstate.c +++ b/drivers/cpufreq/intel_pstate.c @@ -2542,7 +2542,7 @@ static inline bool intel_pstate_sample(struct cpudata *cpu, u64 time) * that sample.time will always be reset before setting the utilization * update hook and make the caller skip the sample then. */ - if (cpu->last_sample_time) { + if (likely(cpu->last_sample_time)) { intel_pstate_calc_avg_perf(cpu); return true; }