Skip to content

Commit

Permalink
cpufreq: amd: add trace for amd-pstate module
Browse files Browse the repository at this point in the history
Add trace event to monitor the performance value changes which is
controlled by cpu governors.

Signed-off-by: Huang Rui <ray.huang@amd.com>
  • Loading branch information
huangrui authored and xanmod committed Nov 4, 2021
1 parent a97ebea commit de13cc0
Show file tree
Hide file tree
Showing 2 changed files with 50 additions and 0 deletions.
4 changes: 4 additions & 0 deletions drivers/cpufreq/amd-pstate.c
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@
#include <linux/delay.h>
#include <linux/uaccess.h>
#include <linux/static_call.h>
#include <trace/events/power.h>

#include <acpi/processor.h>
#include <acpi/cppc_acpi.h>
Expand Down Expand Up @@ -189,6 +190,9 @@ static void amd_pstate_update(struct amd_cpudata *cpudata, u32 min_perf,
value &= ~REQ_MAX_PERF(~0L);
value |= REQ_MAX_PERF(max_perf);

trace_amd_pstate_perf(min_perf, des_perf, max_perf, cpudata->cpu,
(value != prev), fast_switch);

if (value == prev)
return;

Expand Down
46 changes: 46 additions & 0 deletions include/trace/events/power.h
Original file line number Diff line number Diff line change
Expand Up @@ -173,6 +173,52 @@ TRACE_EVENT(cpu_frequency_limits,
(unsigned long)__entry->cpu_id)
);

TRACE_EVENT(amd_pstate_perf,

TP_PROTO(unsigned long min_perf,
unsigned long target_perf,
unsigned long capacity,
unsigned int cpu_id,
bool changed,
bool fast_switch
),

TP_ARGS(min_perf,
target_perf,
capacity,
cpu_id,
changed,
fast_switch
),

TP_STRUCT__entry(
__field(unsigned long, min_perf)
__field(unsigned long, target_perf)
__field(unsigned long, capacity)
__field(unsigned int, cpu_id)
__field(bool, changed)
__field(bool, fast_switch)
),

TP_fast_assign(
__entry->min_perf = min_perf;
__entry->target_perf = target_perf;
__entry->capacity = capacity;
__entry->cpu_id = cpu_id;
__entry->changed = changed;
__entry->fast_switch = fast_switch;
),

TP_printk("amd_min_perf=%lu amd_des_perf=%lu amd_max_perf=%lu cpu_id=%u changed=%s fast_switch=%s",
(unsigned long)__entry->min_perf,
(unsigned long)__entry->target_perf,
(unsigned long)__entry->capacity,
(unsigned int)__entry->cpu_id,
(__entry->changed) ? "true" : "false",
(__entry->fast_switch) ? "true" : "false"
)
);

TRACE_EVENT(device_pm_callback_start,

TP_PROTO(struct device *dev, const char *pm_ops, int event),
Expand Down

0 comments on commit de13cc0

Please sign in to comment.