[lttng-dev] [PATCH lttng-modules 2/2] Fix: tracing: Centralize preemptirq tracepoints (4.19)

Michael Jeanson mjeanson at efficios.com
Fri Sep 7 12:21:13 EDT 2018


See upstream commit:

  commit c3bc8fd637a9623f5c507bd18f9677effbddf584
  Author: Joel Fernandes (Google) <joel at joelfernandes.org>
  Date:   Mon Jul 30 15:24:23 2018 -0700

    tracing: Centralize preemptirq tracepoints and unify their usage

    This patch detaches the preemptirq tracepoints from the tracers and
    keeps it separate.

    Advantages:
    * Lockdep and irqsoff event can now run in parallel since they no longer
    have their own calls.

    * This unifies the usecase of adding hooks to an irqsoff and irqson
    event, and a preemptoff and preempton event.
      3 users of the events exist:
      - Lockdep
      - irqsoff and preemptoff tracers
      - irqs and preempt trace events

    The unification cleans up several ifdefs and makes the code in preempt
    tracer and irqsoff tracers simpler. It gets rid of all the horrific
    ifdeferry around PROVE_LOCKING and makes configuration of the different
    users of the tracepoints more easy and understandable. It also gets rid
    of the time_* function calls from the lockdep hooks used to call into
    the preemptirq tracer which is not needed anymore. The negative delta in
    lines of code in this patch is quite large too.

    In the patch we introduce a new CONFIG option PREEMPTIRQ_TRACEPOINTS
    as a single point for registering probes onto the tracepoints. With
    this,
    the web of config options for preempt/irq toggle tracepoints and its
    users becomes:

     PREEMPT_TRACER   PREEMPTIRQ_EVENTS  IRQSOFF_TRACER PROVE_LOCKING
           |                 |     \         |           |
           \    (selects)    /      \        \ (selects) /
          TRACE_PREEMPT_TOGGLE       ----> TRACE_IRQFLAGS
                          \                  /
                           \ (depends on)   /
                         PREEMPTIRQ_TRACEPOINTS

Signed-off-by: Michael Jeanson <mjeanson at efficios.com>
---
 .../events/lttng-module/preemptirq.h          | 37 ++++++++++++++++---
 1 file changed, 32 insertions(+), 5 deletions(-)

diff --git a/instrumentation/events/lttng-module/preemptirq.h b/instrumentation/events/lttng-module/preemptirq.h
index 4f9be85..2fc8117 100644
--- a/instrumentation/events/lttng-module/preemptirq.h
+++ b/instrumentation/events/lttng-module/preemptirq.h
@@ -12,6 +12,9 @@
 #include <asm/sections.h>
 #include <probes/lttng-tracepoint-event.h>
 
+/*
+ * The preemptirq probe is built when CONFIG_PREEMPTIRQ_EVENTS is defined.
+ */
 
 LTTNG_TRACEPOINT_EVENT_CLASS(preemptirq_template,
 
@@ -25,7 +28,19 @@ LTTNG_TRACEPOINT_EVENT_CLASS(preemptirq_template,
 	)
 )
 
-#ifndef CONFIG_PROVE_LOCKING
+/*
+ * Tracing of irq enable / disable events is enabled
+ *   on >= 4.19 when CONFIG_TRACE_IRQFLAGS is defined.
+ *   on previous kernels when CONFIG_PROVE_LOCKING is NOT defined.
+ */
+#if defined(CONFIG_TRACE_IRQFLAGS)
+#define LTTNG_TRACE_IRQ
+#elif (LINUX_VERSION_CODE < KERNEL_VERSION(4,19,0) && \
+	!defined(CONFIG_PROVE_LOCKING))
+#define LTTNG_TRACE_IRQ
+#endif
+
+#ifdef LTTNG_TRACE_IRQ
 LTTNG_TRACEPOINT_EVENT_INSTANCE_MAP(preemptirq_template, irq_disable,
 
 	preemptirq_irq_disable,
@@ -43,9 +58,21 @@ LTTNG_TRACEPOINT_EVENT_INSTANCE_MAP(preemptirq_template, irq_enable,
 
 	TP_ARGS(ip, parent_ip)
 )
-#endif /* !CONFIG_PROVE_LOCKING */
-
-#ifdef CONFIG_DEBUG_PREEMPT
+#endif /* LTTNG_TRACE_IRQ */
+
+/*
+ * Tracing of preempt enable / disable events is enabled
+ *   on >= 4.19 when CONFIG_TRACE_PREEMPT_TOGGLE is defined.
+ *   on previous kernels when CONFIG_DEBUG_PREEMPT is defined.
+ */
+#if defined(CONFIG_TRACE_PREEMPT_TOGGLE)
+#define LTTNG_TRACE_PREEMPT
+#elif (LINUX_VERSION_CODE < KERNEL_VERSION(4,19,0) && \
+	defined(CONFIG_DEBUG_PREEMPT))
+#define LTTNG_TRACE_PREEMPT
+#endif
+
+#ifdef LTTNG_TRACE_PREEMPT
 LTTNG_TRACEPOINT_EVENT_INSTANCE_MAP(preemptirq_template, preempt_disable,
 
 	preemptirq_preempt_disable,
@@ -63,7 +90,7 @@ LTTNG_TRACEPOINT_EVENT_INSTANCE_MAP(preemptirq_template, preempt_enable,
 
 	TP_ARGS(ip, parent_ip)
 )
-#endif /* CONFIG_DEBUG_PREEMPT */
+#endif /* LTTNG_TRACE_PREEMPT */
 
 #endif /* LTTNG_TRACE_PREEMPTIRQ_H */
 
-- 
2.17.1



More information about the lttng-dev mailing list