Skip to content

Commit 4dcd130

Browse files
committed
cpufreq/amd-pstate: Add trace event for EPP perf updates
In "active" mode the most important thing for debugging whether an issue is hardware or software based is to look at what was the last thing written to the CPPC request MSR or shared memory region. The 'amd_pstate_epp_perf' trace event shows the values being written for all CPUs. Reviewed-by: Perry Yuan <perry.yuan@amd.com> Reviewed-by: Gautham R. Shenoy <gautham.shenoy@amd.com> Link: https://lore.kernel.org/r/20241209185248.16301-4-mario.limonciello@amd.com Signed-off-by: Mario Limonciello <mario.limonciello@amd.com>
1 parent 53ec210 commit 4dcd130

File tree

2 files changed

+73
-0
lines changed

2 files changed

+73
-0
lines changed

drivers/cpufreq/amd-pstate-trace.h

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,51 @@ TRACE_EVENT(amd_pstate_perf,
8888
)
8989
);
9090

91+
TRACE_EVENT(amd_pstate_epp_perf,
92+
93+
TP_PROTO(unsigned int cpu_id,
94+
unsigned int highest_perf,
95+
unsigned int epp,
96+
unsigned int min_perf,
97+
unsigned int max_perf,
98+
bool boost
99+
),
100+
101+
TP_ARGS(cpu_id,
102+
highest_perf,
103+
epp,
104+
min_perf,
105+
max_perf,
106+
boost),
107+
108+
TP_STRUCT__entry(
109+
__field(unsigned int, cpu_id)
110+
__field(unsigned int, highest_perf)
111+
__field(unsigned int, epp)
112+
__field(unsigned int, min_perf)
113+
__field(unsigned int, max_perf)
114+
__field(bool, boost)
115+
),
116+
117+
TP_fast_assign(
118+
__entry->cpu_id = cpu_id;
119+
__entry->highest_perf = highest_perf;
120+
__entry->epp = epp;
121+
__entry->min_perf = min_perf;
122+
__entry->max_perf = max_perf;
123+
__entry->boost = boost;
124+
),
125+
126+
TP_printk("cpu%u: [%u<->%u]/%u, epp=%u, boost=%u",
127+
(unsigned int)__entry->cpu_id,
128+
(unsigned int)__entry->min_perf,
129+
(unsigned int)__entry->max_perf,
130+
(unsigned int)__entry->highest_perf,
131+
(unsigned int)__entry->epp,
132+
(bool)__entry->boost
133+
)
134+
);
135+
91136
#endif /* _AMD_PSTATE_TRACE_H */
92137

93138
/* This part must be outside protection */

drivers/cpufreq/amd-pstate.c

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -324,6 +324,14 @@ static int amd_pstate_set_energy_pref_index(struct amd_cpudata *cpudata,
324324
return -EBUSY;
325325
}
326326

327+
if (trace_amd_pstate_epp_perf_enabled()) {
328+
trace_amd_pstate_epp_perf(cpudata->cpu, cpudata->highest_perf,
329+
epp,
330+
AMD_CPPC_MIN_PERF(cpudata->cppc_req_cached),
331+
AMD_CPPC_MAX_PERF(cpudata->cppc_req_cached),
332+
cpudata->boost_state);
333+
}
334+
327335
ret = amd_pstate_set_epp(cpudata, epp);
328336

329337
return ret;
@@ -1598,6 +1606,13 @@ static int amd_pstate_epp_update_limit(struct cpufreq_policy *policy)
15981606

15991607
WRITE_ONCE(cpudata->cppc_req_cached, value);
16001608

1609+
if (trace_amd_pstate_epp_perf_enabled()) {
1610+
trace_amd_pstate_epp_perf(cpudata->cpu, cpudata->highest_perf, epp,
1611+
cpudata->min_limit_perf,
1612+
cpudata->max_limit_perf,
1613+
policy->boost_enabled);
1614+
}
1615+
16011616
amd_pstate_update_perf(cpudata, cpudata->min_limit_perf, 0U,
16021617
cpudata->max_limit_perf, false);
16031618

@@ -1641,6 +1656,13 @@ static void amd_pstate_epp_reenable(struct amd_cpudata *cpudata)
16411656

16421657
max_perf = READ_ONCE(cpudata->highest_perf);
16431658

1659+
if (trace_amd_pstate_epp_perf_enabled()) {
1660+
trace_amd_pstate_epp_perf(cpudata->cpu, cpudata->highest_perf,
1661+
cpudata->epp_cached,
1662+
AMD_CPPC_MIN_PERF(cpudata->cppc_req_cached),
1663+
max_perf, cpudata->boost_state);
1664+
}
1665+
16441666
amd_pstate_update_perf(cpudata, 0, 0, max_perf, false);
16451667
amd_pstate_set_epp(cpudata, cpudata->epp_cached);
16461668
}
@@ -1669,6 +1691,12 @@ static int amd_pstate_epp_cpu_offline(struct cpufreq_policy *policy)
16691691

16701692
mutex_lock(&amd_pstate_limits_lock);
16711693

1694+
if (trace_amd_pstate_epp_perf_enabled()) {
1695+
trace_amd_pstate_epp_perf(cpudata->cpu, cpudata->highest_perf,
1696+
AMD_CPPC_EPP_BALANCE_POWERSAVE,
1697+
min_perf, min_perf, policy->boost_enabled);
1698+
}
1699+
16721700
amd_pstate_update_perf(cpudata, min_perf, 0, min_perf, false);
16731701
amd_pstate_set_epp(cpudata, AMD_CPPC_EPP_BALANCE_POWERSAVE);
16741702

0 commit comments

Comments
 (0)