[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <d4efd910035c5b5eaa9f54eea64f8fef2c33339d.1554234787.git.bristot@redhat.com>
Date: Tue, 2 Apr 2019 22:03:55 +0200
From: Daniel Bristot de Oliveira <bristot@...hat.com>
To: linux-kernel@...r.kernel.org
Cc: Steven Rostedt <rostedt@...dmis.org>,
Arnaldo Carvalho de Melo <acme@...nel.org>,
Ingo Molnar <mingo@...hat.com>,
Andy Lutomirski <luto@...nel.org>,
Thomas Gleixner <tglx@...utronix.de>,
Borislav Petkov <bp@...en8.de>,
Peter Zijlstra <peterz@...radead.org>,
"H. Peter Anvin" <hpa@...or.com>,
"Joel Fernandes (Google)" <joel@...lfernandes.org>,
Jiri Olsa <jolsa@...hat.com>,
Namhyung Kim <namhyung@...nel.org>,
Alexander Shishkin <alexander.shishkin@...ux.intel.com>,
Tommaso Cucinotta <tommaso.cucinotta@...tannapisa.it>,
Romulo Silva de Oliveira <romulo.deoliveira@...c.br>,
Clark Williams <williams@...hat.com>, x86@...nel.org
Subject: [RFC PATCH 3/7] trace: Optimize trace_get_context_bit()
trace_get_context_bit() and trace_recursive_lock() uses the same logic,
but the second reads the per_cpu variable only once.
Uses the trace_recursive_lock()'s logic in trace_get_context_bit().
Signed-off-by: Daniel Bristot de Oliveira <bristot@...hat.com>
Cc: Steven Rostedt <rostedt@...dmis.org>
Cc: Arnaldo Carvalho de Melo <acme@...nel.org>
Cc: Ingo Molnar <mingo@...hat.com>
Cc: Andy Lutomirski <luto@...nel.org>
Cc: Thomas Gleixner <tglx@...utronix.de>
Cc: Borislav Petkov <bp@...en8.de>
Cc: Peter Zijlstra <peterz@...radead.org>
Cc: "H. Peter Anvin" <hpa@...or.com>
Cc: "Joel Fernandes (Google)" <joel@...lfernandes.org>
Cc: Jiri Olsa <jolsa@...hat.com>
Cc: Namhyung Kim <namhyung@...nel.org>
Cc: Alexander Shishkin <alexander.shishkin@...ux.intel.com>
Cc: Tommaso Cucinotta <tommaso.cucinotta@...tannapisa.it>
Cc: Romulo Silva de Oliveira <romulo.deoliveira@...c.br>
Cc: Clark Williams <williams@...hat.com>
Cc: linux-kernel@...r.kernel.org
Cc: x86@...nel.org
---
kernel/trace/trace.h | 19 ++++++-------------
1 file changed, 6 insertions(+), 13 deletions(-)
diff --git a/kernel/trace/trace.h b/kernel/trace/trace.h
index dad2f0cd7208..09318748fab8 100644
--- a/kernel/trace/trace.h
+++ b/kernel/trace/trace.h
@@ -635,20 +635,13 @@ enum {
static __always_inline int trace_get_context_bit(void)
{
- int bit;
-
- if (in_interrupt()) {
- if (in_nmi())
- bit = TRACE_CTX_NMI;
+ unsigned long pc = preempt_count();
- else if (in_irq())
- bit = TRACE_CTX_IRQ;
- else
- bit = TRACE_CTX_SOFTIRQ;
- } else
- bit = TRACE_CTX_NORMAL;
-
- return bit;
+ if (pc & (NMI_MASK | HARDIRQ_MASK | SOFTIRQ_OFFSET))
+ return pc & NMI_MASK ? TRACE_CTX_NMI :
+ pc & HARDIRQ_MASK ? TRACE_CTX_IRQ : TRACE_CTX_SOFTIRQ;
+ else
+ return TRACE_CTX_NORMAL;
}
static __always_inline int trace_test_and_set_recursion(int start, int max)
--
2.20.1
Powered by blists - more mailing lists