Skip to content

Commit 9f50c91

Browse files
committed
tracing: Remove the last struct stack_trace usage
Simplify the stack retrieval code by using the storage array based interface. Signed-off-by: Thomas Gleixner <tglx@linutronix.de> Reviewed-by: Steven Rostedt (VMware) <rostedt@goodmis.org> Reviewed-by: Josh Poimboeuf <jpoimboe@redhat.com> Cc: Andy Lutomirski <luto@kernel.org> Cc: Alexander Potapenko <glider@google.com> Cc: Alexey Dobriyan <adobriyan@gmail.com> Cc: Andrew Morton <akpm@linux-foundation.org> Cc: Christoph Lameter <cl@linux.com> Cc: Pekka Enberg <penberg@kernel.org> Cc: linux-mm@kvack.org Cc: David Rientjes <rientjes@google.com> Cc: Catalin Marinas <catalin.marinas@arm.com> Cc: Dmitry Vyukov <dvyukov@google.com> Cc: Andrey Ryabinin <aryabinin@virtuozzo.com> Cc: kasan-dev@googlegroups.com Cc: Mike Rapoport <rppt@linux.vnet.ibm.com> Cc: Akinobu Mita <akinobu.mita@gmail.com> Cc: Christoph Hellwig <hch@lst.de> Cc: iommu@lists.linux-foundation.org Cc: Robin Murphy <robin.murphy@arm.com> Cc: Marek Szyprowski <m.szyprowski@samsung.com> Cc: Johannes Thumshirn <jthumshirn@suse.de> Cc: David Sterba <dsterba@suse.com> Cc: Chris Mason <clm@fb.com> Cc: Josef Bacik <josef@toxicpanda.com> Cc: linux-btrfs@vger.kernel.org Cc: dm-devel@redhat.com Cc: Mike Snitzer <snitzer@redhat.com> Cc: Alasdair Kergon <agk@redhat.com> Cc: Daniel Vetter <daniel@ffwll.ch> Cc: intel-gfx@lists.freedesktop.org Cc: Joonas Lahtinen <joonas.lahtinen@linux.intel.com> Cc: Maarten Lankhorst <maarten.lankhorst@linux.intel.com> Cc: dri-devel@lists.freedesktop.org Cc: David Airlie <airlied@linux.ie> Cc: Jani Nikula <jani.nikula@linux.intel.com> Cc: Rodrigo Vivi <rodrigo.vivi@intel.com> Cc: Tom Zanussi <tom.zanussi@linux.intel.com> Cc: Miroslav Benes <mbenes@suse.cz> Cc: linux-arch@vger.kernel.org Link: https://lkml.kernel.org/r/20190425094803.340000461@linutronix.de
1 parent ee6dd0d commit 9f50c91

1 file changed

Lines changed: 16 additions & 21 deletions

File tree

‎kernel/trace/trace_stack.c‎

Lines changed: 16 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -23,11 +23,7 @@
2323
static unsigned long stack_dump_trace[STACK_TRACE_ENTRIES];
2424
static unsigned stack_trace_index[STACK_TRACE_ENTRIES];
2525

26-
struct stack_trace stack_trace_max = {
27-
.max_entries = STACK_TRACE_ENTRIES,
28-
.entries = &stack_dump_trace[0],
29-
};
30-
26+
static unsigned int stack_trace_nr_entries;
3127
static unsigned long stack_trace_max_size;
3228
static arch_spinlock_t stack_trace_max_lock =
3329
(arch_spinlock_t)__ARCH_SPIN_LOCK_UNLOCKED;
@@ -44,10 +40,10 @@ static void print_max_stack(void)
4440

4541
pr_emerg(" Depth Size Location (%d entries)\n"
4642
" ----- ---- --------\n",
47-
stack_trace_max.nr_entries);
43+
stack_trace_nr_entries);
4844

