Skip to contentSkip to conversation

PM: tracing: Don't compile in unused trace events

PATCH In review Steven Rostedt 3 participants 7 messages Jun 12, 2025 – Jun 13, 2025

Subsystems (3)
lore
Share & tools
lore

Steven Rostedt

author maintainer
#0 lore raw

cover PM: tracing: Don't compile in unused trace events

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
author maintainer
#1 lore raw

PATCH 1/4 PM: cpufreq: powernv/tracing: Move powernv_throttle trace event

From: Steven Rostedt <[email protected]>

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")
---
 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
drivers/cpufreq/Makefile +1 -0
index d38526b8e063..681d687b5a18 100644
@@ -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
 
 ##################################################################################
drivers/cpufreq/powernv-cpufreq.c +3 -1
index a8943e2a93be..7d9a5f656de8 100644
@@ -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)
drivers/cpufreq/powernv-trace.h new file +44 -0

44 lines not on this page · raw message

include/trace/events/power.h +0 -22
index 6c631eec23e3..913181cebfe9 100644
@@ -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,
kernel/trace/power-traces.c +0 -1
index 21bb161c2316..f2fe33573e54 100644
@@ -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);
 
Signature · 1 line
2.47.2
maintainer Acked-by on v1 1/4
#2 lore raw

Re: [PATCH 1/4] PM: cpufreq: powernv/tracing: Move powernv_throttle trace event

Quoted 11 lines · Steven Rostedt

From: Steven Rostedt <[email protected]>

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")
Quoted 8 lines
---
 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
Signature · 1 line
viresh
author maintainer
#3 lore raw

PATCH 2/4 PM: tracing: Hide psci_domain_idle events under ARM_PSCI_CPUIDLE

In reply to Steven Rostedt

From: Steven Rostedt <[email protected]>

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.

---
 include/trace/events/power.h | 2 ++
 1 file changed, 2 insertions(+)
include/trace/events/power.h +2 -0
index 913181cebfe9..a10ad300d660 100644
@@ -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,
 
Signature · 1 line
2.47.2
author maintainer
#4 lore raw

PATCH 3/4 PM: tracing: Hide device_pm_callback events under PM_SLEEP

In reply to Steven Rostedt

From: Steven Rostedt <[email protected]>

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.

---
 include/trace/events/power.h | 2 ++
 1 file changed, 2 insertions(+)
include/trace/events/power.h +2 -0
index a10ad300d660..5b1df5e1e092 100644
@@ -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,
 
Signature · 1 line
2.47.2
author maintainer
#5 lore raw

PATCH 4/4 PM: tracing: Hide power_domain_target event under ARCH_OMAP2PLUS

In reply to Steven Rostedt

From: Steven Rostedt <[email protected]>

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.

---
 include/trace/events/power.h | 2 ++
 1 file changed, 2 insertions(+)
include/trace/events/power.h +2 -0
index 5b1df5e1e092..82904291c2b8 100644
@@ -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
Signature · 1 line
2.47.2
maintainer Acked-by on the v1 series
#6 lore raw
In reply to Steven Rostedt
Quoted 19 lines · Steven Rostedt

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

Quoted 8 lines

----

 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:

Thanks!