[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <20190410103647.119410023@linutronix.de>
Date: Wed, 10 Apr 2019 12:28:33 +0200
From: Thomas Gleixner <tglx@...utronix.de>
To: LKML <linux-kernel@...r.kernel.org>
Cc: Josh Poimboeuf <jpoimboe@...hat.com>, x86@...nel.org,
Andy Lutomirski <luto@...nel.org>,
Steven Rostedt <rostedt@...dmis.org>,
Alexander Potapenko <glider@...gle.com>
Subject: [RFC patch 39/41] tracing: Simplify stack trace retrieval
Replace the indirection through struct stack_trace by using the storage
array based interfaces.
Signed-off-by: Thomas Gleixner <tglx@...utronix.de>
Cc: Steven Rostedt <rostedt@...dmis.org>
---
kernel/trace/trace.c | 34 +++++++++-------------------------
1 file changed, 9 insertions(+), 25 deletions(-)
--- a/kernel/trace/trace.c
+++ b/kernel/trace/trace.c
@@ -2776,20 +2776,16 @@ static void __ftrace_trace_stack(struct
struct ring_buffer_event *event;
struct ftrace_stack *fstack;
struct stack_entry *entry;
- struct stack_trace trace;
- int size = FTRACE_KSTACK_ENTRIES;
+ unsigned int size, nent;
int stackidx;
- trace.nr_entries = 0;
- trace.skip = skip;
-
/*
* Add one, for this function and the call to save_stack_trace()
* If regs is set, then these functions will not be in the way.
*/
#ifndef CONFIG_UNWINDER_ORC
if (!regs)
- trace.skip++;
+ skip++;
#endif
/*
@@ -2816,28 +2812,22 @@ static void __ftrace_trace_stack(struct
barrier();
fstack = this_cpu_ptr(ftrace_stacks.stacks) + (stackidx - 1);
- trace.entries = fstack->calls;
- trace.max_entries = FTRACE_KSTACK_ENTRIES;
+ nent = ARRAY_SIZE(fstack->calls);
if (regs)
- save_stack_trace_regs(regs, &trace);
+ nent = stack_trace_save_regs(regs, fstack->calls, nent, skip);
else
- save_stack_trace(&trace);
-
- if (trace.nr_entries > size)
- size = trace.nr_entries;
-
- size *= sizeof(unsigned long);
+ nent = stack_trace_save(fstack->calls, nent, skip);
+ size = nent * sizeof(unsigned long);
event = __trace_buffer_lock_reserve(buffer, TRACE_STACK,
sizeof(*entry) + size, flags, pc);
if (!event)
goto out;
entry = ring_buffer_event_data(event);
- memcpy(&entry->caller, trace.entries, size);
-
- entry->size = trace.nr_entries;
+ memcpy(&entry->caller, fstack->calls, size);
+ entry->size = nent;
if (!call_filter_check_discard(call, entry, buffer, event))
__buffer_unlock_commit(buffer, event);
@@ -2916,7 +2906,6 @@ ftrace_trace_userstack(struct ring_buffe
struct trace_event_call *call = &event_user_stack;
struct ring_buffer_event *event;
struct userstack_entry *entry;
- struct stack_trace trace;
if (!(global_trace.trace_flags & TRACE_ITER_USERSTACKTRACE))
return;
@@ -2947,12 +2936,7 @@ ftrace_trace_userstack(struct ring_buffe
entry->tgid = current->tgid;
memset(&entry->caller, 0, sizeof(entry->caller));
- trace.nr_entries = 0;
- trace.max_entries = FTRACE_STACK_ENTRIES;
- trace.skip = 0;
- trace.entries = entry->caller;
-
- save_stack_trace_user(&trace);
+ stack_trace_save_user(entry->caller, FTRACE_STACK_ENTRIES, 0);
if (!call_filter_check_discard(call, entry, buffer, event))
__buffer_unlock_commit(buffer, event);
Powered by blists - more mailing lists