Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1436042

[for-next][PATCH 09/12] tracing: Show the preempt count of when the event was called

From Steven Rostedt <rostedt@goodmis.org>
Newsgroups linux.kernel
Subject [for-next][PATCH 09/12] tracing: Show the preempt count of when the event was called
Date 2016-07-03 22:40 +0200
Message-ID <rQWlj-4MM-19@gated-at.bofh.it> (permalink)
References <rQWlj-4MM-3@gated-at.bofh.it>
Organization linux.* mail to news gateway

Show all headers | View raw


From: "Steven Rostedt (Red Hat)" <rostedt@goodmis.org>

Because tracepoint callbacks are done with preemption enabled, the trace
events are always called with preempt disable due to the
rcu_read_lock_sched_notrace() in __DO_TRACE(). This causes the preempt count
shown in the recorded trace event to be inaccurate. It is always one more
that what the preempt_count was when the tracepoint was called.

If CONFIG_PREEMPT is enabled, subtract 1 from the preempt_count before
recording it in the trace buffer.

Link: http://lkml.kernel.org/r/20160525132537.GA10808@linutronix.de

Reported-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
Signed-off-by: Steven Rostedt <rostedt@goodmis.org>
---
 kernel/trace/trace_events.c | 8 ++++++++
 1 file changed, 8 insertions(+)

diff --git a/kernel/trace/trace_events.c b/kernel/trace/trace_events.c
index fd449eb138cf..03c0a48c3ac4 100644
--- a/kernel/trace/trace_events.c
+++ b/kernel/trace/trace_events.c
@@ -261,6 +261,14 @@ void *trace_event_buffer_reserve(struct trace_event_buffer *fbuffer,
 
 	local_save_flags(fbuffer->flags);
 	fbuffer->pc = preempt_count();
+	/*
+	 * If CONFIG_PREEMPT is enabled, then the tracepoint itself disables
+	 * preemption (adding one to the preempt_count). Since we are
+	 * interested in the preempt_count at the time the tracepoint was
+	 * hit, we need to subtract one to offset the increment.
+	 */
+	if (IS_ENABLED(CONFIG_PREEMPT))
+		fbuffer->pc--;
 	fbuffer->trace_file = trace_file;
 
 	fbuffer->event =
-- 
2.8.1

Back to linux.kernel | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

[for-next][PATCH 00/12] tracing: Updates for 4.8 Steven Rostedt <rostedt@goodmis.org> - 2016-07-03 22:40 +0200
  [for-next][PATCH 09/12] tracing: Show the preempt count of when the event was called Steven Rostedt <rostedt@goodmis.org> - 2016-07-03 22:40 +0200
  [for-next][PATCH 01/12] tracing: Make the pid filtering helper functions global Steven Rostedt <rostedt@goodmis.org> - 2016-07-03 22:40 +0200
  [for-next][PATCH 11/12] tracing: Skip more functions when doing stack tracing of events Steven Rostedt <rostedt@goodmis.org> - 2016-07-03 22:40 +0200
  [for-next][PATCH 04/12] tracing: Move pid_list write processing into its own function Steven Rostedt <rostedt@goodmis.org> - 2016-07-03 22:40 +0200
  [for-next][PATCH 12/12] tracing/function_graph: Fix filters for function_graph threshold Steven Rostedt <rostedt@goodmis.org> - 2016-07-03 22:40 +0200
  [for-next][PATCH 06/12] tracing: expose current->comm to [ku]probe events Steven Rostedt <rostedt@goodmis.org> - 2016-07-03 22:40 +0200
  [for-next][PATCH 02/12] tracing: Move filtered_pid helper functions into trace.c Steven Rostedt <rostedt@goodmis.org> - 2016-07-03 22:40 +0200
  [for-next][PATCH 03/12] tracing: Move the pid_list seq_file functions to be global Steven Rostedt <rostedt@goodmis.org> - 2016-07-03 22:40 +0200
  [for-next][PATCH 07/12] tracing: Choose static tp_printk buffer by explicit nesting count Steven Rostedt <rostedt@goodmis.org> - 2016-07-03 22:40 +0200
  [for-next][PATCH 08/12] tracing: Add trace_printk sample code Steven Rostedt <rostedt@goodmis.org> - 2016-07-03 22:40 +0200

csiph-web