lkml.org 
[lkml]   [2019]   [Apr]   [2]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
From
Subject[RFC PATCH 7/7] events: Use early task context tracking if available
Date
Use the early task context tracking to detect the current context,
if the arch supports it.

Signed-off-by: Daniel Bristot de Oliveira <bristot@redhat.com>
Cc: Steven Rostedt <rostedt@goodmis.org>
Cc: Arnaldo Carvalho de Melo <acme@kernel.org>
Cc: Ingo Molnar <mingo@redhat.com>
Cc: Andy Lutomirski <luto@kernel.org>
Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: Borislav Petkov <bp@alien8.de>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: "H. Peter Anvin" <hpa@zytor.com>
Cc: "Joel Fernandes (Google)" <joel@joelfernandes.org>
Cc: Jiri Olsa <jolsa@redhat.com>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
Cc: Tommaso Cucinotta <tommaso.cucinotta@santannapisa.it>
Cc: Romulo Silva de Oliveira <romulo.deoliveira@ufsc.br>
Cc: Clark Williams <williams@redhat.com>
Cc: linux-kernel@vger.kernel.org
Cc: x86@kernel.org
---
kernel/events/internal.h | 13 +++++++++++++
1 file changed, 13 insertions(+)

diff --git a/kernel/events/internal.h b/kernel/events/internal.h
index 241a2318bfdc..8e4215f8cb93 100644
--- a/kernel/events/internal.h
+++ b/kernel/events/internal.h
@@ -219,6 +219,18 @@ enum {
TRACE_CTX_MAX
};

+#ifdef ARCH_HAS_TASK_CONTEXT
+static __always_inline int trace_get_context_bit(void)
+{
+ unsigned long tc = this_cpu_read(task_context);
+
+ if (tc)
+ return tc & TASK_CTX_NMI ? TRACE_CTX_NMI :
+ tc & TASK_CTX_IRQ ? TRACE_CTX_IRQ : TRACE_CTX_SOFTIRQ;
+ else
+ return TRACE_CTX_NORMAL;
+}
+#else /* ARCH_HAS_TASK_CONTEXT */
static __always_inline int trace_get_context_bit(void)
{
unsigned long pc = preempt_count();
@@ -229,6 +241,7 @@ static __always_inline int trace_get_context_bit(void)
else
return TRACE_CTX_NORMAL;
}
+#endif /* ARCH_HAS_TASK_CONTEXT */

static inline int get_recursion_context(int *recursion)
{
--
2.20.1
\
 
 \ /
  Last update: 2019-04-02 22:04    [W:1.859 / U:0.004 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site