x86/tracing: Disentangle pagefault and resched IPI tracing key
authorThomas Gleixner <tglx@linutronix.de>
Mon, 28 Aug 2017 06:47:33 +0000 (08:47 +0200)
committerIngo Molnar <mingo@kernel.org>
Tue, 29 Aug 2017 09:42:29 +0000 (11:42 +0200)
The pagefault and the resched IPI handler are the only ones where it is
worth to optimize the code further in case tracepoints are disabled. But it
makes no sense to have a single static key for both.

Seperate the static keys so the facilities are handled seperately.

Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Cc: Andy Lutomirski <luto@kernel.org>
Cc: Borislav Petkov <bp@alien8.de>
Cc: Linus Torvalds <torvalds@linux-foundation.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Steven Rostedt <rostedt@goodmis.org>
Link: http://lkml.kernel.org/r/20170828064957.536699116@linutronix.de
Signed-off-by: Ingo Molnar <mingo@kernel.org>
arch/x86/include/asm/trace/common.h
arch/x86/include/asm/trace/exceptions.h
arch/x86/include/asm/trace/irq_vectors.h
arch/x86/kernel/smp.c
arch/x86/kernel/tracepoint.c
arch/x86/mm/fault.c

index b1eb7b18ee8a76a90d12e664a4d82682629403e3..57c8da027d99238f03591a0ab4cfab53da9a03a7 100644 (file)
@@ -1,15 +1,16 @@
 #ifndef _ASM_TRACE_COMMON_H
 #define _ASM_TRACE_COMMON_H
 
-extern int trace_irq_vector_regfunc(void);
-extern void trace_irq_vector_unregfunc(void);
-
 #ifdef CONFIG_TRACING
-DECLARE_STATIC_KEY_FALSE(trace_irqvectors_key);
-#define trace_irqvectors_enabled()                     \
-       static_branch_unlikely(&trace_irqvectors_key)
+DECLARE_STATIC_KEY_FALSE(trace_pagefault_key);
+#define trace_pagefault_enabled()                      \
+       static_branch_unlikely(&trace_pagefault_key)
+DECLARE_STATIC_KEY_FALSE(trace_resched_ipi_key);
+#define trace_resched_ipi_enabled()                    \
+       static_branch_unlikely(&trace_resched_ipi_key)
 #else
-static inline bool trace_irqvectors_enabled(void) { return false; }
+static inline bool trace_pagefault_enabled(void) { return false; }
+static inline bool trace_resched_ipi_enabled(void) { return false; }
 #endif
 
 #endif
index 960a5b50ac3b50476063670c9b1a771a27f28f64..5665bf205b8d500c0e5d08fa11d213aefdae053f 100644 (file)
@@ -7,6 +7,9 @@
 #include <linux/tracepoint.h>
 #include <asm/trace/common.h>
 
+extern int trace_pagefault_reg(void);
+extern void trace_pagefault_unreg(void);
+
 DECLARE_EVENT_CLASS(x86_exceptions,
 
        TP_PROTO(unsigned long address, struct pt_regs *regs,
@@ -35,8 +38,7 @@ DEFINE_EVENT_FN(x86_exceptions, name,                         \
        TP_PROTO(unsigned long address, struct pt_regs *regs,   \
                 unsigned long error_code),                     \
        TP_ARGS(address, regs, error_code),                     \
-       trace_irq_vector_regfunc,                               \
-       trace_irq_vector_unregfunc);
+       trace_pagefault_reg, trace_pagefault_unreg);
 
 DEFINE_PAGE_FAULT_EVENT(page_fault_user);
 DEFINE_PAGE_FAULT_EVENT(page_fault_kernel);
index 7825b4426e7ee41192ec78e904c1e4ff81871383..a1bdc25b65070c618d580c225f27a53d4b1d4c46 100644 (file)
@@ -7,6 +7,9 @@
 #include <linux/tracepoint.h>
 #include <asm/trace/common.h>
 
+extern int trace_resched_ipi_reg(void);
+extern void trace_resched_ipi_unreg(void);
+
 DECLARE_EVENT_CLASS(x86_irq_vector,
 
        TP_PROTO(int vector),
@@ -24,17 +27,24 @@ DECLARE_EVENT_CLASS(x86_irq_vector,
        TP_printk("vector=%d", __entry->vector) );
 
 #define DEFINE_IRQ_VECTOR_EVENT(name)          \
+DEFINE_EVENT_FN(x86_irq_vector, name##_entry,  \
+       TP_PROTO(int vector),                   \
+       TP_ARGS(vector), NULL, NULL);           \
+DEFINE_EVENT_FN(x86_irq_vector, name##_exit,   \
+       TP_PROTO(int vector),                   \
+       TP_ARGS(vector), NULL, NULL);
+
+#define DEFINE_RESCHED_IPI_EVENT(name)         \
 DEFINE_EVENT_FN(x86_irq_vector, name##_entry,  \
        TP_PROTO(int vector),                   \
        TP_ARGS(vector),                        \
-       trace_irq_vector_regfunc,               \
-       trace_irq_vector_unregfunc);            \
+       trace_resched_ipi_reg,                  \
+       trace_resched_ipi_unreg);               \
 DEFINE_EVENT_FN(x86_irq_vector, name##_exit,   \
        TP_PROTO(int vector),                   \
        TP_ARGS(vector),                        \
-       trace_irq_vector_regfunc,               \
-       trace_irq_vector_unregfunc);
-
+       trace_resched_ipi_reg,                  \
+       trace_resched_ipi_unreg);
 
 /*
  * local_timer - called when entering/exiting a local timer interrupt
@@ -42,10 +52,17 @@ DEFINE_EVENT_FN(x86_irq_vector, name##_exit,        \
  */
 DEFINE_IRQ_VECTOR_EVENT(local_timer);
 
