Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

amd-pstate: Introduce a tracepoint trace_amd_pstate_cppc_req2()

Introduce a new tracepoint trace_amd_pstate_cppc_req2() to track
updates to MSR_AMD_CPPC_REQ2.

Invoke this while changing the Floor Perf.

Reviewed-by: Mario Limonciello <mario.limonciello@amd.com>
Signed-off-by: Gautham R. Shenoy <gautham.shenoy@amd.com>
Signed-off-by: Mario Limonciello (AMD) <superm1@kernel.org>

authored by

Gautham R. Shenoy and committed by
Mario Limonciello (AMD)
30c63f72 b9f103d0

+46 -3
+35
drivers/cpufreq/amd-pstate-trace.h
··· 133 133 ) 134 134 ); 135 135 136 + TRACE_EVENT(amd_pstate_cppc_req2, 137 + 138 + TP_PROTO(unsigned int cpu_id, 139 + u8 floor_perf, 140 + bool changed, 141 + int err_code 142 + ), 143 + 144 + TP_ARGS(cpu_id, 145 + floor_perf, 146 + changed, 147 + err_code), 148 + 149 + TP_STRUCT__entry( 150 + __field(unsigned int, cpu_id) 151 + __field(u8, floor_perf) 152 + __field(bool, changed) 153 + __field(int, err_code) 154 + ), 155 + 156 + TP_fast_assign( 157 + __entry->cpu_id = cpu_id; 158 + __entry->floor_perf = floor_perf; 159 + __entry->changed = changed; 160 + __entry->err_code = err_code; 161 + ), 162 + 163 + TP_printk("cpu%u: floor_perf=%u, changed=%u (error = %d)", 164 + __entry->cpu_id, 165 + __entry->floor_perf, 166 + __entry->changed, 167 + __entry->err_code 168 + ) 169 + ); 170 + 136 171 #endif /* _AMD_PSTATE_TRACE_H */ 137 172 138 173 /* This part must be outside protection */
+11 -3
drivers/cpufreq/amd-pstate.c
··· 333 333 { 334 334 struct amd_cpudata *cpudata = policy->driver_data; 335 335 u64 value, prev; 336 + bool changed; 336 337 int ret; 337 338 338 339 if (!cpu_feature_enabled(X86_FEATURE_CPPC_PERF_PRIO)) ··· 342 341 value = prev = READ_ONCE(cpudata->cppc_req2_cached); 343 342 FIELD_MODIFY(AMD_CPPC_FLOOR_PERF_MASK, &value, perf); 344 343 345 - if (value == prev) 346 - return 0; 344 + changed = value != prev; 345 + if (!changed) { 346 + ret = 0; 347 + goto out_trace; 348 + } 347 349 348 350 ret = wrmsrq_on_cpu(cpudata->cpu, MSR_AMD_CPPC_REQ2, value); 349 351 if (ret) { 352 + changed = false; 350 353 pr_err("failed to set CPPC REQ2 value. Error (%d)\n", ret); 351 - return ret; 354 + goto out_trace; 352 355 } 353 356 354 357 WRITE_ONCE(cpudata->cppc_req2_cached, value); 355 358 359 + out_trace: 360 + if (trace_amd_pstate_cppc_req2_enabled()) 361 + trace_amd_pstate_cppc_req2(cpudata->cpu, perf, changed, ret); 356 362 return ret; 357 363 } 358 364