diff mbox series

cpuidle: Add find_deepest_state trace event

Message ID 20250519082811.92279-1-qiwu.chen@transsion.com
State New
Headers show
Series cpuidle: Add find_deepest_state trace event | expand

Commit Message

qiwu.chen May 19, 2025, 8:28 a.m. UTC
Add a new trace event namely cpuidle_find_deepest_state to trace
the found deepest idle state during CPUidle flow.

The new trace event will help developers debug CPUidle issues by
providing more detailed information about the CPUidle states.

Signed-off-by: qiwu.chen <qiwu.chen@transsion.com>
---
 drivers/cpuidle/cpuidle.c    |  2 ++
 include/trace/events/power.h | 24 ++++++++++++++++++++++++
 2 files changed, 26 insertions(+)
diff mbox series

Patch

diff --git a/drivers/cpuidle/cpuidle.c b/drivers/cpuidle/cpuidle.c
index 0835da449db8..9065aa396892 100644
--- a/drivers/cpuidle/cpuidle.c
+++ b/drivers/cpuidle/cpuidle.c
@@ -103,6 +103,8 @@  static int find_deepest_state(struct cpuidle_driver *drv,
 		latency_req = s->exit_latency_ns;
 		ret = i;
 	}
+	trace_cpuidle_find_deepest_state(dev->cpu, s2idle, ret);
+
 	return ret;
 }
 
diff --git a/include/trace/events/power.h b/include/trace/events/power.h
index 9253e83b9bb4..82b5ac8c46e6 100644
--- a/include/trace/events/power.h
+++ b/include/trace/events/power.h
@@ -62,6 +62,30 @@  TRACE_EVENT(cpu_idle_miss,
 		(unsigned long)__entry->state, (__entry->below)?"below":"above")
 );
 
+TRACE_EVENT(cpuidle_find_deepest_state,
+
+	TP_PROTO(unsigned int cpu_id, bool s2idle, unsigned int deepest_state),
+
+	TP_ARGS(cpu_id, s2idle, deepest_state),
+
+	TP_STRUCT__entry(
+		__field(u32,            cpu_id)
+		__field(bool,           s2idle)
+		__field(u32,            deepest_state)
+	),
+
+	TP_fast_assign(
+		__entry->cpu_id = cpu_id;
+		__entry->s2idle = s2idle;
+		__entry->deepest_state = deepest_state;
+	),
+
+	TP_printk("cpu_id=%lu is_s2idle=%s deepest_state=%lu",
+		 (unsigned long)__entry->cpu_id,
+		 (__entry->s2idle)?"yes":"no",
+		 (unsigned long)__entry->deepest_state)
+);
+
 DECLARE_EVENT_CLASS(psci_domain_idle,
 
 	TP_PROTO(unsigned int cpu_id, unsigned int state, bool s2idle),