49-
for (i = 0; i < stack_trace_max.nr_entries; i++) {
50-
if (i + 1 == stack_trace_max.nr_entries)
45+
for (i = 0; i < stack_trace_nr_entries; i++) {
46+
if (i + 1 == stack_trace_nr_entries)
5147
size = stack_trace_index[i];
5248
else
5349
size = stack_trace_index[i] - stack_trace_index[i+1];
@@ -93,13 +89,12 @@ static void check_stack(unsigned long ip, unsigned long *stack)
9389

9490
stack_trace_max_size = this_size;
9591

96-
stack_trace_max.nr_entries = 0;
97-
stack_trace_max.skip = 0;
98-
99-
save_stack_trace(&stack_trace_max);
92+
stack_trace_nr_entries = stack_trace_save(stack_dump_trace,
93+
ARRAY_SIZE(stack_dump_trace) - 1,
94+
0);
10095

10196
/* Skip over the overhead of the stack tracer itself */
102-
for (i = 0; i < stack_trace_max.nr_entries; i++) {
97+
for (i = 0; i < stack_trace_nr_entries; i++) {
10398
if (stack_dump_trace[i] == ip)
10499
break;
105100
}
@@ -108,7 +103,7 @@ static void check_stack(unsigned long ip, unsigned long *stack)
108103
* Some archs may not have the passed in ip in the dump.
109104
* If that happens, we need to show everything.
110105
*/
111-
if (i == stack_trace_max.nr_entries)
106+
if (i == stack_trace_nr_entries)
112107
i = 0;
113108

114109
/*
@@ -126,13 +121,13 @@ static void check_stack(unsigned long ip, unsigned long *stack)
126121
* loop will only happen once. This code only takes place
127122
* on a new max, so it is far from a fast path.
128123
*/
129-
while (i < stack_trace_max.nr_entries) {
124+
while (i < stack_trace_nr_entries) {
130125
int found = 0;
131126

132127
stack_trace_index[x] = this_size;
133128
p = start;
134129

135-
for (; p < top && i < stack_trace_max.nr_entries; p++) {
130+
for (; p < top && i < stack_trace_nr_entries; p++) {
136131
/*
137132
* The READ_ONCE_NOCHECK is used to let KASAN know that
138133
* this is not a stack-out-of-bounds error.
@@ -163,7 +158,7 @@ static void check_stack(unsigned long ip, unsigned long *stack)
163158
i++;
164159
}
165160

166-
stack_trace_max.nr_entries = x;
161+
stack_trace_nr_entries = x;
167162

168163
if (task_stack_end_corrupted(current)) {
169164
print_max_stack();
@@ -265,7 +260,7 @@ __next(struct seq_file *m, loff_t *pos)
265260
{
266261
long n = *pos - 1;
267262

268-
if (n >= stack_trace_max.nr_entries)
263+
if (n >= stack_trace_nr_entries)
269264
return NULL;
270265

271266
m->private = (void *)n;
@@ -329,7 +324,7 @@ static int t_show(struct seq_file *m, void *v)
329324
seq_printf(m, " Depth Size Location"
330325
" (%d entries)\n"
331326
" ----- ---- --------\n",
332-
stack_trace_max.nr_entries);
327+
stack_trace_nr_entries);
333328

334329
if (!stack_tracer_enabled && !stack_trace_max_size)
335330
print_disabled(m);
@@ -339,10 +334,10 @@ static int t_show(struct seq_file *m, void *v)
339334

340335
i = *(long *)v;
341336

342-
if (i >= stack_trace_max.nr_entries)
337+
if (i >= stack_trace_nr_entries)
343338
return 0;
344339

345-
if (i + 1 == stack_trace_max.nr_entries)
340+
if (i + 1 == stack_trace_nr_entries)
346341
size = stack_trace_index[i];
347342
else
348343
size = stack_trace_index[i] - stack_trace_index[i+1];

0 commit comments

Comments
 (0)