From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751908AbdJDQB5 (ORCPT ); Wed, 4 Oct 2017 12:01:57 -0400 Received: from bombadil.infradead.org ([65.50.211.133]:50733 "EHLO bombadil.infradead.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751219AbdJDQBz (ORCPT ); Wed, 4 Oct 2017 12:01:55 -0400 Date: Wed, 4 Oct 2017 18:01:51 +0200 From: Peter Zijlstra To: Joel Fernandes Cc: linux-kernel@vger.kernel.org, kernel-team@android.com, Steven Rostedt Subject: Re: [PATCH v7 2/2] tracing: Add support for preempt and irq enable/disable events Message-ID: <20171004160151.noficzcd4ef5ydml@hirez.programming.kicks-ass.net> References: <20170929212245.24168-1-joelaf@google.com> <20170929212245.24168-2-joelaf@google.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20170929212245.24168-2-joelaf@google.com> User-Agent: NeoMutt/20170609 (1.8.3) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, Sep 29, 2017 at 02:22:45PM -0700, Joel Fernandes wrote: > diff --git a/kernel/trace/trace_irqsoff.c b/kernel/trace/trace_irqsoff.c > index 0e3033c00474..515ac851841a 100644 > --- a/kernel/trace/trace_irqsoff.c > +++ b/kernel/trace/trace_irqsoff.c > @@ -16,6 +16,9 @@ > > #include "trace.h" > > +#define CREATE_TRACE_POINTS > +#include > + > #if defined(CONFIG_IRQSOFF_TRACER) || defined(CONFIG_PREEMPT_TRACER) > static struct trace_array *irqsoff_trace __read_mostly; > static int tracer_enabled __read_mostly; > @@ -776,27 +779,60 @@ static inline void tracer_preempt_on(unsigned long a0, unsigned long a1) { } > static inline void tracer_preempt_off(unsigned long a0, unsigned long a1) { } > #endif > > +/* > + * trace_hardirqs_off can be called even when IRQs are already off. In fact it must be.. otherwise you'll get a complaint. > It is > + * pointless and inconsistent with trace_preempt_enable and > + * trace_preempt_disable to trace this, lets prevent double counting it with a > + * per-cpu variable. Also reuse the per-cpu variable for other trace_hardirqs_* > + * functions since we already define it. Lockdep ignores redundant calls. But I'm not entirely sure what the above is trying to say. > + */ > +static DEFINE_PER_CPU(int, tracing_irq_cpu); > + > #if defined(CONFIG_TRACE_IRQFLAGS) && !defined(CONFIG_PROVE_LOCKING) > void trace_hardirqs_on(void) > { > + if (!this_cpu_read(tracing_irq_cpu)) > + return; > + > + trace_irq_enable_rcuidle(CALLER_ADDR0, CALLER_ADDR1); > tracer_hardirqs_on(); > + > + this_cpu_write(tracing_irq_cpu, 0); > } > EXPORT_SYMBOL(trace_hardirqs_on); > > void trace_hardirqs_off(void) > { > + if (this_cpu_read(tracing_irq_cpu)) > + return; > + > + this_cpu_write(tracing_irq_cpu, 1); > + > + trace_irq_disable_rcuidle(CALLER_ADDR0, CALLER_ADDR1); > tracer_hardirqs_off(); > } > EXPORT_SYMBOL(trace_hardirqs_off); > > __visible void trace_hardirqs_on_caller(unsigned long caller_addr) > { > + if (!this_cpu_read(tracing_irq_cpu)) > + return; > + > + trace_irq_enable_rcuidle(CALLER_ADDR0, caller_addr); > tracer_hardirqs_on_caller(caller_addr); > + > + this_cpu_write(tracing_irq_cpu, 0); > } > EXPORT_SYMBOL(trace_hardirqs_on_caller); > > __visible void trace_hardirqs_off_caller(unsigned long caller_addr) > { > + if (this_cpu_read(tracing_irq_cpu)) > + return; > + > + this_cpu_write(tracing_irq_cpu, 1); > + > + trace_irq_disable_rcuidle(CALLER_ADDR0, caller_addr); > tracer_hardirqs_off_caller(caller_addr); > } > EXPORT_SYMBOL(trace_hardirqs_off_caller); lockdep implements the trace_hardirq_*() in terms of *_caller(). Would that make sense here?