[patch 16/41] x86/tracing: Disentangle pagefault and resched IPI tracing key
From: Thomas Gleixner
Date: Fri Aug 25 2017 - 07:01:43 EST
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@xxxxxxxxxxxxx>
---
arch/x86/include/asm/trace/common.h | 15 ++++++++-------
arch/x86/include/asm/trace/exceptions.h | 6 ++++--
arch/x86/include/asm/trace/irq_vectors.h | 22 ++++++++++++++++------
arch/x86/kernel/smp.c | 4 ++--
arch/x86/kernel/tracepoint.c | 27 ++++++++++++++++++++++-----
arch/x86/mm/fault.c | 2 +-
6 files changed, 53 insertions(+), 23 deletions(-)
Index: b/arch/x86/include/asm/trace/common.h
===================================================================
--- a/arch/x86/include/asm/trace/common.h
+++ b/arch/x86/include/asm/trace/common.h
@@ -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: b/arch/x86/include/asm/trace/exceptions.h
===================================================================
--- a/arch/x86/include/asm/trace/exceptions.h
+++ b/arch/x86/include/asm/trace/exceptions.h
@@ -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: b/arch/x86/include/asm/trace/irq_vectors.h
===================================================================
--- a/arch/x86/include/asm/trace/irq_vectors.h
+++ b/arch/x86/include/asm/trace/irq_vectors.h
@@ -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),
@@ -26,15 +29,22 @@ DECLARE_EVENT_CLASS(x86_irq_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
@@ -45,7 +55,7 @@ DEFINE_IRQ_VECTOR_EVENT(local_timer);
/*
* reschedule - called when entering/exiting a reschedule vector handler
*/
-DEFINE_IRQ_VECTOR_EVENT(reschedule);
+DEFINE_RESCHED_IPI_EVENT(reschedule);
/*
* spurious_apic - called when entering/exiting a spurious apic vector handler
Index: b/arch/x86/kernel/smp.c
===================================================================
--- a/arch/x86/kernel/smp.c
+++ b/arch/x86/kernel/smp.c
@@ -261,7 +261,7 @@ static void native_stop_other_cpus(int w
{
ack_APIC_irq();
- if (trace_irqvectors_enabled()) {
+ if (trace_resched_ipi_enabled()) {
/*
* scheduler_ipi() might call irq_enter() as well, but
* nested calls are fine.
@@ -273,7 +273,7 @@ static void native_stop_other_cpus(int w
inc_irq_stat(irq_resched_count);
scheduler_ipi();
- if (trace_irqvectors_enabled()) {
+ if (trace_resched_ipi_enabled()) {
trace_reschedule_exit(RESCHEDULE_VECTOR);
irq_exit();
}
Index: b/arch/x86/kernel/tracepoint.c
===================================================================
--- a/arch/x86/kernel/tracepoint.c
+++ b/arch/x86/kernel/tracepoint.c
@@ -10,15 +10,32 @@
#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: b/arch/x86/mm/fault.c
===================================================================
--- a/arch/x86/mm/fault.c
+++ b/arch/x86/mm/fault.c
@@ -1509,7 +1509,7 @@ do_page_fault(struct pt_regs *regs, unsi
*
* exception_{enter,exit}() contain all sorts of tracepoints.
*/
- if (trace_irqvectors_enabled())
+ if (trace_pagefault_enabled())
trace_page_fault_entries(address, regs, error_code);
prev_state = exception_enter();