Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752697AbdLDJrE (ORCPT ); Mon, 4 Dec 2017 04:47:04 -0500 Received: from usa-sjc-mx-foss1.foss.arm.com ([217.140.101.70]:60826 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751156AbdLDJrD (ORCPT ); Mon, 4 Dec 2017 04:47:03 -0500 From: Patrick Bellasi To: linux-kernel@vger.kernel.org Cc: Ingo Molnar , Peter Zijlstra , Dietmar Eggemann , Joel Fernandes , Steven Rostedt , Linux-kernel@vger.kernel.org Subject: [PATCH] tracing: Fix trace_preempt_{on,off} for !CONFIG_DEBUG_PREEMPT builds Date: Mon, 4 Dec 2017 09:46:42 +0000 Message-Id: <20171204094642.6901-1-patrick.bellasi@arm.com> X-Mailer: git-send-email 2.14.1 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 3457 Lines: 96 The new preempt enable/disable events introduced by: d59158162 tracing: Add support for preempt and irq enable/disable events are defined only for CONFIG_DEBUG_PREEMPT kernels when the CONFIG_PREEMPTIRQ_EVENTS support, introduced by the above patch, is enabled. These events are generated within by trace_preempt_{on,off} calls, which are part of the the "Preemption-off Latency Tracer" (CONFIG_PREEMPT_TRACER). Currently these calls are (correctly) generated on CONFIG_PREEMPT_TRACER even when the kernel is !CONFIG_DEBUG_PREEMPT configured. Thus leading to an undefined reference to the new trace events. Let's ensure that we always have an (eventually) empty definition of the events for CONFIG_PREEMPTIRQ_EVENTS kernels. This patch will ensure that the additional preempt enabled/disable events are generated only when we have both: CONFIG_PREEMPT_TRACER && CONFIG_DEBUG_PREEMPT Signed-off-by: Patrick Bellasi Reviewed-by: Dietmar Eggemann Reviewed-by: Alessio Balsini Cc: Steven Rostedt Cc: Ingo Molnar Cc: Joel Fernandes Cc: Linux-kernel@vger.kernel.org --- Fix kernel compilation for this configuration: !CONFIG_DEBUG_PREEMPT && CONFIG_PREEMPT_TRACER To reproduce, e.g. 1. make defconfig 2. add: CONFIG_PREEMPTIRQ_EVENTS=y CONFIG_PREEMPT_TRACER=y 3. make kernel/trace/trace_irqsoff.o For sake of consistency, this patch adds a default empty definition of all the new trace events whenever CONFIG_PREEMPTIRQ_EVENTS is enabled but the specific event's requirements are not satisfied. This is complementary to the default empty definitions provided for the !CONFIG_PREEMPTIRQ_EVENTS case. --- include/trace/events/preemptirq.h | 10 ++++++++++ kernel/trace/trace_irqsoff.c | 3 +-- 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/include/trace/events/preemptirq.h b/include/trace/events/preemptirq.h index f5024c560d8f..500ad0a221d5 100644 --- a/include/trace/events/preemptirq.h +++ b/include/trace/events/preemptirq.h @@ -40,6 +40,11 @@ DEFINE_EVENT(preemptirq_template, irq_disable, DEFINE_EVENT(preemptirq_template, irq_enable, TP_PROTO(unsigned long ip, unsigned long parent_ip), TP_ARGS(ip, parent_ip)); +#else +#define trace_irq_disable(...) +#define trace_irq_enable(...) +#define trace_irq_disable_rcuidle(...) +#define trace_irq_enable_rcuidle(...) #endif #ifdef CONFIG_DEBUG_PREEMPT @@ -50,6 +55,11 @@ DEFINE_EVENT(preemptirq_template, preempt_disable, DEFINE_EVENT(preemptirq_template, preempt_enable, TP_PROTO(unsigned long ip, unsigned long parent_ip), TP_ARGS(ip, parent_ip)); +#else +#define trace_preempt_disable(...) +#define trace_preempt_enable(...) +#define trace_preempt_disable_rcuidle(...) +#define trace_preempt_enable_rcuidle(...) #endif #endif /* _TRACE_PREEMPTIRQ_H */ diff --git a/kernel/trace/trace_irqsoff.c b/kernel/trace/trace_irqsoff.c index 03ecb4465ee4..9d62e5f30d58 100644 --- a/kernel/trace/trace_irqsoff.c +++ b/kernel/trace/trace_irqsoff.c @@ -848,8 +848,7 @@ inline void print_irqtrace_events(struct task_struct *curr) } #endif -#if defined(CONFIG_PREEMPT_TRACER) || \ - (defined(CONFIG_DEBUG_PREEMPT) && defined(CONFIG_PREEMPTIRQ_EVENTS)) +#ifdef CONFIG_PREEMPT_TRACER void trace_preempt_on(unsigned long a0, unsigned long a1) { trace_preempt_enable_rcuidle(a0, a1); -- 2.14.1