Skip to contentSkip to conversation

Allow different tracers to be compiled independently

PATCH In review Jan Kara 10 participants 40 messages Mar 23, 2010 – Mar 26, 2010

Subsystems (14)
lore
Share & tools
lore
author reviewer
#14 lore raw

PATCH 7/18 ext4: Provide config options for enabling ext4 and jbd2 tracing

In reply to Jan Kara
---
 include/trace/events/ext4.h |    2 ++
 include/trace/events/jbd2.h |    2 ++
 kernel/trace/Kconfig        |   23 +++++++++++++++++++++++
 3 files changed, 27 insertions(+), 0 deletions(-)
include/trace/events/ext4.h +2 -0
index 2aa6aa3..f1ad2e3 100644
@@ -1,5 +1,7 @@
 #undef TRACE_SYSTEM
+#undef TRACE_CONFIG
 #define TRACE_SYSTEM ext4
+#define TRACE_CONFIG CONFIG_EXT4_TRACER
 
 #if !defined(_TRACE_EXT4_H) || defined(TRACE_HEADER_MULTI_READ)
 #define _TRACE_EXT4_H
include/trace/events/jbd2.h +2 -0
index bf16545..37e442b 100644
@@ -1,5 +1,7 @@
 #undef TRACE_SYSTEM
+#undef TRACE_CONFIG
 #define TRACE_SYSTEM jbd2
+#define TRACE_CONFIG CONFIG_JBD2_TRACER
 
 #if !defined(_TRACE_JBD2_H) || defined(TRACE_HEADER_MULTI_READ)
 #define _TRACE_JBD2_H
kernel/trace/Kconfig +23 -0
index 13e13d4..e696314 100644
@@ -438,6 +438,29 @@ config BLK_DEV_IO_TRACE
 
 	  If unsure, say N.
 
+config EXT4_TRACER
+	bool "Support for tracing EXT4 events"
+	depends on EXT4_FS
+	select GENERIC_TRACER
+	select TRACE_ANY_MODULE if EXT4_FS=m
+	help
+	  Provide tracing for various functions in ext4 filesystem
+	  such as block allocation, delayed allocation, or writeback
+	  handling. This trace points can help with debugging allocation
+	  algorithms or writeback performance.
+
+	  If unsure, say N.
+
+config JBD2_TRACER
+	bool "JBD2 tracing"
+	depends on JBD2
+	select GENERIC_TRACER
+	help
+	  Provide tracing for several functions in JBD2 commit and
+	  checkpointing code.
+
+	  If unsure, say N.
+
 config KPROBE_EVENT
 	depends on KPROBES
 	depends on HAVE_REGS_AND_STACK_ACCESS_API
Signature · 1 line
1.6.4.2

Jan Kara

author reviewer
#0 lore raw

cover Allow different tracers to be compiled independently

Hi,

currently, when one tracer is selected, most of tracepoints for other
tracers also gets pulled into the kernel. So for example it's not possible to enable BLK_DEV_IO_TRACE without polluting slab allocation paths with tracepoint checks (see changelog of patch 01). This patch set adds a possibility for each set of trace points to be compile-enabled separately.
The first patch contains the necessary magic in linux/tracepoint.h. Other
patches just tell tracing framework about correspoding config options and possibly introduce them if they did not exist before.
The patches in this patch set are actually completely independent so
they can be merged via respective subsystem trees. But changes are rather tiny so I don't expect much conflicts...

Honza

author reviewer
#17 lore raw

PATCH 10/18 gfs2: Provide config option for enabling trace points

CC cluster-devel at redhat.com
---
 fs/gfs2/Kconfig      |    8 ++++++++
 fs/gfs2/trace_gfs2.h |    2 ++
 2 files changed, 10 insertions(+), 0 deletions(-)
fs/gfs2/Kconfig +8 -0
index 4dcddf8..872ced2 100644
@@ -38,3 +38,11 @@ config GFS2_FS_LOCKING_DLM
 	  Most users of GFS2 will require this. It provides the locking
 	  interface between GFS2 and the DLM, which is required to use GFS2
 	  in a cluster environment.
+
+config GFS2_TRACER
+	bool "GFS2 tracing"
+	depends on GFS2_FS && EVENT_TRACING
+	help
+	  Provide trace points in block allocation functions, locking, and
+	  journaling code.
+
fs/gfs2/trace_gfs2.h +2 -0
index 148d55c..5f4faf3 100644
@@ -1,5 +1,7 @@
 #undef TRACE_SYSTEM
+#undef TRACE_CONFIG
 #define TRACE_SYSTEM gfs2
+#define TRACE_CONFIG CONFIG_GFS2_TRACER
 
 #if !defined(_TRACE_GFS2_H) || defined(TRACE_HEADER_MULTI_READ)
 #define _TRACE_GFS2_H
Signature · 1 line
1.6.4.2
author reviewer
#22 lore raw

PATCH 11/18 i915: Provide config option for enabling tracepoints

In reply to Jan Kara
---
 drivers/gpu/drm/Kconfig           |    9 +++++++++
 drivers/gpu/drm/i915/i915_trace.h |    2 ++
 2 files changed, 11 insertions(+), 0 deletions(-)
drivers/gpu/drm/Kconfig +9 -0
index 305c590..bce8013 100644
@@ -124,6 +124,15 @@ config DRM_I915_KMS
 	  the driver to bind to PCI devices, which precludes loading things
 	  like intelfb.
 
+config DRM_I915_TRACER
+	bool "Enable tracing of i915 driver"
+	depends on DRM_I915 && EVENT_TRACING
+	help
+	  Say Y here to make i915 driver provide trace points in functions
+	  handling irqs, dmas, and gem.
+
+	  If unsure, say N.
+
 endchoice
 
 config DRM_MGA
drivers/gpu/drm/i915/i915_trace.h +2 -0
index 01840d9..fdb59c2 100644
@@ -3,6 +3,8 @@
 
 #include <linux/stringify.h>
 #include <linux/types.h>
+#undef TRACE_CONFIG
+#define TRACE_CONFIG CONFIG_DRM_I915_TRACER
 #include <linux/tracepoint.h>
 
 #include <drm/drmP.h>
Signature · 1 line
1.6.4.2
author reviewer
#5 lore raw

PATCH 3/18 mm: Generate kmemtrace trace points only if they are enabled

In reply to Jan Kara
---
 include/trace/events/kmem.h |    2 ++
 1 files changed, 2 insertions(+), 0 deletions(-)
include/trace/events/kmem.h +2 -0
index 3adca0c..1f93693 100644
@@ -1,5 +1,7 @@
 #undef TRACE_SYSTEM
+#undef TRACE_CONFIG
 #define TRACE_SYSTEM kmem
+#define TRACE_CONFIG CONFIG_KMEMTRACE
 
 #if !defined(_TRACE_KMEM_H) || defined(TRACE_HEADER_MULTI_READ)
 #define _TRACE_KMEM_H
Signature · 7 lines
1.6.4.2

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to [email protected].  For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
author reviewer
#6 lore raw

PATCH 4/18 mac80211: Generate trace points only if api tracer enabled

In reply to Jan Kara
---
 net/mac80211/driver-trace.h |    4 +++-
 1 files changed, 3 insertions(+), 1 deletions(-)
net/mac80211/driver-trace.h +3 -1
index 41baf73..0e6c059 100644
@@ -1,11 +1,13 @@
 #if !defined(__MAC80211_DRIVER_TRACE) || defined(TRACE_HEADER_MULTI_READ)
 #define __MAC80211_DRIVER_TRACE
 
+#undef TRACE_CONFIG
+#define TRACE_CONFIG CONFIG_MAC80211_DRIVER_API_TRACER
 #include <linux/tracepoint.h>
 #include <net/mac80211.h>
 #include "ieee80211_i.h"
 
-#if !defined(CONFIG_MAC80211_DRIVER_API_TRACER) || defined(__CHECKER__)
+#if defined(__CHECKER__)
 #undef TRACE_EVENT
 #define TRACE_EVENT(name, proto, ...) \
 static inline void trace_ ## name(proto) {}
Signature · 1 line
1.6.4.2
author reviewer
#27 lore raw

PATCH 13/18 acpi: Provide config option to enable power tracepoints

In reply to Jan Kara
---
 include/trace/events/power.h |    2 ++
 kernel/trace/Kconfig         |    9 +++++++++
 2 files changed, 11 insertions(+), 0 deletions(-)
