Commit 4285f2fc authored by Thomas Gleixner's avatar Thomas Gleixner

tracing: Remove the ULONG_MAX stack trace hackery

No architecture terminates the stack trace with ULONG_MAX anymore. As the
code checks the number of entries stored anyway there is no point in
keeping all that ULONG_MAX magic around.

The histogram code zeroes the storage before saving the stack, so if the
trace is shorter than the maximum number of entries it can terminate the
print loop if a zero entry is detected.
Signed-off-by: default avatarThomas Gleixner <tglx@linutronix.de>
Acked-by: default avatarPeter Zijlstra (Intel) <peterz@infradead.org>
Cc: Josh Poimboeuf <jpoimboe@redhat.com>
Cc: Andy Lutomirski <luto@kernel.org>
Cc: Steven Rostedt <rostedt@goodmis.org>
Cc: Alexander Potapenko <glider@google.com>
Link: https://lkml.kernel.org/r/20190410103645.048761764@linutronix.de
parent fa49e2ea
...@@ -5246,7 +5246,7 @@ static void hist_trigger_stacktrace_print(struct seq_file *m, ...@@ -5246,7 +5246,7 @@ static void hist_trigger_stacktrace_print(struct seq_file *m,
unsigned int i; unsigned int i;
for (i = 0; i < max_entries; i++) { for (i = 0; i < max_entries; i++) {
if (stacktrace_entries[i] == ULONG_MAX) if (!stacktrace_entries[i])
return; return;
seq_printf(m, "%*c", 1 + spaces, ' '); seq_printf(m, "%*c", 1 + spaces, ' ');
......
...@@ -18,8 +18,7 @@ ...@@ -18,8 +18,7 @@
#include "trace.h" #include "trace.h"
static unsigned long stack_dump_trace[STACK_TRACE_ENTRIES+1] = static unsigned long stack_dump_trace[STACK_TRACE_ENTRIES + 1];
{ [0 ... (STACK_TRACE_ENTRIES)] = ULONG_MAX };
unsigned stack_trace_index[STACK_TRACE_ENTRIES]; unsigned stack_trace_index[STACK_TRACE_ENTRIES];
/* /*
...@@ -52,10 +51,7 @@ void stack_trace_print(void) ...@@ -52,10 +51,7 @@ void stack_trace_print(void)
stack_trace_max.nr_entries); stack_trace_max.nr_entries);
for (i = 0; i < stack_trace_max.nr_entries; i++) { for (i = 0; i < stack_trace_max.nr_entries; i++) {
if (stack_dump_trace[i] == ULONG_MAX) if (i + 1 == stack_trace_max.nr_entries)
break;
if (i+1 == stack_trace_max.nr_entries ||
stack_dump_trace[i+1] == ULONG_MAX)
size = stack_trace_index[i]; size = stack_trace_index[i];
else else
size = stack_trace_index[i] - stack_trace_index[i+1]; size = stack_trace_index[i] - stack_trace_index[i+1];
...@@ -150,8 +146,6 @@ check_stack(unsigned long ip, unsigned long *stack) ...@@ -150,8 +146,6 @@ check_stack(unsigned long ip, unsigned long *stack)
p = start; p = start;
for (; p < top && i < stack_trace_max.nr_entries; p++) { for (; p < top && i < stack_trace_max.nr_entries; p++) {
if (stack_dump_trace[i] == ULONG_MAX)
break;
/* /*
* The READ_ONCE_NOCHECK is used to let KASAN know that * The READ_ONCE_NOCHECK is used to let KASAN know that
* this is not a stack-out-of-bounds error. * this is not a stack-out-of-bounds error.
...@@ -183,8 +177,6 @@ check_stack(unsigned long ip, unsigned long *stack) ...@@ -183,8 +177,6 @@ check_stack(unsigned long ip, unsigned long *stack)
} }
stack_trace_max.nr_entries = x; stack_trace_max.nr_entries = x;
for (; x < i; x++)
stack_dump_trace[x] = ULONG_MAX;
if (task_stack_end_corrupted(current)) { if (task_stack_end_corrupted(current)) {
stack_trace_print(); stack_trace_print();
...@@ -286,7 +278,7 @@ __next(struct seq_file *m, loff_t *pos) ...@@ -286,7 +278,7 @@ __next(struct seq_file *m, loff_t *pos)
{ {
long n = *pos - 1; long n = *pos - 1;
if (n >= stack_trace_max.nr_entries || stack_dump_trace[n] == ULONG_MAX) if (n >= stack_trace_max.nr_entries)
return NULL; return NULL;
m->private = (void *)n; m->private = (void *)n;
...@@ -360,12 +352,10 @@ static int t_show(struct seq_file *m, void *v) ...@@ -360,12 +352,10 @@ static int t_show(struct seq_file *m, void *v)
i = *(long *)v; i = *(long *)v;
if (i >= stack_trace_max.nr_entries || if (i >= stack_trace_max.nr_entries)
stack_dump_trace[i] == ULONG_MAX)
return 0; return 0;
if (i+1 == stack_trace_max.nr_entries || if (i + 1 == stack_trace_max.nr_entries)
stack_dump_trace[i+1] == ULONG_MAX)
size = stack_trace_index[i]; size = stack_trace_index[i];
else else
size = stack_trace_index[i] - stack_trace_index[i+1]; size = stack_trace_index[i] - stack_trace_index[i+1];
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment