# \[PATCH 0/4\] PM: tracing: Don't compile in unused trace events

- Subsystems: CPU FREQUENCY SCALING FRAMEWORK, THE REST, TRACING
- Maintainers: "Rafael J. Wysocki", Viresh Kumar, Linus Torvalds, Steven Rostedt, Masami Hiramatsu
- Series: 4 patches touching 5 files, +54/-24
- Status: LANDED
- Landed in mainline.
- List: linuxppc-dev
- 7 messages, 3 authors
- Page: https://ratatoskr.run/linuxppc-dev/2025/06/3089513/t

## \[PATCH 0/4\] PM: tracing: Don't compile in unused trace events

- From: Steven Rostedt \<rostedt@goodmis.org\>
- Date: 2025-06-12 14:52:36 
- Message: https://ratatoskr.run/linuxppc-dev/2025/06/3089513.md

```text

I have code that makes unsued events trigger a warning. I'm currently cleaning
up the kernel to remove the majority of events that are defined but not used.
When an event is defined, it can take up to 5K of text and meta data per
event. An event should not be created if it is not being used.

The powernv_throttle event is only used by the powernv code so I moved it to
its own header file and it gets created when the powernv code is compiled in.

For the other power events, I just added #ifdef around them with the configs
that enable them.

Steven Rostedt (4):
      PM: cpufreq: powernv/tracing: Move powernv_throttle trace event
      PM: tracing: Hide psci_domain_idle events under ARM_PSCI_CPUIDLE
      PM: tracing: Hide device_pm_callback events under PM_SLEEP
      PM: tracing: Hide power_domain_target event under ARCH_OMAP2PLUS

----
 drivers/cpufreq/Makefile          |  1 +
 drivers/cpufreq/powernv-cpufreq.c |  4 +++-
 drivers/cpufreq/powernv-trace.h   | 44 +++++++++++++++++++++++++++++++++++++++
 include/trace/events/power.h      | 28 ++++++-------------------
 kernel/trace/power-traces.c       |  1 -
 5 files changed, 54 insertions(+), 24 deletions(-)
 create mode 100644 drivers/cpufreq/powernv-trace.h

```

## \[PATCH 2/4\] PM: tracing: Hide psci\_domain\_idle events under ARM\_PSCI\_CPUIDLE

- From: Steven Rostedt \<rostedt@goodmis.org\>
- Date: 2025-06-12 14:52:36 
- Message: https://ratatoskr.run/linuxppc-dev/2025/06/3089514.md

```text
From: Steven Rostedt <rostedt@goodmis.org>

The events psci_domain_idle_enter and psci_domain_idle_exit events are
only called when CONFIG_ARM_PSCI_CPUIDLE is defined. As each event can
take up to 5K (less for DEFINE_EVENT()) regardless if they are used or
not, it's best not to define them when they are not used. Add #ifdef
around these events when they are not used.

Signed-off-by: Steven Rostedt (Google) <rostedt@goodmis.org>
---
 include/trace/events/power.h | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/include/trace/events/power.h b/include/trace/events/power.h
index 913181cebfe9..a10ad300d660 100644
--- a/include/trace/events/power.h
+++ b/include/trace/events/power.h
@@ -62,6 +62,7 @@ TRACE_EVENT(cpu_idle_miss,
 		(unsigned long)__entry->state, (__entry->below)?"below":"above")
 );
 
+#ifdef CONFIG_ARM_PSCI_CPUIDLE
 DECLARE_EVENT_CLASS(psci_domain_idle,
 
 	TP_PROTO(unsigned int cpu_id, unsigned int state, bool s2idle),
@@ -98,6 +99,7 @@ DEFINE_EVENT(psci_domain_idle, psci_domain_idle_exit,
 
 	TP_ARGS(cpu_id, state, s2idle)
 );
+#endif
 
 TRACE_EVENT(pstate_sample,
 
-- 
2.47.2



```

## \[PATCH 3/4\] PM: tracing: Hide device\_pm\_callback events under PM\_SLEEP

- From: Steven Rostedt \<rostedt@goodmis.org\>
- Date: 2025-06-12 14:52:36 
- Message: https://ratatoskr.run/linuxppc-dev/2025/06/3089515.md

```text
From: Steven Rostedt <rostedt@goodmis.org>

The events device_pm_callback_start and device_pm_callback_end events are
only called when CONFIG_PM_SLEEP is defined. As each event can take up to
5K regardless if they are used or not, it's best not to define them when
they are not used. Add #ifdef around these events when they are not used.

Signed-off-by: Steven Rostedt (Google) <rostedt@goodmis.org>
---
 include/trace/events/power.h | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/include/trace/events/power.h b/include/trace/events/power.h
index a10ad300d660..5b1df5e1e092 100644
--- a/include/trace/events/power.h
+++ b/include/trace/events/power.h
@@ -212,6 +212,7 @@ TRACE_EVENT(cpu_frequency_limits,
 		  (unsigned long)__entry->cpu_id)
 );
 
+#ifdef CONFIG_PM_SLEEP
 TRACE_EVENT(device_pm_callback_start,
 
 	TP_PROTO(struct device *dev, const char *pm_ops, int event),
@@ -260,6 +261,7 @@ TRACE_EVENT(device_pm_callback_end,
 	TP_printk("%s %s, err=%d",
 		__get_str(driver), __get_str(device), __entry->error)
 );
+#endif
 
 TRACE_EVENT(suspend_resume,
 
-- 
2.47.2



```

## \[PATCH 1/4\] PM: cpufreq: powernv/tracing: Move powernv\_throttle trace event

- From: Steven Rostedt \<rostedt@goodmis.org\>
- Date: 2025-06-12 14:52:41 
- Message: https://ratatoskr.run/linuxppc-dev/2025/06/3089516.md

```text
From: Steven Rostedt <rostedt@goodmis.org>

As the trace event powernv_throttle is only used by the powernv code, move
it to a separate include file and have that code directly enable it.

Trace events can take up around 5K of memory when they are defined
regardless if they are used or not. It wastes memory to have them defined
in configurations where the tracepoint is not used.

Fixes: 0306e481d479a ("cpufreq: powernv/tracing: Add powernv_throttle tracepoint")
Signed-off-by: Steven Rostedt (Google) <rostedt@goodmis.org>
---
 drivers/cpufreq/Makefile          |  1 +
 drivers/cpufreq/powernv-cpufreq.c |  4 ++-
 drivers/cpufreq/powernv-trace.h   | 44 +++++++++++++++++++++++++++++++
 include/trace/events/power.h      | 22 ----------------
 kernel/trace/power-traces.c       |  1 -
 5 files changed, 48 insertions(+), 24 deletions(-)
 create mode 100644 drivers/cpufreq/powernv-trace.h

diff --git a/drivers/cpufreq/Makefile b/drivers/cpufreq/Makefile
index d38526b8e063..681d687b5a18 100644
--- a/drivers/cpufreq/Makefile
+++ b/drivers/cpufreq/Makefile
@@ -21,6 +21,7 @@ obj-$(CONFIG_CPUFREQ_VIRT)		+= virtual-cpufreq.o
 
 # Traces
 CFLAGS_amd-pstate-trace.o               := -I$(src)
+CFLAGS_powernv-cpufreq.o                := -I$(src)
 amd_pstate-y				:= amd-pstate.o amd-pstate-trace.o
 
 ##################################################################################
diff --git a/drivers/cpufreq/powernv-cpufreq.c b/drivers/cpufreq/powernv-cpufreq.c
index a8943e2a93be..7d9a5f656de8 100644
--- a/drivers/cpufreq/powernv-cpufreq.c
+++ b/drivers/cpufreq/powernv-cpufreq.c
@@ -21,7 +21,6 @@
 #include <linux/string_choices.h>
 #include <linux/cpu.h>
 #include <linux/hashtable.h>
-#include <trace/events/power.h>
 
 #include <asm/cputhreads.h>
 #include <asm/firmware.h>
@@ -30,6 +29,9 @@
 #include <asm/opal.h>
 #include <linux/timer.h>
 
+#define CREATE_TRACE_POINTS
+#include "powernv-trace.h"
+
 #define POWERNV_MAX_PSTATES_ORDER  8
 #define POWERNV_MAX_PSTATES	(1UL << (POWERNV_MAX_PSTATES_ORDER))
 #define PMSR_PSAFE_ENABLE	(1UL << 30)
diff --git a/drivers/cpufreq/powernv-trace.h b/drivers/cpufreq/powernv-trace.h
new file mode 100644
index 000000000000..8cadb7c9427b
--- /dev/null
+++ b/drivers/cpufreq/powernv-trace.h
@@ -0,0 +1,44 @@
+/* SPDX-License-Identifier: GPL-2.0 */
+
+#if !defined(_POWERNV_TRACE_H) || defined(TRACE_HEADER_MULTI_READ)
+#define _POWERNV_TRACE_H
+
+#include <linux/cpufreq.h>
+#include <linux/tracepoint.h>
+#include <linux/trace_events.h>
+
+#undef TRACE_SYSTEM
+#define TRACE_SYSTEM power
+
+TRACE_EVENT(powernv_throttle,
+
+	TP_PROTO(int chip_id, const char *reason, int pmax),
+
+	TP_ARGS(chip_id, reason, pmax),
+
+	TP_STRUCT__entry(
+		__field(int, chip_id)
+		__string(reason, reason)
+		__field(int, pmax)
+	),
+
+	TP_fast_assign(
+		__entry->chip_id = chip_id;
+		__assign_str(reason);
+		__entry->pmax = pmax;
+	),
+
+	TP_printk("Chip %d Pmax %d %s", __entry->chip_id,
+		  __entry->pmax, __get_str(reason))
+);
+
+#endif /* _POWERNV_TRACE_H */
+
+/* This part must be outside protection */
+#undef TRACE_INCLUDE_PATH
+#define TRACE_INCLUDE_PATH .
+
+#undef TRACE_INCLUDE_FILE
+#define TRACE_INCLUDE_FILE powernv-trace
+
+#include <trace/define_trace.h>
diff --git a/include/trace/events/power.h b/include/trace/events/power.h
index 6c631eec23e3..913181cebfe9 100644
--- a/include/trace/events/power.h
+++ b/include/trace/events/power.h
@@ -99,28 +99,6 @@ DEFINE_EVENT(psci_domain_idle, psci_domain_idle_exit,
 	TP_ARGS(cpu_id, state, s2idle)
 );
 
-TRACE_EVENT(powernv_throttle,
-
-	TP_PROTO(int chip_id, const char *reason, int pmax),
-
-	TP_ARGS(chip_id, reason, pmax),
-
-	TP_STRUCT__entry(
-		__field(int, chip_id)
-		__string(reason, reason)
-		__field(int, pmax)
-	),
-
-	TP_fast_assign(
-		__entry->chip_id = chip_id;
-		__assign_str(reason);
-		__entry->pmax = pmax;
-	),
-
-	TP_printk("Chip %d Pmax %d %s", __entry->chip_id,
-		  __entry->pmax, __get_str(reason))
-);
-
 TRACE_EVENT(pstate_sample,
 
 	TP_PROTO(u32 core_busy,
diff --git a/kernel/trace/power-traces.c b/kernel/trace/power-traces.c
index 21bb161c2316..f2fe33573e54 100644
--- a/kernel/trace/power-traces.c
+++ b/kernel/trace/power-traces.c
@@ -17,5 +17,4 @@
 EXPORT_TRACEPOINT_SYMBOL_GPL(suspend_resume);
 EXPORT_TRACEPOINT_SYMBOL_GPL(cpu_idle);
 EXPORT_TRACEPOINT_SYMBOL_GPL(cpu_frequency);
-EXPORT_TRACEPOINT_SYMBOL_GPL(powernv_throttle);
 
-- 
2.47.2



```

## \[PATCH 4/4\] PM: tracing: Hide power\_domain\_target event under ARCH\_OMAP2PLUS

- From: Steven Rostedt \<rostedt@goodmis.org\>
- Date: 2025-06-12 14:53:03 
- Message: https://ratatoskr.run/linuxppc-dev/2025/06/3089518.md