include/trace/events/power.h +2 -0
index c4efe9b..6d84fc1 100644
@@ -1,5 +1,7 @@
 #undef TRACE_SYSTEM
+#undef TRACE_CONFIG
 #define TRACE_SYSTEM power
+#define TRACE_CONFIG CONFIG_POWER_TRACER
 
 #if !defined(_TRACE_POWER_H) || defined(TRACE_HEADER_MULTI_READ)
 #define _TRACE_POWER_H
kernel/trace/Kconfig +9 -0
index 787f52e..a48ff49 100644
@@ -430,6 +430,15 @@ config TIMER_TRACER
 
 	  If unsure, say N
 
+config POWER_TRACER
+	bool "Trace power events"
+	select GENERIC_TRACER
+	help
+	  Provide trace points for events like changing CPU frequency,
+	  turning CPUs on / off.
+
+	  If unsure, say N
+
 config WORKQUEUE_TRACER
 	bool "Trace workqueues"
 	select GENERIC_TRACER
Signature · 1 line
1.6.4.2
author reviewer
#28 lore raw

PATCH 14/18 net: Provide config option for enabling SKB tracing

In reply to Jan Kara
---
 include/trace/events/skb.h |    2 ++
 kernel/trace/Kconfig       |   10 ++++++++++
 2 files changed, 12 insertions(+), 0 deletions(-)
include/trace/events/skb.h +2 -0
index 4b2be6d..cd340df 100644
@@ -1,5 +1,7 @@
 #undef TRACE_SYSTEM
+#undef TRACE_CONFIG
 #define TRACE_SYSTEM skb
+#define TRACE_CONFIG CONFIG_SKB_TRACER
 
 #if !defined(_TRACE_SKB_H) || defined(TRACE_HEADER_MULTI_READ)
 #define _TRACE_SKB_H
kernel/trace/Kconfig +10 -0
index a48ff49..a02d577 100644
@@ -498,6 +498,16 @@ config JBD2_TRACER
 
 	  If unsure, say N.
 
+config SKB_TRACER
+	bool "SKB tracing"
+	depends on NET
+	select GENERIC_TRACER
+	help
+	  Provide tracing for copying datagrams into iovecs and freeing
+	  skbs.
+
+	  If unsure, say N.
+
 config KPROBE_EVENT
 	depends on KPROBES
 	depends on HAVE_REGS_AND_STACK_ACCESS_API
Signature · 1 line
1.6.4.2
author reviewer
#29 lore raw

PATCH 15/18 net: Provide config option for enabling NAPI tracing

In reply to Jan Kara
---
 include/trace/events/napi.h |    2 ++
 kernel/trace/Kconfig        |    9 +++++++++
 2 files changed, 11 insertions(+), 0 deletions(-)
include/trace/events/napi.h +2 -0
index a8989c4..70cb4dd 100644
@@ -2,6 +2,8 @@
 #define _TRACE_NAPI_H_
 
 #include <linux/netdevice.h>
