diff options
author | Thomas Gleixner <tglx@linutronix.de> | 2017-08-28 08:47:21 +0200 |
---|---|---|
committer | Ingo Molnar <mingo@kernel.org> | 2017-08-29 11:42:23 +0200 |
commit | 2feb1b316d48004d905278c02a55902cab0be8be (patch) | |
tree | e34696f4142dfd9366473a96612398da48bce30d /arch/x86/kernel/tracepoint.c | |
parent | x86/boot: Move EISA setup to a separate file (diff) | |
download | linux-2feb1b316d48004d905278c02a55902cab0be8be.tar.xz linux-2feb1b316d48004d905278c02a55902cab0be8be.zip |
x86/tracing: Introduce a static key for exception tracing
Switching the IDT just for avoiding tracepoints creates a completely
impenetrable macro/inline/ifdef mess.
There is no point in avoiding tracepoints for most of the traps/exceptions.
For the more expensive tracepoints, like pagefaults, this can be handled with
an explicit static key.
Preparatory patch to remove the tracing IDT.
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/20170828064956.593094539@linutronix.de
Signed-off-by: Ingo Molnar <mingo@kernel.org>
Diffstat (limited to 'arch/x86/kernel/tracepoint.c')
-rw-r--r-- | arch/x86/kernel/tracepoint.c | 9 |
1 files changed, 8 insertions, 1 deletions
diff --git a/arch/x86/kernel/tracepoint.c b/arch/x86/kernel/tracepoint.c index 15515132bf0d..dd4aa04bb95c 100644 --- a/arch/x86/kernel/tracepoint.c +++ b/arch/x86/kernel/tracepoint.c @@ -4,9 +4,11 @@ * Copyright (C) 2013 Seiji Aguchi <seiji.aguchi@hds.com> * */ +#include <linux/jump_label.h> +#include <linux/atomic.h> + #include <asm/hw_irq.h> #include <asm/desc.h> -#include <linux/atomic.h> atomic_t trace_idt_ctr = ATOMIC_INIT(0); struct desc_ptr trace_idt_descr = { NR_VECTORS * 16 - 1, @@ -15,6 +17,7 @@ struct desc_ptr trace_idt_descr = { NR_VECTORS * 16 - 1, /* No need to be aligned, but done to keep all IDTs defined the same way. */ gate_desc trace_idt_table[NR_VECTORS] __page_aligned_bss; +DEFINE_STATIC_KEY_FALSE(trace_irqvectors_key); static int trace_irq_vector_refcount; static DEFINE_MUTEX(irq_vector_mutex); @@ -36,6 +39,8 @@ static void switch_idt(void *arg) int trace_irq_vector_regfunc(void) { + static_branch_inc(&trace_irqvectors_key); + mutex_lock(&irq_vector_mutex); if (!trace_irq_vector_refcount) { set_trace_idt_ctr(1); @@ -49,6 +54,8 @@ int trace_irq_vector_regfunc(void) void trace_irq_vector_unregfunc(void) { + static_branch_dec(&trace_irqvectors_key); + mutex_lock(&irq_vector_mutex); trace_irq_vector_refcount--; if (!trace_irq_vector_refcount) { |