mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Howard Cochran <hcochran@kernelspring.com>
To: linux-kernel@vger.kernel.org
Cc: Steven Rostedt <rostedt@goodmis.org>,
	Ingo Molnar <mingo@redhat.com>,
	Howard Cochran <cochran@lexmark.com>,
	Howard Cochran <hcochran@kernelspring.com>
Subject: [PATCH 2/5] tracing: Make stacktrace trigger affect the correct instance
Date: Fri, 15 Apr 2016 02:53:47 -0400	[thread overview]
Message-ID: <1460703230-13307-3-git-send-email-hcochran@kernelspring.com> (raw)
In-Reply-To: <1460703230-13307-1-git-send-email-hcochran@kernelspring.com>

Currently, the stacktrace trigger always dumps the stack into the top
level buffer, even if it was triggered within an instance. Fixed
by using the trace_array associated with the trace_event_file which
fired the trigger.

Signed-off-by: Howard Cochran <hcochran@kernelspring.com>
---
 kernel/trace/trace.c                | 21 +++++++++++++++++----
 kernel/trace/trace.h                |  2 ++
 kernel/trace/trace_events_trigger.c |  2 +-
 3 files changed, 20 insertions(+), 5 deletions(-)

diff --git a/kernel/trace/trace.c b/kernel/trace/trace.c
index a2f0b9f..5541517 100644
--- a/kernel/trace/trace.c
+++ b/kernel/trace/trace.c
@@ -1900,14 +1900,15 @@ void __trace_stack(struct trace_array *tr, unsigned long flags, int skip,
 }
 
 /**
- * trace_dump_stack - record a stack back trace in the trace buffer
+ * __trace_dump_stack - record a stack back trace in the given trace buffer
  * @skip: Number of functions to skip (helper handlers)
+ * @tr:   Which trace buffer (instance) to write to
  */
-void trace_dump_stack(int skip)
+void __trace_dump_stack(int skip, struct trace_array *tr)
 {
 	unsigned long flags;
 
-	if (tracing_disabled || tracing_selftest_running)
+	if (tracing_disabled || tr->buffer_disabled || tracing_selftest_running)
 		return;
 
 	local_save_flags(flags);
@@ -1917,10 +1918,22 @@ void trace_dump_stack(int skip)
 	 * this function.
 	 */
 	skip += 3;
-	__ftrace_trace_stack(global_trace.trace_buffer.buffer,
+	__ftrace_trace_stack(tr->trace_buffer.buffer,
 			     flags, skip, preempt_count(), NULL);
 }
 
+/**
+ * trace_dump_stack - record a stack back trace in the top-level trace buffer
+ * @skip: Number of functions to skip (helper handlers)
+ */
+void trace_dump_stack(int skip)
+{
+	/* This wrapper function deepens the stack one level */
+	skip += 1;
+
+	__trace_dump_stack(skip, &global_trace);
+}
+
 static DEFINE_PER_CPU(int, user_stack_count);
 
 void
diff --git a/kernel/trace/trace.h b/kernel/trace/trace.h
index ca4915f..00a5419 100644
--- a/kernel/trace/trace.h
+++ b/kernel/trace/trace.h
@@ -716,6 +716,8 @@ enum print_line_t print_trace_line(struct trace_iterator *iter);
 
 extern char trace_find_mark(unsigned long long duration);
 
+void __trace_dump_stack(int skip, struct trace_array *tr);
+
 /* Standard output formatting function used for function return traces */
 #ifdef CONFIG_FUNCTION_GRAPH_TRACER
 
diff --git a/kernel/trace/trace_events_trigger.c b/kernel/trace/trace_events_trigger.c
index b69f2a2..adfcd53 100644
--- a/kernel/trace/trace_events_trigger.c
+++ b/kernel/trace/trace_events_trigger.c
@@ -996,7 +996,7 @@ static void
 stacktrace_trigger(struct event_trigger_data *data, void *rec,
 		   struct trace_event_file *file)
 {
-	trace_dump_stack(STACK_SKIP);
+	__trace_dump_stack(STACK_SKIP, file->tr);
 }
 
 static void
-- 
1.9.1

  parent reply	other threads:[~2016-04-15  6:55 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-04-15  6:53 [PATCHSET] tracing: Make event triggers affect " Howard Cochran
2016-04-15  6:53 ` [PATCH 1/5] tracing: Add param to event_trigger_ops.func() for instances Howard Cochran
2016-04-15  7:10   ` kbuild test robot
2016-04-15  6:53 ` Howard Cochran [this message]
2016-04-15  6:53 ` [PATCH 3/5] tracing: Make traceon, traceoff trigger affect the correct instance Howard Cochran
2016-04-15  6:53 ` [PATCH 4/5] tracing: Make snapshot " Howard Cochran
2016-04-15  6:53 ` [PATCH 5/5] tracing: Make internal_trace_puts() write to " Howard Cochran

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1460703230-13307-3-git-send-email-hcochran@kernelspring.com \
    --to=hcochran@kernelspring.com \
    --cc=cochran@lexmark.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mingo@redhat.com \
    --cc=rostedt@goodmis.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®