+#undef TRACE_CONFIG
+#define TRACE_CONFIG CONFIG_NAPI_TRACER
 #include <linux/tracepoint.h>
 
 DECLARE_TRACE(napi_poll,
kernel/trace/Kconfig +9 -0
index a02d577..88b556c 100644
@@ -508,6 +508,15 @@ config SKB_TRACER
 
 	  If unsure, say N.
 
+config NAPI_TRACER
+	bool "NAPI tracing"
+	depends on NET
+	select GENERIC_TRACER
+	help
+	  Provide tracing for NAPI functions.
+
+	  If unsure, say N.
+
 config KPROBE_EVENT
 	depends on KPROBES
 	depends on HAVE_REGS_AND_STACK_ACCESS_API
Signature · 1 line
1.6.4.2
author reviewer
#30 lore raw

PATCH 16/18 Generate empty tracepoints if syscall tracing is disabled

In reply to Jan Kara
---
 include/trace/events/syscalls.h |    2 ++
 1 files changed, 2 insertions(+), 0 deletions(-)
include/trace/events/syscalls.h +2 -0
index fb726ac..6f0ad30 100644
@@ -1,6 +1,8 @@
 #undef TRACE_SYSTEM
+#undef TRACE_CONFIG
 #define TRACE_SYSTEM raw_syscalls
 #define TRACE_INCLUDE_FILE syscalls
+#define TRACE_CONFIG CONFIG_FTRACE_SYSCALLS
 
 #if !defined(_TRACE_EVENTS_SYSCALLS_H) || defined(TRACE_HEADER_MULTI_READ)
 #define _TRACE_EVENTS_SYSCALLS_H
Signature · 1 line
1.6.4.2
author reviewer
#31 lore raw

PATCH 17/18 kvm: Provide config option for enabling KVM trace events

In reply to Jan Kara
---
 include/trace/events/kvm.h |    2 ++
 kernel/trace/Kconfig       |    9 +++++++++
 2 files changed, 11 insertions(+), 0 deletions(-)
include/trace/events/kvm.h +2 -0
index b17d49d..c85908c 100644
@@ -1,6 +1,8 @@
 #if !defined(_TRACE_KVM_MAIN_H) || defined(TRACE_HEADER_MULTI_READ)
 #define _TRACE_KVM_MAIN_H
 
+#undef TRACE_CONFIG
+#define TRACE_CONFIG CONFIG_KVM_TRACER
 #include <linux/tracepoint.h>
 
 #undef TRACE_SYSTEM
kernel/trace/Kconfig +9 -0
index 88b556c..abcd529 100644
@@ -517,6 +517,15 @@ config NAPI_TRACER
 
 	  If unsure, say N.
 
+config KVM_TRACER
+	bool "KVM tracing"
+	depends on KVM
+	select GENERIC_TRACER
+	help
+	  Trace lots of various events inside KVM.
+
+	  If unsure, say N.
+
 config KPROBE_EVENT
 	depends on KPROBES
 	depends on HAVE_REGS_AND_STACK_ACCESS_API
Signature · 1 line
1.6.4.2
author reviewer
#4 lore raw

PATCH 2/18 block: Generate blktrace trace points only if blktrace is enabled

In reply to Jan Kara
---
 include/trace/events/block.h |    2 ++
 1 files changed, 2 insertions(+), 0 deletions(-)
include/trace/events/block.h +2 -0
index 5fb7273..6412165 100644
@@ -1,5 +1,7 @@
 #undef TRACE_SYSTEM
+#undef TRACE_CONFIG
 #define TRACE_SYSTEM block
+#define TRACE_CONFIG CONFIG_BLK_DEV_IO_TRACE
 
 #if !defined(_TRACE_BLOCK_H) || defined(TRACE_HEADER_MULTI_READ)
 #define _TRACE_BLOCK_H
Signature · 1 line
1.6.4.2
author reviewer
#24 lore raw

PATCH 12/18 timer: Provide config option for enabling timer tracepoints

In reply to Jan Kara
CC Thomas Gleixner <[email protected]>
---
 include/trace/events/timer.h |    2 ++
 kernel/trace/Kconfig         |    9 +++++++++
 2 files changed, 11 insertions(+), 0 deletions(-)
include/trace/events/timer.h +2 -0
index 9496b96..2737598 100644
@@ -1,5 +1,7 @@
 #undef TRACE_SYSTEM
+#undef TRACE_CONFIG
 #define TRACE_SYSTEM timer
+#define TRACE_CONFIG CONFIG_TIMER_TRACER
 
 #if !defined(_TRACE_TIMER_H) || defined(TRACE_HEADER_MULTI_READ)
 #define _TRACE_TIMER_H
kernel/trace/Kconfig +9 -0
index a9d7e33..787f52e 100644
@@ -421,6 +421,15 @@ config MODULE_TRACER
 
 	  If unsure, say N
 
+config TIMER_TRACER
+	bool "Trace timer actions"
+	select GENERIC_TRACER
+	help
+	  Provide trace points for timer initialization, starting, expiring,
+	  and canceling.
+
+	  If unsure, say N
+
 config WORKQUEUE_TRACER
 	bool "Trace workqueues"
 	select GENERIC_TRACER
Signature · 1 line
1.6.4.2
author reviewer
#15 lore raw

PATCH 8/18 lockdep: Provide config option for enabling lock tracepoints

In reply to Jan Kara
CC Peter Zijlstra <[email protected]>
CC Ingo Molnar <[email protected]>
---
 include/trace/events/lock.h |    2 ++
 kernel/trace/Kconfig        |    9 +++++++++
 2 files changed, 11 insertions(+), 0 deletions(-)
include/trace/events/lock.h +2 -0
index 5c1dcfc..a1836e5 100644
@@ -1,5 +1,7 @@
 #undef TRACE_SYSTEM
+#undef TRACE_CONFIG
 #define TRACE_SYSTEM lock
+#define TRACE_CONFIG CONFIG_LOCK_TRACER
 
 #if !defined(_TRACE_LOCK_H) || defined(TRACE_HEADER_MULTI_READ)
 #define _TRACE_LOCK_H
kernel/trace/Kconfig +9 -0
index e696314..ac63423 100644
@@ -402,6 +402,15 @@ config KMEMTRACE
 
 	  If unsure, say N.
 
+config LOCK_TRACER
+	bool "Trace lock operations"
+	depends on LOCKDEP
+	select GENERIC_TRACER
+	help
+	  Provide trace points for acquisition and release of locks.
+
+	  If unsure, say N
+
 config WORKQUEUE_TRACER
 	bool "Trace workqueues"
 	select GENERIC_TRACER
Signature · 1 line
1.6.4.2
author reviewer
#10 lore raw

PATCH 6/18 sched: Generate trace points only if scheduler tracing is enabled

In reply to Jan Kara
CC Ingo Molnar <[email protected]>
CC Peter Zijlstra <[email protected]>
---
 include/trace/events/sched.h |    2 ++
 1 files changed, 2 insertions(+), 0 deletions(-)
include/trace/events/sched.h +2 -0
index cfceb0b..0a08ab1 100644
@@ -1,5 +1,7 @@
 #undef TRACE_SYSTEM
+#undef TRACE_CONFIG
 #define TRACE_SYSTEM sched
+#define TRACE_CONFIG CONFIG_CONTEXT_SWITCH_TRACER
 
 #if !defined(_TRACE_SCHED_H) || defined(TRACE_HEADER_MULTI_READ)
 #define _TRACE_SCHED_H
Signature · 1 line
1.6.4.2
author reviewer
#16 lore raw

PATCH 9/18 module: Provide config option to enable tracing of module load / unload

In reply to Jan Kara
---
 include/trace/events/module.h |    2 ++
 kernel/trace/Kconfig          |   10 ++++++++++
 2 files changed, 12 insertions(+), 0 deletions(-)
include/trace/events/module.h +2 -0
index 4b0f48b..edaa505 100644
@@ -1,5 +1,7 @@
 #undef TRACE_SYSTEM
+#undef TRACE_CONFIG
 #define TRACE_SYSTEM module
+#define TRACE_CONFIG CONFIG_MODULE_TRACER
 
 #if !defined(_TRACE_MODULE_H) || defined(TRACE_HEADER_MULTI_READ)
 #define _TRACE_MODULE_H
kernel/trace/Kconfig +10 -0
index ac63423..a9d7e33 100644
@@ -411,6 +411,16 @@ config LOCK_TRACER
 
 	  If unsure, say N
 
+config MODULE_TRACER
+	bool "Trace module loading and unloading"
+	depends on MODULES
+	select GENERIC_TRACER
+	help
+	  Provide trace point for module loading, unloading, freeing,
+	  etc.
+
+	  If unsure, say N
+
 config WORKQUEUE_TRACER
 	bool "Trace workqueues"
 	select GENERIC_TRACER
Signature · 1 line
1.6.4.2
author reviewer
#32 lore raw

PATCH 18/18 Create config option for enabling IRQ tracepoints

In reply to Jan Kara
---
 include/trace/events/irq.h |    2 ++
 kernel/trace/Kconfig       |    6 ++++++
 2 files changed, 8 insertions(+), 0 deletions(-)
include/trace/events/irq.h +2 -0
index 0e4cfb6..dd9cdb7 100644
@@ -1,5 +1,7 @@
 #undef TRACE_SYSTEM
+#undef TRACE_CONFIG
 #define TRACE_SYSTEM irq
+#define TRACE_CONFIG CONFIG_IRQ_TRACER
 
 #if !defined(_TRACE_IRQ_H) || defined(TRACE_HEADER_MULTI_READ)
 #define _TRACE_IRQ_H
kernel/trace/Kconfig +6 -0
index abcd529..7893ea4 100644
@@ -152,6 +152,10 @@ config FUNCTION_GRAPH_TRACER
 	  address on the current task structure into a stack of calls.
 
 
+# Config option to determine whether IRQ tracepoins should be compiled
+config IRQ_TRACER
+       bool
+
 config IRQSOFF_TRACER
 	bool "Interrupts-off Latency Tracer"
 	default n
@@ -161,6 +165,7 @@ config IRQSOFF_TRACER
 	select GENERIC_TRACER
 	select TRACER_MAX_TRACE
 	select RING_BUFFER_ALLOW_SWAP
+	select IRQ_TRACER
 	help
 	  This option measures the time spent in irqs-off critical
 	  sections, with microsecond accuracy.
@@ -183,6 +188,7 @@ config PREEMPT_TRACER
 	select GENERIC_TRACER
 	select TRACER_MAX_TRACE
 	select RING_BUFFER_ALLOW_SWAP
+	select IRQ_TRACER
 	help
 	  This option measures the time spent in preemption-off critical
 	  sections, with microsecond accuracy.
Signature · 1 line
1.6.4.2
author reviewer
#9 lore raw

PATCH 5/18 workqueue: Generate trace points only when workqueue tracer enabled

In reply to Jan Kara
---
 include/trace/events/workqueue.h |    2 ++
 1 files changed, 2 insertions(+), 0 deletions(-)
include/trace/events/workqueue.h +2 -0
index d6c9744..d1641ad 100644
@@ -1,5 +1,7 @@
 #undef TRACE_SYSTEM
+#undef TRACE_CONFIG
 #define TRACE_SYSTEM workqueue
+#define TRACE_CONFIG CONFIG_WORKQUEUE_TRACER
 
 #if !defined(_TRACE_WORKQUEUE_H) || defined(TRACE_HEADER_MULTI_READ)
 #define _TRACE_WORKQUEUE_H
Signature · 1 line
1.6.4.2
author reviewer
#1 lore raw

PATCH 1/18 trace: Allow <linux/tracepoint.h> to create empty tracepoints

In reply to Jan Kara

If a particular tracer is disabled, there is no need to generate any tracepoint code for it. Actually, the inline checks whether tracepoints of the tracer are active have non-negligible impact on a code size [1] and thus can in theory lead to slowdown. This is undesirable when e.g. BLK_DEV_IO_TRACE should be enabled in the production kernel but KMEMTRACE is disabled.

So introduce a macro trickery in <linux/tracepoint.h> so that each tracer can define TRACE_CONFIG to CONFIG_MY_TRACER before including linux/tracepoint.h in it's events file and that will result in tracepoints becoming empty if CONFIG_MY_TRACER is not defined.

[1] As an example: bloat-o-meter mm/slub.o.untraced mm/slub.o.traced add/remove: 61/1 grow/shrink: 24/10 up/down: 6366/-737 (5629)

function                                     old     new   delta
deactivate_slab                                -     592    +592
show_stat                                      -     380    +380
trace_kmalloc_node                             -     265    +265
trace_kmalloc                                  -     255    +255
kmem_cache_alloc_node                        590     825    +235
kmem_cache_alloc                             542     768    +226
kfree                                        566     763    +197
kmem_cache_free                              478     671    +193

...

CC Steven Rostedt <[email protected]>
CC Frederic Weisbecker <[email protected]>
CC Ingo Molnar <[email protected]>
---
 include/linux/tracepoint.h |   96 +++++++++++++++++++++++++++++++++++--------
 1 files changed, 78 insertions(+), 18 deletions(-)
include/linux/tracepoint.h +78 -18
index f59604e..1ad17cc 100644
@@ -37,8 +37,7 @@ struct tracepoint {
 
 #define TP_PROTO(args...)	args
 #define TP_ARGS(args...)	args
-
-#ifdef CONFIG_TRACEPOINTS
+#define PARAMS(args...)		args
 
 /*
  * it_func[0] is never NULL because there is at least one element in the array
@@ -63,7 +62,7 @@ struct tracepoint {
  * not add unwanted padding between the beginning of the section and the
  * structure. Force alignment to the same alignment as the section start.
  */
-#define DECLARE_TRACE(name, proto, args)				\
+#define DECLARE_TRACE_1(name, proto, args)				\
 	extern struct tracepoint __tracepoint_##name;			\
 	static inline void trace_##name(proto)				\
 	{								\
@@ -81,26 +80,22 @@ struct tracepoint {
 	}
 
 
-#define DEFINE_TRACE_FN(name, reg, unreg)				\
+#define DEFINE_TRACE_FN_1(name, reg, unreg)				\
 	static const char __tpstrtab_##name[]				\
 	__attribute__((section("__tracepoints_strings"))) = #name;	\
 	struct tracepoint __tracepoint_##name				\
 	__attribute__((section("__tracepoints"), aligned(32))) =	\
 		{ __tpstrtab_##name, 0, reg, unreg, NULL }
 
-#define DEFINE_TRACE(name)						\
+#define DEFINE_TRACE_1(name)						\
 	DEFINE_TRACE_FN(name, NULL, NULL);
 
-#define EXPORT_TRACEPOINT_SYMBOL_GPL(name)				\
+#define EXPORT_TRACEPOINT_SYMBOL_GPL_1(name)				\
 	EXPORT_SYMBOL_GPL(__tracepoint_##name)
-#define EXPORT_TRACEPOINT_SYMBOL(name)					\
+#define EXPORT_TRACEPOINT_SYMBOL_1(name)				\
 	EXPORT_SYMBOL(__tracepoint_##name)
 
-extern void tracepoint_update_probe_range(struct tracepoint *begin,
-	struct tracepoint *end);
-
-#else /* !CONFIG_TRACEPOINTS */
-#define DECLARE_TRACE(name, proto, args)				\
+#define DECLARE_TRACE_0(name, proto, args)				\
 	static inline void _do_trace_##name(struct tracepoint *tp, proto) \
 	{ }								\
 	static inline void trace_##name(proto)				\
@@ -114,10 +109,51 @@ extern void tracepoint_update_probe_range(struct tracepoint *begin,
 		return -ENOSYS;						\
 	}
 
-#define DEFINE_TRACE_FN(name, reg, unreg)
-#define DEFINE_TRACE(name)
-#define EXPORT_TRACEPOINT_SYMBOL_GPL(name)
-#define EXPORT_TRACEPOINT_SYMBOL(name)
+#define DEFINE_TRACE_FN_0(name, reg, unreg)
+#define DEFINE_TRACE_0(name)
+#define EXPORT_TRACEPOINT_SYMBOL_GPL_0(name)
+#define EXPORT_TRACEPOINT_SYMBOL_0(name)
+
+/*
+ * Below two-level macro magic is really needed to propely expand TRACE_CONFIG
+ * macro to 0 or 1 in the end
+ */
+#define __DECLARE_TRACE(config, name, proto, args) \
+		DECLARE_TRACE_##config(name, PARAMS(proto), PARAMS(args))
+#define __DEFINE_TRACE_FN(config, name, reg, unreg) \
+			DEFINE_TRACE_FN_##config(name, reg, unreg)
+#define __DEFINE_TRACE(config, name) DEFINE_TRACE_##config(name)
+#define __EXPORT_TRACEPOINT_SYMBOL_GPL(config, name) \
+			EXPORT_TRACEPOINT_SYMBOL_GPL_##config(name)
+#define __EXPORT_TRACEPOINT_SYMBOL(config, name) \
+			EXPORT_TRACEPOINT_SYMBOL_##config(name)
+
+#define _DECLARE_TRACE(config, name, proto, args) \
+		__DECLARE_TRACE(config, name, PARAMS(proto), PARAMS(args))
+#define _DEFINE_TRACE_FN(config, name, reg, unreg) \
+			__DEFINE_TRACE_FN(config, name, reg, unreg)
+#define _DEFINE_TRACE(config, name) __DEFINE_TRACE(config, name)
+#define _EXPORT_TRACEPOINT_SYMBOL_GPL(config, name) \
+			__EXPORT_TRACEPOINT_SYMBOL_GPL(config, name)
+#define _EXPORT_TRACEPOINT_SYMBOL(config, name) \
+			__EXPORT_TRACEPOINT_SYMBOL(config, name)
+
+#define DECLARE_TRACE(name, proto, args) \
+		_DECLARE_TRACE(TRACE_CONFIG, name, PARAMS(proto), PARAMS(args))
+#define DEFINE_TRACE_FN(name, reg, unreg) \
+			_DEFINE_TRACE_FN(TRACE_CONFIG, name, reg, unreg)
+#define DEFINE_TRACE(name) _DEFINE_TRACE(TRACE_CONFIG, name)
+#define EXPORT_TRACEPOINT_SYMBOL_GPL(name) \
+			_EXPORT_TRACEPOINT_SYMBOL_GPL(TRACE_CONFIG, name)
+#define EXPORT_TRACEPOINT_SYMBOL(name) \
+			_EXPORT_TRACEPOINT_SYMBOL(TRACE_CONFIG, name)
+
+#ifdef CONFIG_TRACEPOINTS
+
+extern void tracepoint_update_probe_range(struct tracepoint *begin,
+	struct tracepoint *end);
+
+#else /* ! CONFIG_TRACEPOINTS */
 
 static inline void tracepoint_update_probe_range(struct tracepoint *begin,
 	struct tracepoint *end)
@@ -163,11 +199,35 @@ static inline void tracepoint_synchronize_unregister(void)
 	synchronize_sched();
 }
 
-#define PARAMS(args...) args
-
 #endif /* _LINUX_TRACEPOINT_H */
 
 /*
+ * The two chunks below are out of include file ifdef protection because
+ * we want to be able to define TRACE_CONFIG even before second or even
+ * later include of linux/tracepoint.h.
+ */
+/*
+ * Make tracepoints which are not converted to a new method of enabling
+ * always compiled in
+ */
+#ifndef TRACE_CONFIG
+#define TRACE_CONFIG 1
+#endif
+
+/*
+ * If TRACE_CONFIG is defined but a config option it is defined to isn't, make
+ * the result 0. It would require much less magic if the kernel was not
+ * compiled with -Wundef.
+ */
+#define CONFIG_TEST_1
+#define _CONFIG_UNDEF(x) !defined(CONFIG_TEST_##x)
+#define CONFIG_UNDEF(x) _CONFIG_UNDEF(x)
+#if CONFIG_UNDEF(TRACE_CONFIG)
+#undef TRACE_CONFIG
+#define TRACE_CONFIG 0
+#endif
+
+/*
  * Note: we keep the TRACE_EVENT outside the include file ifdef protection.
  *  This is due to the way trace events work. If a file includes two
  *  trace event headers under one "CREATE_TRACE_POINTS" the first include
Signature · 1 line
1.6.4.2
#33 lore raw
In reply to Jan Kara
Quoted 15 lines · Jan Kara

Hi,

currently, when one tracer is selected, most of tracepoints for other
tracers also gets pulled into the kernel. So for example it's not possible to enable BLK_DEV_IO_TRACE without polluting slab allocation paths with tracepoint checks (see changelog of patch 01). This patch set adds a possibility for each set of trace points to be compile-enabled separately.
The first patch contains the necessary magic in linux/tracepoint.h. Other
patches just tell tracing framework about correspoding config options and possibly introduce them if they did not exist before.
The patches in this patch set are actually completely independent so
they can be merged via respective subsystem trees. But changes are rather tiny so I don't expect much conflicts...

Quoted 1 line

Honza

(Adding more people in Cc)

I don't know. Yeah this first looks like a good idea but once CONFIG_EVENT_TRACING is enabled, each tracepoint is a lightweight thing and induce a tiny overhead, probably hard to notice, and this is going to be even more the case after the jmp label optimization patches.

I liked the fact we had a general tracing kernel once the above config is selected. And we don't bother telling people that to use tool X you need CONFIG_EVENT_Y, and you need to rebuild your kernel, etc...

I wonder if this is going to be a win.

maintainer
#2 lore raw

Re: [PATCH 01/18] trace: Allow <linux/tracepoint.h> to create empty tracepoints

In reply to Jan Kara

And I thought I was nasty with the CPP macros ;-)

Added Mathieu to the Cc since he's the one that wrote the original tracepoint code.

Quoted 93 lines · Jan Kara

If a particular tracer is disabled, there is no need to generate any tracepoint code for it. Actually, the inline checks whether tracepoints of the tracer are active have non-negligible impact on a code size [1] and thus can in theory lead to slowdown. This is undesirable when e.g. BLK_DEV_IO_TRACE should be enabled in the production kernel but KMEMTRACE is disabled.

So introduce a macro trickery in <linux/tracepoint.h> so that each tracer can define TRACE_CONFIG to CONFIG_MY_TRACER before including linux/tracepoint.h in it's events file and that will result in tracepoints becoming empty if CONFIG_MY_TRACER is not defined.

[1] As an example: bloat-o-meter mm/slub.o.untraced mm/slub.o.traced add/remove: 61/1 grow/shrink: 24/10 up/down: 6366/-737 (5629)

function                                     old     new   delta
deactivate_slab                                -     592    +592
show_stat                                      -     380    +380
trace_kmalloc_node                             -     265    +265
trace_kmalloc                                  -     255    +255
kmem_cache_alloc_node                        590     825    +235
kmem_cache_alloc                             542     768    +226
kfree                                        566     763    +197
kmem_cache_free                              478     671    +193

...

CC Steven Rostedt <[email protected]>
CC Frederic Weisbecker <[email protected]>
CC Ingo Molnar <[email protected]>
---
 include/linux/tracepoint.h |   96 +++++++++++++++++++++++++++++++++++--------
 1 files changed, 78 insertions(+), 18 deletions(-)
include/linux/tracepoint.h +7 -14
index f59604e..1ad17cc 100644
@@ -37,8 +37,7 @@ struct tracepoint {
 
 #define TP_PROTO(args...)	args
 #define TP_ARGS(args...)	args
-
-#ifdef CONFIG_TRACEPOINTS
+#define PARAMS(args...)		args
 
 /*
  * it_func[0] is never NULL because there is at least one element in the array
@@ -63,7 +62,7 @@ struct tracepoint {
  * not add unwanted padding between the beginning of the section and the
  * structure. Force alignment to the same alignment as the section start.
  */
-#define DECLARE_TRACE(name, proto, args)				\
+#define DECLARE_TRACE_1(name, proto, args)				\
 	extern struct tracepoint __tracepoint_##name;			\
 	static inline void trace_##name(proto)				\
 	{								\
@@ -81,26 +80,22 @@ struct tracepoint {
 	}
 
 
-#define DEFINE_TRACE_FN(name, reg, unreg)				\
+#define DEFINE_TRACE_FN_1(name, reg, unreg)				\
 	static const char __tpstrtab_##name[]				\
 	__attribute__((section("__tracepoints_strings"))) = #name;	\
 	struct tracepoint __tracepoint_##name				\
 	__attribute__((section("__tracepoints"), aligned(32))) =	\
 		{ __tpstrtab_##name, 0, reg, unreg, NULL }
 
-#define DEFINE_TRACE(name)						\
+#define DEFINE_TRACE_1(name)						\
 	DEFINE_TRACE_FN(name, NULL, NULL);
 
-#define EXPORT_TRACEPOINT_SYMBOL_GPL(name)				\
+#define EXPORT_TRACEPOINT_SYMBOL_GPL_1(name)				\
 	EXPORT_SYMBOL_GPL(__tracepoint_##name)
-#define EXPORT_TRACEPOINT_SYMBOL(name)					\
+#define EXPORT_TRACEPOINT_SYMBOL_1(name)				\
 	EXPORT_SYMBOL(__tracepoint_##name)
 
-extern void tracepoint_update_probe_range(struct tracepoint *begin,
-	struct tracepoint *end);
-
-#else /* !CONFIG_TRACEPOINTS */
-#define DECLARE_TRACE(name, proto, args)				\
+#define DECLARE_TRACE_0(name, proto, args)				\
 	static inline void _do_trace_##name(struct tracepoint *tp, proto) \
 	{ }								\
 	static inline void trace_##name(proto)				\
@@ -114,10 +109,51 @@ extern void tracepoint_update_probe_range(struct tracepoint *begin,
 		return -ENOSYS;						\
 	}
 
-#define DEFINE_TRACE_FN(name, reg, unreg)
-#define DEFINE_TRACE(name)

include/linux/tracepoint.h extern void tracepoint_update_probe_range(struct tracepoint *begin, · line 119

Quoted 10 lines
include/linux/tracepoint.h +8 -2
-#define EXPORT_TRACEPOINT_SYMBOL_GPL(name)
-#define EXPORT_TRACEPOINT_SYMBOL(name)
+#define DEFINE_TRACE_FN_0(name, reg, unreg)
+#define DEFINE_TRACE_0(name)
+#define EXPORT_TRACEPOINT_SYMBOL_GPL_0(name)
+#define EXPORT_TRACEPOINT_SYMBOL_0(name)
+
+/*
+ * Below two-level macro magic is really needed to propely expand TRACE_CONFIG
+ * macro to 0 or 1 in the end

This is a really lame comment. There should be almost as much comments as code when doing CPP trickery like this.

Quoted 50 lines
include/linux/tracepoint.h +38 -2
+ */
+#define __DECLARE_TRACE(config, name, proto, args) \
+		DECLARE_TRACE_##config(name, PARAMS(proto), PARAMS(args))
+#define __DEFINE_TRACE_FN(config, name, reg, unreg) \
+			DEFINE_TRACE_FN_##config(name, reg, unreg)
+#define __DEFINE_TRACE(config, name) DEFINE_TRACE_##config(name)
+#define __EXPORT_TRACEPOINT_SYMBOL_GPL(config, name) \
+			EXPORT_TRACEPOINT_SYMBOL_GPL_##config(name)
+#define __EXPORT_TRACEPOINT_SYMBOL(config, name) \
+			EXPORT_TRACEPOINT_SYMBOL_##config(name)
+
+#define _DECLARE_TRACE(config, name, proto, args) \
+		__DECLARE_TRACE(config, name, PARAMS(proto), PARAMS(args))
+#define _DEFINE_TRACE_FN(config, name, reg, unreg) \
+			__DEFINE_TRACE_FN(config, name, reg, unreg)
+#define _DEFINE_TRACE(config, name) __DEFINE_TRACE(config, name)
+#define _EXPORT_TRACEPOINT_SYMBOL_GPL(config, name) \
+			__EXPORT_TRACEPOINT_SYMBOL_GPL(config, name)
+#define _EXPORT_TRACEPOINT_SYMBOL(config, name) \
+			__EXPORT_TRACEPOINT_SYMBOL(config, name)
+
+#define DECLARE_TRACE(name, proto, args) \
+		_DECLARE_TRACE(TRACE_CONFIG, name, PARAMS(proto), PARAMS(args))
+#define DEFINE_TRACE_FN(name, reg, unreg) \
+			_DEFINE_TRACE_FN(TRACE_CONFIG, name, reg, unreg)
+#define DEFINE_TRACE(name) _DEFINE_TRACE(TRACE_CONFIG, name)
+#define EXPORT_TRACEPOINT_SYMBOL_GPL(name) \
+			_EXPORT_TRACEPOINT_SYMBOL_GPL(TRACE_CONFIG, name)
+#define EXPORT_TRACEPOINT_SYMBOL(name) \
+			_EXPORT_TRACEPOINT_SYMBOL(TRACE_CONFIG, name)
+
+#ifdef CONFIG_TRACEPOINTS
+
+extern void tracepoint_update_probe_range(struct tracepoint *begin,
+	struct tracepoint *end);
+
+#else /* ! CONFIG_TRACEPOINTS */
 
 static inline void tracepoint_update_probe_range(struct tracepoint *begin,
 	struct tracepoint *end)
@@ -163,11 +199,35 @@ static inline void tracepoint_synchronize_unregister(void)
 	synchronize_sched();
 }
 
-#define PARAMS(args...) args
-
 #endif /* _LINUX_TRACEPOINT_H */
 
 /*
+ * The two chunks below are out of include file ifdef protection because

include/linux/tracepoint.h static inline void tracepoint_synchronize_unregister(void) · line 215

Quoted 10 lines
include/linux/tracepoint.h +10 -0
+ * we want to be able to define TRACE_CONFIG even before second or even
+ * later include of linux/tracepoint.h.
+ */
+/*
+ * Make tracepoints which are not converted to a new method of enabling
+ * always compiled in
+ */
+#ifndef TRACE_CONFIG
+#define TRACE_CONFIG 1
+#endif

Hmm, We can have tracepoints in a header. Would this still work if a header with a tracepoint was not converted but it was included in a file that was. Of course I haven't seen the other patches yet so I don't yet know what a conversion looks like.

-- Steve

<

Quoted 18 lines
include/linux/tracepoint.h +15 -0
+
+/*
+ * If TRACE_CONFIG is defined but a config option it is defined to isn't, make
+ * the result 0. It would require much less magic if the kernel was not
+ * compiled with -Wundef.
+ */
+#define CONFIG_TEST_1
+#define _CONFIG_UNDEF(x) !defined(CONFIG_TEST_##x)
+#define CONFIG_UNDEF(x) _CONFIG_UNDEF(x)
+#if CONFIG_UNDEF(TRACE_CONFIG)
+#undef TRACE_CONFIG
+#define TRACE_CONFIG 0
+#endif
+
+/*
  * Note: we keep the TRACE_EVENT outside the include file ifdef protection.
  *  This is due to the way trace events work. If a file includes two
  *  trace event headers under one "CREATE_TRACE_POINTS" the first include
#11 lore raw

Re: [PATCH 06/18] sched: Generate trace points only if scheduler tracing is enabled

In reply to Jan Kara
Quoted 4 lines · Jan Kara
CC Ingo Molnar <[email protected]>
CC Peter Zijlstra <[email protected]>

---

Note this one is an exception.
Once tracing is enabled, we need the context switch tracer anyway to keep track of the pid:cmdline mappings.

Quoted 23 lines
 include/trace/events/sched.h |    2 ++
 1 files changed, 2 insertions(+), 0 deletions(-)
include/trace/events/sched.h +2 -0
index cfceb0b..0a08ab1 100644
@@ -1,5 +1,7 @@
 #undef TRACE_SYSTEM
+#undef TRACE_CONFIG
 #define TRACE_SYSTEM sched
+#define TRACE_CONFIG CONFIG_CONTEXT_SWITCH_TRACER
 
 #if !defined(_TRACE_SCHED_H) || defined(TRACE_HEADER_MULTI_READ)
 #define _TRACE_SCHED_H
Signature · 7 lines
1.6.4.2

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/
Acked-by on v1 12/18
#25 lore raw

Re: [PATCH 12/18] timer: Provide config option for enabling timer tracepoints

In reply to Jan Kara
Quoted 2 lines · Jan Kara
CC Thomas Gleixner <[email protected]>

Steven, can you pick that up please ?

Quoted 40 lines
---
 include/trace/events/timer.h |    2 ++
 kernel/trace/Kconfig         |    9 +++++++++
 2 files changed, 11 insertions(+), 0 deletions(-)
include/trace/events/timer.h +2 -0
index 9496b96..2737598 100644
@@ -1,5 +1,7 @@
 #undef TRACE_SYSTEM
+#undef TRACE_CONFIG
 #define TRACE_SYSTEM timer
+#define TRACE_CONFIG CONFIG_TIMER_TRACER
 
 #if !defined(_TRACE_TIMER_H) || defined(TRACE_HEADER_MULTI_READ)
 #define _TRACE_TIMER_H
kernel/trace/Kconfig +9 -0
index a9d7e33..787f52e 100644
@@ -421,6 +421,15 @@ config MODULE_TRACER
 
 	  If unsure, say N
 
+config TIMER_TRACER
+	bool "Trace timer actions"
+	select GENERIC_TRACER
+	help
+	  Provide trace points for timer initialization, starting, expiring,
+	  and canceling.
+
+	  If unsure, say N
+
 config WORKQUEUE_TRACER
 	bool "Trace workqueues"
 	select GENERIC_TRACER
Signature · 1 line
1.6.4.2
maintainer
#26 lore raw

Re: [PATCH 12/18] timer: Provide config option for enabling timer tracepoints

Quoted 8 lines · Thomas Gleixner
Quoted 2 lines · Jan Kara
CC Thomas Gleixner <[email protected]>

Steven, can you pick that up please ?

I assume this is dependent on the first patch. I made some comments to that one, and was hoping to get some better comments in the code before doing anything with it.

-- Steve

maintainer
#34 lore raw
In reply to Frederic Weisbecker
Quoted 11 lines · Frederic Weisbecker

I don't know. Yeah this first looks like a good idea but once CONFIG_EVENT_TRACING is enabled, each tracepoint is a lightweight thing and induce a tiny overhead, probably hard to notice, and this is going to be even more the case after the jmp label optimization patches.

I liked the fact we had a general tracing kernel once the above config is selected. And we don't bother telling people that to use tool X you need CONFIG_EVENT_Y, and you need to rebuild your kernel, etc...

Indeed, a lot of the value of tracepoints goes away if people are compiling kernels without them and we need to get a special "tracing kernel" installed before we can debug a problem.

So I'd hope we can do the necessary optimization work so people don't feel it's necessary to enable or disable tracepoints by subsystem....

-- Ted

#35 lore raw
Quoted 12 lines · Theodore Tso
Quoted 9 lines · Frederic Weisbecker

I don't know. Yeah this first looks like a good idea but once CONFIG_EVENT_TRACING is enabled, each tracepoint is a lightweight thing and induce a tiny overhead, probably hard to notice, and this is going to be even more the case after the jmp label optimization patches.

I liked the fact we had a general tracing kernel once the above config is selected. And we don't bother telling people that to use tool X you need CONFIG_EVENT_Y, and you need to rebuild your kernel, etc...

Quoted 6 lines

Indeed, a lot of the value of tracepoints goes away if people are compiling kernels without them and we need to get a special "tracing kernel" installed before we can debug a problem.

So I'd hope we can do the necessary optimization work so people don't feel it's necessary to enable or disable tracepoints by subsystem....

Yeah, agreed. Ultra-embedded can disable them all, but other than that i think we should not make it too finegrained as a lot of tooling value is in the 'critical mass' that tracepoints have achieved. The power events tracepoints are most useful when combined with scheduling events, etc.

Ingo

#23 lore raw

Re: [PATCH 11/18] i915: Provide config option for enabling tracepoints

In reply to Jan Kara

Out of curiosity what motivated this patch? When adding the tracepoints, I found the overhead of compiling in but not enabling them to be insignificant, i.e. nearly unmeasurable in throughput benchmarks, so didn't believe it warranted a config option. Especially one that advises people to turn off what may be a useful aid in desktop systems.

Also is TRACER the right name, that would seem to confuse the option with a standalone tracer as opposed to simply enabling tracepoints. -ickle

Signature · 1 line
Chris Wilson, Intel Open Source Technology Centre
#18 lore raw

Re: [Cluster-devel] [PATCH 10/18] gfs2: Provide config option for enabling trace points

In reply to Jan Kara

Hi,

Now in the GFS2 -nmw git tree. Thanks,

Steve.

Quoted 35 lines · Jan Kara
---
 fs/gfs2/Kconfig      |    8 ++++++++
 fs/gfs2/trace_gfs2.h |    2 ++
 2 files changed, 10 insertions(+), 0 deletions(-)
fs/gfs2/Kconfig +8 -0
index 4dcddf8..872ced2 100644
@@ -38,3 +38,11 @@ config GFS2_FS_LOCKING_DLM
 	  Most users of GFS2 will require this. It provides the locking
 	  interface between GFS2 and the DLM, which is required to use GFS2
 	  in a cluster environment.
+
+config GFS2_TRACER
+	bool "GFS2 tracing"
+	depends on GFS2_FS && EVENT_TRACING
+	help
+	  Provide trace points in block allocation functions, locking, and
+	  journaling code.
+
fs/gfs2/trace_gfs2.h +2 -0
index 148d55c..5f4faf3 100644
@@ -1,5 +1,7 @@
 #undef TRACE_SYSTEM
+#undef TRACE_CONFIG
 #define TRACE_SYSTEM gfs2
+#define TRACE_CONFIG CONFIG_GFS2_TRACER
 
 #if !defined(_TRACE_GFS2_H) || defined(TRACE_HEADER_MULTI_READ)
 #define _TRACE_GFS2_H
#36 lore raw
In reply to Ingo Molnar
Quoted 19 lines · * Ingo Molnar ([email protected]) wrote:
Quoted 16 lines · Theodore Tso
Quoted 9 lines · Frederic Weisbecker

I don't know. Yeah this first looks like a good idea but once CONFIG_EVENT_TRACING is enabled, each tracepoint is a lightweight thing and induce a tiny overhead, probably hard to notice, and this is going to be even more the case after the jmp label optimization patches.

I liked the fact we had a general tracing kernel once the above config is selected. And we don't bother telling people that to use tool X you need CONFIG_EVENT_Y, and you need to rebuild your kernel, etc...

Indeed, a lot of the value of tracepoints goes away if people are compiling kernels without them and we need to get a special "tracing kernel" installed before we can debug a problem.

Quoted 8 lines
Quoted 2 lines

So I'd hope we can do the necessary optimization work so people don't feel it's necessary to enable or disable tracepoints by subsystem....

Yeah, agreed. Ultra-embedded can disable them all, but other than that i think we should not make it too finegrained as a lot of tooling value is in the 'critical mass' that tracepoints have achieved. The power events tracepoints are most useful when combined with scheduling events, etc.

We're in complete agreement here. When I considered if it was worth it to create such a per-tracepoint group compile-time disabling in the first place, I decided not to do it precisely due to the added-value that comes with the availability of system-wide tracepoints. And I think with the static jump patching, we are now at a point where the overhead is stunningly low.

Now, space-wise, the one thing I would consider appropriate as a compromise for small embedded systems would be to allow the TRACE_EVENT probes to be compiled as modules.

Thanks,

Mathieu

Signature · 4 lines
Mathieu Desnoyers
Operating System Efficiency R&D Consultant
EfficiOS Inc.
http://www.efficios.com
maintainer
#37 lore raw
Quoted 10 lines · Mathieu Desnoyers
Quoted 1 line · * Ingo Molnar ([email protected]) wrote:

We're in complete agreement here. When I considered if it was worth it to create such a per-tracepoint group compile-time disabling in the first place, I decided not to do it precisely due to the added-value that comes with the availability of system-wide tracepoints. And I think with the static jump patching, we are now at a point where the overhead is stunningly low.

Quoted 3 lines

Now, space-wise, the one thing I would consider appropriate as a compromise for small embedded systems would be to allow the TRACE_EVENT probes to be compiled as modules.

Yeah, I agree here. Hmm, I wonder if we could automate this. That is, we could now, create a module per trace system if it is so configured. It would move the functions that create, record and output the trace points in TRACE_EVENT() into a separate module. Then you just need to load the modules you want to trace (grouped by system).

We can make add kobjects to /sys so that udev loads them automatically for distros.

-- Steve

maintainer
#12 lore raw

Re: [PATCH 06/18] sched: Generate trace points only if scheduler tracing is enabled

In reply to Frederic Weisbecker
Quoted 7 lines · Frederic Weisbecker
Quoted 4 lines · Jan Kara
CC Ingo Molnar <[email protected]>
CC Peter Zijlstra <[email protected]>

---

Quoted 5 lines

Note this one is an exception.
Once tracing is enabled, we need the context switch tracer anyway to keep track of the pid:cmdline mappings.

Yes, the scheduling tracepoints are needed by several tracers. This must be enabled by all.

But then again, I'm thinking it would be nicer to find a way to lower the impact than just turning them off.

Perhaps only allow the individual disabling if CONFIG_EMBEDDED is set.

-- Steve

maintainer
#8 lore raw

Re: [PATCH 04/18] mac80211: Generate trace points only if api tracer enabled

In reply to Johannes Berg
Quoted 6 lines · Johannes Berg
Quoted 2 lines · Jan Kara

You kinda missed something there, this patch doesn't explain to me why and it's all I ever got to see :)

This patch set is about fine grained tuning of what tracepoints get enabled and which don't. I honestly think that this should only be permitted if CONFIG_EMBEDDED is set (if it should be permitted at all).

I would much rather find a way to lower the tracepoint footprint than to pick and choose what tracepoints get enabled.

-- Steve

maintainer
#19 lore raw

Re: [Cluster-devel] [PATCH 10/18] gfs2: Provide config option for enabling trace points

In reply to Steven Whitehouse
Quoted 4 lines · Steven Whitehouse

Hi,

Now in the GFS2 -nmw git tree. Thanks,

Note, this depends on patch 1 which we have not yet determined if it should be applied or not.

-- Steve

Quoted 45 lines

Steve.

Quoted 28 lines · Jan Kara
---
 fs/gfs2/Kconfig      |    8 ++++++++
 fs/gfs2/trace_gfs2.h |    2 ++
 2 files changed, 10 insertions(+), 0 deletions(-)
fs/gfs2/Kconfig +8 -0
index 4dcddf8..872ced2 100644
@@ -38,3 +38,11 @@ config GFS2_FS_LOCKING_DLM
 	  Most users of GFS2 will require this. It provides the locking
 	  interface between GFS2 and the DLM, which is required to use GFS2
 	  in a cluster environment.
+
+config GFS2_TRACER
+	bool "GFS2 tracing"
+	depends on GFS2_FS && EVENT_TRACING
+	help
+	  Provide trace points in block allocation functions, locking, and
+	  journaling code.
+
fs/gfs2/trace_gfs2.h +0 -0
index 148d55c..5f4faf3 100644

fs/gfs2/trace_gfs2.h line 7

Quoted 7 lines
fs/gfs2/trace_gfs2.h +2 -0
@@ -1,5 +1,7 @@
 #undef TRACE_SYSTEM
+#undef TRACE_CONFIG
 #define TRACE_SYSTEM gfs2
+#define TRACE_CONFIG CONFIG_GFS2_TRACER
 
 #if !defined(_TRACE_GFS2_H) || defined(TRACE_HEADER_MULTI_READ)
 #define _TRACE_GFS2_H

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/

#13 lore raw

Re: [PATCH 06/18] sched: Generate trace points only if scheduler tracing is enabled

In reply to Steven Rostedt
Quoted 14 lines · Steven Rostedt
Quoted 7 lines · Frederic Weisbecker
Quoted 4 lines · Jan Kara
CC Ingo Molnar <[email protected]>
CC Peter Zijlstra <[email protected]>

---

Quoted 5 lines

Note this one is an exception.
Once tracing is enabled, we need the context switch tracer anyway to keep track of the pid:cmdline mappings.

Quoted 7 lines

Yes, the scheduling tracepoints are needed by several tracers. This must be enabled by all.

But then again, I'm thinking it would be nicer to find a way to lower the impact than just turning them off.

Perhaps only allow the individual disabling if CONFIG_EMBEDDED is set.

Yeah agreed!

#20 lore raw

Re: [Cluster-devel] [PATCH 10/18] gfs2: Provide config option for enabling trace points

In reply to Steven Rostedt

Hi,

Quoted 11 lines · Steven Rostedt
Quoted 4 lines · Steven Whitehouse

Hi,

Now in the GFS2 -nmw git tree. Thanks,

Note, this depends on patch 1 which we have not yet determined if it should be applied or not.

-- Steve

Sorry, I think I misread the initial message. I can roll it out again if required. I did a compile test in both states though and it seemed to work for me,

Steve.

maintainer
#21 lore raw

Re: [Cluster-devel] [PATCH 10/18] gfs2: Provide config option for enabling trace points

Quoted 9 lines · Steven Whitehouse

Hi,

Quoted 6 lines · Steven Rostedt
Quoted 4 lines · Steven Whitehouse

Hi,

Now in the GFS2 -nmw git tree. Thanks,

Quoted 9 lines
Quoted 5 lines

Note, this depends on patch 1 which we have not yet determined if it should be applied or not.

-- Steve

Sorry, I think I misread the initial message. I can roll it out again if required. I did a compile test in both states though and it seemed to work for me,

No problem, I'm just saying I believe without the first patch, this is a nop. That is, both states have the same result. The trace events stay in.

-- Steve

author reviewer
#38 lore raw
In reply to Frederic Weisbecker
Quoted 18 lines · Frederic Weisbecker
Quoted 15 lines · Jan Kara

Hi,

currently, when one tracer is selected, most of tracepoints for other
tracers also gets pulled into the kernel. So for example it's not possible to enable BLK_DEV_IO_TRACE without polluting slab allocation paths with tracepoint checks (see changelog of patch 01). This patch set adds a possibility for each set of trace points to be compile-enabled separately.
The first patch contains the necessary magic in linux/tracepoint.h. Other
patches just tell tracing framework about correspoding config options and possibly introduce them if they did not exist before.
The patches in this patch set are actually completely independent so
they can be merged via respective subsystem trees. But changes are rather tiny so I don't expect much conflicts...

Quoted 1 line

Honza

Quoted 7 lines

(Adding more people in Cc)

I don't know. Yeah this first looks like a good idea but once CONFIG_EVENT_TRACING is enabled, each tracepoint is a lightweight thing and induce a tiny overhead, probably hard to notice, and this is going to be even more the case after the jmp label optimization patches.

Sorry for replying late, I was on vacation. My motivation was that we
wanted BLK_DEV_IO_TRACE enabled in all our distro kernels but there is a concern that this could have some impact on performance especially in SLAB allocator due to more icache pressure or so. This is not completely bogus concern if you look at bloat-o-meter output. For example:

function                                     old     new   delta
kmem_cache_alloc                             542     768    +226

But looking at the disassembly now, I can see that the difference in
inline code is actually only ~40 bytes (on x86_64) - so that's about 7%. Not a huge deal but still noticeable.

Quoted 4 lines

I liked the fact we had a general tracing kernel once the above config is selected. And we don't bother telling people that to use tool X you need CONFIG_EVENT_Y, and you need to rebuild your kernel, etc...

OK, I understand this. I guess I should go and measure whether disabling
tracepoints really makes some performance difference or not.

Honza

Signature · 2 lines
Jan Kara <[email protected]>
SUSE Labs, CR
author reviewer
#3 lore raw

Re: [PATCH 01/18] trace: Allow <linux/tracepoint.h> to create empty tracepoints

In reply to Steven Rostedt
Quoted 1 line · Steven Rostedt

And I thought I was nasty with the CPP macros ;-)

Yeah, this is the darkest magic I've ever conceived with CPP ;)

...

Quoted 7 lines
Quoted 7 lines
include/linux/tracepoint.h +3 -4
-#define DEFINE_TRACE_FN(name, reg, unreg)
-#define DEFINE_TRACE(name)
-#define EXPORT_TRACEPOINT_SYMBOL_GPL(name)
-#define EXPORT_TRACEPOINT_SYMBOL(name)
+#define DEFINE_TRACE_FN_0(name, reg, unreg)
+#define DEFINE_TRACE_0(name)
+#define EXPORT_TRACEPOINT_SYMBOL_GPL_0(name)
Quoted 8 lines

include/linux/tracepoint.h extern void tracepoint_update_probe_range(struct tracepoint *begin, · line 119

Quoted 5 lines
include/linux/tracepoint.h +5 -0
+#define EXPORT_TRACEPOINT_SYMBOL_0(name)
+
+/*
+ * Below two-level macro magic is really needed to propely expand TRACE_CONFIG
+ * macro to 0 or 1 in the end

This is a really lame comment. There should be almost as much comments as code when doing CPP trickery like this.

OK, I'll expand it with a bit of CPP theory about argument expansion.

Quoted 30 lines
Quoted 30 lines

+ */

include/linux/tracepoint.h +29 -0
+#define __DECLARE_TRACE(config, name, proto, args) \
+		DECLARE_TRACE_##config(name, PARAMS(proto), PARAMS(args))
+#define __DEFINE_TRACE_FN(config, name, reg, unreg) \
+			DEFINE_TRACE_FN_##config(name, reg, unreg)
+#define __DEFINE_TRACE(config, name) DEFINE_TRACE_##config(name)
+#define __EXPORT_TRACEPOINT_SYMBOL_GPL(config, name) \
+			EXPORT_TRACEPOINT_SYMBOL_GPL_##config(name)
+#define __EXPORT_TRACEPOINT_SYMBOL(config, name) \
+			EXPORT_TRACEPOINT_SYMBOL_##config(name)
+
+#define _DECLARE_TRACE(config, name, proto, args) \
+		__DECLARE_TRACE(config, name, PARAMS(proto), PARAMS(args))
+#define _DEFINE_TRACE_FN(config, name, reg, unreg) \
+			__DEFINE_TRACE_FN(config, name, reg, unreg)
+#define _DEFINE_TRACE(config, name) __DEFINE_TRACE(config, name)
+#define _EXPORT_TRACEPOINT_SYMBOL_GPL(config, name) \
+			__EXPORT_TRACEPOINT_SYMBOL_GPL(config, name)
+#define _EXPORT_TRACEPOINT_SYMBOL(config, name) \
+			__EXPORT_TRACEPOINT_SYMBOL(config, name)
+
+#define DECLARE_TRACE(name, proto, args) \
+		_DECLARE_TRACE(TRACE_CONFIG, name, PARAMS(proto), PARAMS(args))
+#define DEFINE_TRACE_FN(name, reg, unreg) \
+			_DEFINE_TRACE_FN(TRACE_CONFIG, name, reg, unreg)
+#define DEFINE_TRACE(name) _DEFINE_TRACE(TRACE_CONFIG, name)
+#define EXPORT_TRACEPOINT_SYMBOL_GPL(name) \
+			_EXPORT_TRACEPOINT_SYMBOL_GPL(TRACE_CONFIG, name)
+#define EXPORT_TRACEPOINT_SYMBOL(name) \
+			_EXPORT_TRACEPOINT_SYMBOL(TRACE_CONFIG, name)

...

Quoted 9 lines
Quoted 9 lines

/*
+ * The two chunks below are out of include file ifdef protection because
+ * we want to be able to define TRACE_CONFIG even before second or even
+ * later include of linux/tracepoint.h.
+ */
+/*
+ * Make tracepoints which are not converted to a new method of enabling
+ * always compiled in
+ */

Quoted 8 lines

include/linux/tracepoint.h static inline void tracepoint_synchronize_unregister(void) · line 215

Quoted 3 lines
include/linux/tracepoint.h +3 -0
+#ifndef TRACE_CONFIG
+#define TRACE_CONFIG 1
+#endif

Hmm, We can have tracepoints in a header. Would this still work if a header with a tracepoint was not converted but it was included in a file that was. Of course I haven't seen the other patches yet so I don't yet know what a conversion looks like.

Well, if TRACE_CONFIG is not defined while the header is included,
everything is fine. If TRACE_CONFIG would be defined, then it means that TRACE_SYSTEM is defined as well (I tried to define them at the same place) and thus either tracepoints belong to the same system - again fine - or they belong to a different system. But then the header would redefine TRACE_SYSTEM which would subsequently break the file which included the header. So what I do should work, unless TRACE_SYSTEM is already broken...
Maybe I can expand the reasoning in the comment.

Honza

Signature · 2 lines
Jan Kara <[email protected]>
SUSE Labs, CR
#39 lore raw
In reply to Jan Kara
Quoted 38 lines · Jan Kara
Quoted 18 lines · Frederic Weisbecker
Quoted 15 lines · Jan Kara

Hi,

currently, when one tracer is selected, most of tracepoints for other
tracers also gets pulled into the kernel. So for example it's not possible to enable BLK_DEV_IO_TRACE without polluting slab allocation paths with tracepoint checks (see changelog of patch 01). This patch set adds a possibility for each set of trace points to be compile-enabled separately.
The first patch contains the necessary magic in linux/tracepoint.h. Other
patches just tell tracing framework about correspoding config options and possibly introduce them if they did not exist before.
The patches in this patch set are actually completely independent so
they can be merged via respective subsystem trees. But changes are rather tiny so I don't expect much conflicts...

Quoted 1 line

Honza

Quoted 7 lines

(Adding more people in Cc)

I don't know. Yeah this first looks like a good idea but once CONFIG_EVENT_TRACING is enabled, each tracepoint is a lightweight thing and induce a tiny overhead, probably hard to notice, and this is going to be even more the case after the jmp label optimization patches.

Sorry for replying late, I was on vacation. My motivation was that we
wanted BLK_DEV_IO_TRACE enabled in all our distro kernels but there is a concern that this could have some impact on performance especially in SLAB allocator due to more icache pressure or so. This is not completely bogus concern if you look at bloat-o-meter output. For example:

function                                     old     new   delta
kmem_cache_alloc                             542     768    +226

But looking at the disassembly now, I can see that the difference in
inline code is actually only ~40 bytes (on x86_64) - so that's about 7%. Not a huge deal but still noticeable.

Quoted 6 lines
Quoted 4 lines

I liked the fact we had a general tracing kernel once the above config is selected. And we don't bother telling people that to use tool X you need CONFIG_EVENT_Y, and you need to rebuild your kernel, etc...

OK, I understand this. I guess I should go and measure whether disabling
tracepoints really makes some performance difference or not.

If you do so, please try with with the jmp label patches:
http://lwn.net/Articles/379776/