From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752634AbdH2LK5 (ORCPT ); Tue, 29 Aug 2017 07:10:57 -0400 Received: from terminus.zytor.com ([65.50.211.136]:41497 "EHLO terminus.zytor.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751708AbdH2LK4 (ORCPT ); Tue, 29 Aug 2017 07:10:56 -0400 Date: Tue, 29 Aug 2017 04:06:14 -0700 From: tip-bot for Thomas Gleixner Message-ID: Cc: mingo@kernel.org, torvalds@linux-foundation.org, peterz@infradead.org, bp@alien8.de, hpa@zytor.com, rostedt@goodmis.org, tglx@linutronix.de, luto@kernel.org, linux-kernel@vger.kernel.org Reply-To: tglx@linutronix.de, hpa@zytor.com, bp@alien8.de, rostedt@goodmis.org, linux-kernel@vger.kernel.org, luto@kernel.org, torvalds@linux-foundation.org, mingo@kernel.org, peterz@infradead.org In-Reply-To: <20170828064956.593094539@linutronix.de> References: <20170828064956.593094539@linutronix.de> To: linux-tip-commits@vger.kernel.org Subject: [tip:x86/apic] x86/tracing: Introduce a static key for exception tracing Git-Commit-ID: 2feb1b316d48004d905278c02a55902cab0be8be X-Mailer: tip-git-log-daemon Robot-ID: Robot-Unsubscribe: Contact to get blacklisted from these emails MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain; charset=UTF-8 Content-Disposition: inline Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Commit-ID: 2feb1b316d48004d905278c02a55902cab0be8be Gitweb: http://git.kernel.org/tip/2feb1b316d48004d905278c02a55902cab0be8be Author: Thomas Gleixner AuthorDate: Mon, 28 Aug 2017 08:47:21 +0200 Committer: Ingo Molnar CommitDate: Tue, 29 Aug 2017 11:42:23 +0200 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 Cc: Andy Lutomirski Cc: Borislav Petkov Cc: Linus Torvalds Cc: Peter Zijlstra Cc: Steven Rostedt Link: http://lkml.kernel.org/r/20170828064956.593094539@linutronix.de Signed-off-by: Ingo Molnar --- arch/x86/include/asm/trace/common.h | 15 +++++++++++++++ arch/x86/include/asm/trace/exceptions.h | 4 +--- arch/x86/include/asm/trace/irq_vectors.h | 4 +--- arch/x86/kernel/tracepoint.c | 9 ++++++++- 4 files changed, 25 insertions(+), 7 deletions(-) diff --git a/arch/x86/include/asm/trace/common.h b/arch/x86/include/asm/trace/common.h new file mode 100644 index 0000000..b1eb7b1 --- /dev/null +++ b/arch/x86/include/asm/trace/common.h @@ -0,0 +1,15 @@ +#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) +#else +static inline bool trace_irqvectors_enabled(void) { return false; } +#endif + +#endif diff --git a/arch/x86/include/asm/trace/exceptions.h b/arch/x86/include/asm/trace/exceptions.h index 2422b14..960a5b5 100644 --- a/arch/x86/include/asm/trace/exceptions.h +++ b/arch/x86/include/asm/trace/exceptions.h @@ -5,9 +5,7 @@ #define _TRACE_PAGE_FAULT_H #include - -extern int trace_irq_vector_regfunc(void); -extern void trace_irq_vector_unregfunc(void); +#include DECLARE_EVENT_CLASS(x86_exceptions, diff --git a/arch/x86/include/asm/trace/irq_vectors.h b/arch/x86/include/asm/trace/irq_vectors.h index 32dd6a9..7825b44 100644 --- a/arch/x86/include/asm/trace/irq_vectors.h +++ b/arch/x86/include/asm/trace/irq_vectors.h @@ -5,9 +5,7 @@ #define _TRACE_IRQ_VECTORS_H #include - -extern int trace_irq_vector_regfunc(void); -extern void trace_irq_vector_unregfunc(void); +#include DECLARE_EVENT_CLASS(x86_irq_vector, diff --git a/arch/x86/kernel/tracepoint.c b/arch/x86/kernel/tracepoint.c index 1551513..dd4aa04 100644 --- a/arch/x86/kernel/tracepoint.c +++ b/arch/x86/kernel/tracepoint.c @@ -4,9 +4,11 @@ * Copyright (C) 2013 Seiji Aguchi * */ +#include +#include + #include #include -#include 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) {