Skip to contentSkip to conversation

tracing: allow disabling compilation of specific trace systems

RFC PATCH New Tal Shorer 1 participant 3 messages Jun 13, 2015

Subsystems (2)
lore
Share & tools
lore

Tal Shorer

author
#0 lore raw

cover tracing: allow disabling compilation of specific trace systems

Currently, enabling CONFIG_TRACING on a system comes as all-or-nothing: either tracepoints for all subsystems are compiled (with CONFIG_TRACING) or none of them do (without it).

This caused me an unacceptable performance penalty (obviously SOME penalty was expected, but not one so severe) which made me revert the changes in configuration.

The first patch in this series modifies the files that actually define the tracepoint to look for a preprocessor macro NOTRACE and define nops (as if CONFIG_TRACING was not set) instead of them.

The second patch provides an example of how I see this working, with the gpio subsystem as the example for absolutely no reason.
If this idea is deemed worth the time by the community, I'll create patches for the other subsystems.

Tal Shorer (2):
tracing: allow disabling compilation of specific trace systems
tracing: gpio: add Kconfig option for enabling/disabling trace events

 drivers/gpio/Kconfig         | 6 ++++++
 include/linux/tracepoint.h   | 6 +++---
 include/trace/define_trace.h | 2 +-
 include/trace/events/gpio.h  | 4 ++++
 4 files changed, 14 insertions(+), 4 deletions(-)
Signature · 1 line
2.2.2
author
#1 lore raw

RFC PATCH 1/2 tracing: allow disabling compilation of specific trace systems

Allow a trace events header file to disable compilation of its trace events by defining the preprocessor macro NOTRACE.

This could be done, for example, according to a Kconfig option.

---
 include/linux/tracepoint.h   | 6 +++---
 include/trace/define_trace.h | 2 +-
 2 files changed, 4 insertions(+), 4 deletions(-)
include/linux/tracepoint.h +3 -3
index a5f7f3e..c869f84 100644
@@ -111,7 +111,7 @@ extern void syscall_unregfunc(void);
 #define TP_ARGS(args...)	args
 #define TP_CONDITION(args...)	args
 
-#ifdef CONFIG_TRACEPOINTS
+#if defined(CONFIG_TRACEPOINTS) && !defined(NOTRACE)
 
 /*
  * it_func[0] is never NULL because there is at least one element in the array
@@ -234,7 +234,7 @@ extern void syscall_unregfunc(void);
 #define EXPORT_TRACEPOINT_SYMBOL(name)					\
 	EXPORT_SYMBOL(__tracepoint_##name)
 
-#else /* !CONFIG_TRACEPOINTS */
+#else /* !(defined(CONFIG_TRACEPOINTS) && !defined(NOTRACE)) */
 #define __DECLARE_TRACE(name, proto, args, cond, data_proto, data_args) \
 	static inline void trace_##name(proto)				\
 	{ }								\
@@ -266,7 +266,7 @@ extern void syscall_unregfunc(void);
 #define EXPORT_TRACEPOINT_SYMBOL_GPL(name)
 #define EXPORT_TRACEPOINT_SYMBOL(name)
 
-#endif /* CONFIG_TRACEPOINTS */
+#endif /* defined(CONFIG_TRACEPOINTS) && !defined(NOTRACE) */
 
 #ifdef CONFIG_TRACING
 /**
include/trace/define_trace.h +1 -1
index 02e1003..e847fd7 100644
@@ -86,7 +86,7 @@
 #undef DECLARE_TRACE
 #define DECLARE_TRACE(name, proto, args)
 
-#ifdef CONFIG_EVENT_TRACING
+#if defined(CONFIG_EVENT_TRACING) && !defined(NOTRACE)
 #include <trace/ftrace.h>
 #endif
 
Signature · 1 line
2.2.2
author
#2 lore raw

RFC PATCH 2/2 tracing: gpio: add Kconfig option for enabling/disabling trace events

In reply to Tal Shorer

Add a new options to gpio Kconfig, CONFIG_GPIO_TRACING, that is used for enabling/disabling compilation of gpio function trace events.

---
 drivers/gpio/Kconfig        | 6 ++++++
 include/trace/events/gpio.h | 4 ++++
 2 files changed, 10 insertions(+)
drivers/gpio/Kconfig +6 -0
index caefe80..1480a22 100644
@@ -88,6 +88,12 @@ config GPIO_SYSFS
 config GPIO_GENERIC
 	tristate
 
+config GPIO_TRACING
+	bool "gpio tracing"
+	depends on TRACING
+	help
+	  Enable tracing for gpio subsystem
+
 # put drivers in the right section, in alphabetical order
 
 # This symbol is selected by both I2C and SPI expanders
include/trace/events/gpio.h +4 -0
index 927a8ad..09af636 100644
@@ -1,6 +1,10 @@
 #undef TRACE_SYSTEM
 #define TRACE_SYSTEM gpio
 
+#ifndef CONFIG_GPIO_TRACING
+#define NOTRACE
+#endif
+
 #if !defined(_TRACE_GPIO_H) || defined(TRACE_HEADER_MULTI_READ)
 #define _TRACE_GPIO_H
 
Signature · 1 line
2.2.2