```text
From: Steven Rostedt <rostedt@goodmis.org>

The power_domain_target event event is only called when CONFIG_OMAP2PLUS
is defined. As each event can take up to 5K regardless if they are used or
not, it's best not to define them when they are not used. Add #ifdef
around these events when they are not used.

Signed-off-by: Steven Rostedt (Google) <rostedt@goodmis.org>
---
 include/trace/events/power.h | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/include/trace/events/power.h b/include/trace/events/power.h
index 5b1df5e1e092..82904291c2b8 100644
--- a/include/trace/events/power.h
+++ b/include/trace/events/power.h
@@ -319,6 +319,7 @@ DEFINE_EVENT(wakeup_source, wakeup_source_deactivate,
 	TP_ARGS(name, state)
 );
 
+#ifdef CONFIG_ARCH_OMAP2PLUS
 /*
  * The power domain events are used for power domains transitions
  */
@@ -350,6 +351,7 @@ DEFINE_EVENT(power_domain, power_domain_target,
 
 	TP_ARGS(name, state, cpu_id)
 );
+#endif
 
 /*
  * CPU latency QoS events used for global CPU latency QoS list updates
-- 
2.47.2



```

## Re: \[PATCH 0/4\] PM: tracing: Don't compile in unused trace events

- From: Rafael J. Wysocki \<rafael@kernel.org\>
- Date: 2025-06-12 18:47:01 
- Message: https://ratatoskr.run/linuxppc-dev/2025/06/3089895.md

```text
On Thu, Jun 12, 2025 at 4:52 PM Steven Rostedt [ref] wrote:
>
>
> I have code that makes unsued events trigger a warning. I'm currently cleaning
> up the kernel to remove the majority of events that are defined but not used.
> When an event is defined, it can take up to 5K of text and meta data per
> event. An event should not be created if it is not being used.
>
> The powernv_throttle event is only used by the powernv code so I moved it to
> its own header file and it gets created when the powernv code is compiled in.
>
> For the other power events, I just added #ifdef around them with the configs
> that enable them.
>
> Steven Rostedt (4):
>       PM: cpufreq: powernv/tracing: Move powernv_throttle trace event
>       PM: tracing: Hide psci_domain_idle events under ARM_PSCI_CPUIDLE
>       PM: tracing: Hide device_pm_callback events under PM_SLEEP
>       PM: tracing: Hide power_domain_target event under ARCH_OMAP2PLUS
>
> ----
>  drivers/cpufreq/Makefile          |  1 +
>  drivers/cpufreq/powernv-cpufreq.c |  4 +++-
>  drivers/cpufreq/powernv-trace.h   | 44 +++++++++++++++++++++++++++++++++++++++
>  include/trace/events/power.h      | 28 ++++++-------------------
>  kernel/trace/power-traces.c       |  1 -
>  5 files changed, 54 insertions(+), 24 deletions(-)
>  create mode 100644 drivers/cpufreq/powernv-trace.h

For the series:

Acked-by: Rafael J. Wysocki <rafael@kernel.org>

Thanks!

```

## Re: \[PATCH 1/4\] PM: cpufreq: powernv/tracing: Move powernv\_throttle trace event

- From: Viresh Kumar \<viresh.kumar@linaro.org\>
- Date: 2025-06-13 03:16:52 
- Message: https://ratatoskr.run/linuxppc-dev/2025/06/3090381.md

```text
On 12-06-25, 10:53, Steven Rostedt wrote:
> From: Steven Rostedt <rostedt@goodmis.org>
> 
> As the trace event powernv_throttle is only used by the powernv code, move
> it to a separate include file and have that code directly enable it.
> 
> Trace events can take up around 5K of memory when they are defined
> regardless if they are used or not. It wastes memory to have them defined
> in configurations where the tracepoint is not used.
> 
> Fixes: 0306e481d479a ("cpufreq: powernv/tracing: Add powernv_throttle tracepoint")
> Signed-off-by: Steven Rostedt (Google) <rostedt@goodmis.org>
> ---
>  drivers/cpufreq/Makefile          |  1 +
>  drivers/cpufreq/powernv-cpufreq.c |  4 ++-
>  drivers/cpufreq/powernv-trace.h   | 44 +++++++++++++++++++++++++++++++
>  include/trace/events/power.h      | 22 ----------------
>  kernel/trace/power-traces.c       |  1 -
>  5 files changed, 48 insertions(+), 24 deletions(-)
>  create mode 100644 drivers/cpufreq/powernv-trace.h

Acked-by: Viresh Kumar <viresh.kumar@linaro.org>

-- 
viresh

```
