1 // SPDX-License-Identifier: GPL-2.0
3 * Provide a default dump_stack() function for architectures
4 * which don't implement their own.
7 #include <linux/kernel.h>
8 #include <linux/export.h>
9 #include <linux/sched.h>
10 #include <linux/sched/debug.h>
11 #include <linux/smp.h>
12 #include <linux/atomic.h>
14 static void __dump_stack(void)
16 dump_stack_print_info(KERN_DEFAULT);
17 show_stack(NULL, NULL);
21 * dump_stack - dump the current task information and its stack trace
23 * Architectures can override this implementation by implementing its own.
26 static atomic_t dump_lock = ATOMIC_INIT(-1);
28 asmlinkage __visible void dump_stack(void)
36 * Permit this cpu to perform nested stack dumps while serialising
40 local_irq_save(flags);
41 cpu = smp_processor_id();
42 old = atomic_cmpxchg(&dump_lock, -1, cpu);
45 } else if (old == cpu) {
48 local_irq_restore(flags);
56 atomic_set(&dump_lock, -1);
58 local_irq_restore(flags);
61 asmlinkage __visible void dump_stack(void)
66 EXPORT_SYMBOL(dump_stack);