+/*
+ * The ifdef is required because that tracepoint macro hell emits tracepoint
+ * code in files which include this header even if the tracepoint is not
+ * enabled. Brilliant stuff that.
+ */
+#ifdef CONFIG_SMP
 /*
  * reschedule - called when entering/exiting a reschedule vector handler
  */
-DEFINE_IRQ_VECTOR_EVENT(reschedule);
+DEFINE_RESCHED_IPI_EVENT(reschedule);
+#endif
 
 /*
  * spurious_apic - called when entering/exiting a spurious apic vector handler
index cfe865b85bc5368ee5b2499adf3c7a5bf4b65283..5c574dff4c1a00990c6e6d8e5d993cc2777c6c6f 100644 (file)
@@ -262,7 +262,7 @@ __visible void __irq_entry smp_reschedule_interrupt(struct pt_regs *regs)
        ack_APIC_irq();
        inc_irq_stat(irq_resched_count);
 
-       if (trace_irqvectors_enabled()) {
+       if (trace_resched_ipi_enabled()) {
                /*
                 * scheduler_ipi() might call irq_enter() as well, but
                 * nested calls are fine.
index 4cae92f1549505cbdafe5f991a8520e8521c48a3..c6636d1f60b933e3bb7eb46f181d15d369b73311 100644 (file)
 #include <asm/hw_irq.h>
 #include <asm/desc.h>
 
-DEFINE_STATIC_KEY_FALSE(trace_irqvectors_key);
+DEFINE_STATIC_KEY_FALSE(trace_pagefault_key);
 
-int trace_irq_vector_regfunc(void)
+int trace_pagefault_reg(void)
 {
-       static_branch_inc(&trace_irqvectors_key);
+       static_branch_inc(&trace_pagefault_key);
        return 0;
 }
 
-void trace_irq_vector_unregfunc(void)
+void trace_pagefault_unreg(void)
 {
-       static_branch_dec(&trace_irqvectors_key);
+       static_branch_dec(&trace_pagefault_key);
 }
+
+#ifdef CONFIG_SMP
+
+DEFINE_STATIC_KEY_FALSE(trace_resched_ipi_key);
+
+int trace_resched_ipi_reg(void)
+{
+       static_branch_inc(&trace_resched_ipi_key);
+       return 0;
+}
+
+void trace_resched_ipi_unreg(void)
+{
+       static_branch_dec(&trace_resched_ipi_key);
+}
+
+#endif
index 58d7b3a4ec2e5516c08dafe138e147e41c532658..f9bb6608f6f141d79e8eb2b0491c33a793465494 100644 (file)
@@ -1510,7 +1510,7 @@ do_page_fault(struct pt_regs *regs, unsigned long error_code)
        enum ctx_state prev_state;
 
        prev_state = exception_enter();
-       if (trace_irqvectors_enabled())
+       if (trace_pagefault_enabled())
                trace_page_fault_entries(address, regs, error_code);
 
        __do_page_fault(regs, error_code, address);