Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752812AbcDOWd7 (ORCPT ); Fri, 15 Apr 2016 18:33:59 -0400 Received: from mail-ig0-f178.google.com ([209.85.213.178]:35235 "EHLO mail-ig0-f178.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752444AbcDOWdL (ORCPT ); Fri, 15 Apr 2016 18:33:11 -0400 From: Howard Cochran To: linux-kernel@vger.kernel.org Cc: Steven Rostedt , Ingo Molnar , Howard Cochran , Howard Cochran Subject: [PATCH v2 2/5] tracing: Make stacktrace trigger affect the correct instance Date: Fri, 15 Apr 2016 18:32:12 -0400 Message-Id: <1460759535-22403-3-git-send-email-hcochran@kernelspring.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1460759535-22403-1-git-send-email-hcochran@kernelspring.com> References: <1460759535-22403-1-git-send-email-hcochran@kernelspring.com> Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 2803 Lines: 87 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 --- 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 a3336f2..670aa05 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