Skip to content

Commit 30c63f7

Browse files
gautshensuperm1
authored andcommitted
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>
1 parent b9f103d commit 30c63f7

2 files changed

Lines changed: 46 additions & 3 deletions

File tree

drivers/cpufreq/amd-pstate-trace.h

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -133,6 +133,41 @@ TRACE_EVENT(amd_pstate_epp_perf,
133133
)
134134
);
135135

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+
136171
#endif /* _AMD_PSTATE_TRACE_H */
137172

138173
/* This part must be outside protection */

drivers/cpufreq/amd-pstate.c

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -333,6 +333,7 @@ static int amd_pstate_set_floor_perf(struct cpufreq_policy *policy, u8 perf)
333333
{
334334
struct amd_cpudata *cpudata = policy->driver_data;
335335
u64 value, prev;
336+
bool changed;
336337
int ret;
337338

338339
if (!cpu_feature_enabled(X86_FEATURE_CPPC_PERF_PRIO))
@@ -341,17 +342,24 @@ static int amd_pstate_set_floor_perf(struct cpufreq_policy *policy, u8 perf)
341342
value = prev = READ_ONCE(cpudata->cppc_req2_cached);
342343
FIELD_MODIFY(AMD_CPPC_FLOOR_PERF_MASK, &value, perf);
343344

344-
if (value == prev)
345-
return 0;
345+
changed = value != prev;
346+
if (!changed) {
347+
ret = 0;
348+
goto out_trace;
349+
}
346350

347351
ret = wrmsrq_on_cpu(cpudata->cpu, MSR_AMD_CPPC_REQ2, value);
348352
if (ret) {
353+
changed = false;
349354
pr_err("failed to set CPPC REQ2 value. Error (%d)\n", ret);
350-
return ret;
355+
goto out_trace;
351356
}
352357

353358
WRITE_ONCE(cpudata->cppc_req2_cached, value);
354359

360+
out_trace:
361+
if (trace_amd_pstate_cppc_req2_enabled())
362+
trace_amd_pstate_cppc_req2(cpudata->cpu, perf, changed, ret);
355363
return ret;
356364
}
357365

0 commit comments

Comments
 (0)