]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
cpuidle: psci: Add trace for PSCI domain idle
authorKeita Morisaki <keyz@google.com>
Mon, 10 Feb 2025 05:58:28 +0000 (13:58 +0800)
committerUlf Hansson <ulf.hansson@linaro.org>
Mon, 17 Feb 2025 13:41:56 +0000 (14:41 +0100)
The trace event cpu_idle provides insufficient information for debugging
PSCI requests due to lacking access to determined PSCI domain idle
states. The cpu_idle usually only shows -1, 0, or 1 regardless how many
idle states the power domain has.

Add new trace events namely psci_domain_idle_enter and
psci_domain_idle_exit to trace enter and exit events with a determined
idle state.

These new trace events will help developers debug CPUidle issues on ARM
systems using PSCI by providing more detailed information about the
requested idle states.

Signed-off-by: Keita Morisaki <keyz@google.com>
Reviewed-by: Steven Rostedt (Google) <rostedt@goodmis.org>
Reviewed-by: Dhruva Gole <d-gole@ti.com>
Tested-by: Kevin Hilman <khilman@baylibre.com>
Acked-by: Sudeep Holla <sudeep.holla@arm.com>
Link: https://lore.kernel.org/r/20250210055828.1875372-1-keyz@google.com
Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>
drivers/cpuidle/cpuidle-psci.c
include/trace/events/power.h

index 2562dc001fc1de69732ef28f383d2809262a3d96..dd8d776d6e396b8e2de4532febf28c37ecb5f5e1 100644 (file)
@@ -25,6 +25,7 @@
 #include <linux/syscore_ops.h>
 
 #include <asm/cpuidle.h>
+#include <trace/events/power.h>
 
 #include "cpuidle-psci.h"
 #include "dt_idle_states.h"
@@ -74,7 +75,9 @@ static __cpuidle int __psci_enter_domain_idle_state(struct cpuidle_device *dev,
        if (!state)
                state = states[idx];
 
+       trace_psci_domain_idle_enter(dev->cpu, state, s2idle);
        ret = psci_cpu_suspend_enter(state) ? -1 : idx;
+       trace_psci_domain_idle_exit(dev->cpu, state, s2idle);
 
        if (s2idle)
                dev_pm_genpd_resume(pd_dev);
index d2349b6b531ac9570ee64059c3047668ba9b1db6..9253e83b9bb43319395e08121972b523bbe44799 100644 (file)
@@ -62,6 +62,43 @@ TRACE_EVENT(cpu_idle_miss,
                (unsigned long)__entry->state, (__entry->below)?"below":"above")
 );
 
+DECLARE_EVENT_CLASS(psci_domain_idle,
+
+       TP_PROTO(unsigned int cpu_id, unsigned int state, bool s2idle),
+
+       TP_ARGS(cpu_id, state, s2idle),
+
+       TP_STRUCT__entry(
+               __field(u32,            cpu_id)
+               __field(u32,            state)
+               __field(bool,           s2idle)
+       ),
+
+       TP_fast_assign(
+               __entry->cpu_id = cpu_id;
+               __entry->state = state;
+               __entry->s2idle = s2idle;
+       ),
+
+       TP_printk("cpu_id=%lu state=0x%lx is_s2idle=%s",
+                 (unsigned long)__entry->cpu_id, (unsigned long)__entry->state,
+                 (__entry->s2idle)?"yes":"no")
+);
+
+DEFINE_EVENT(psci_domain_idle, psci_domain_idle_enter,
+
+       TP_PROTO(unsigned int cpu_id, unsigned int state, bool s2idle),
+
+       TP_ARGS(cpu_id, state, s2idle)
+);
+
+DEFINE_EVENT(psci_domain_idle, psci_domain_idle_exit,
+
+       TP_PROTO(unsigned int cpu_id, unsigned int state, bool s2idle),
+
+       TP_ARGS(cpu_id, state, s2idle)
+);
+
 TRACE_EVENT(powernv_throttle,
 
        TP_PROTO(int chip_id, const char *reason, int pmax),