2 * Provide a default dump_stack() function for architectures
3 * which don't implement their own.
6 #include <linux/kernel.h>
7 #include <linux/export.h>
8 #include <linux/sched.h>
9 #include <linux/sched/debug.h>
10 #include <linux/smp.h>
11 #include <linux/atomic.h>
13 static void __dump_stack(void)
15 dump_stack_print_info(KERN_DEFAULT);
16 show_stack(NULL, NULL);
20 * dump_stack - dump the current task information and its stack trace
22 * Architectures can override this implementation by implementing its own.
25 static atomic_t dump_lock = ATOMIC_INIT(-1);
27 asmlinkage __visible void dump_stack(void)
35 * Permit this cpu to perform nested stack dumps while serialising
39 local_irq_save(flags);
40 cpu = smp_processor_id();
41 old = atomic_cmpxchg(&dump_lock, -1, cpu);
44 } else if (old == cpu) {
47 local_irq_restore(flags);
55 atomic_set(&dump_lock, -1);
57 local_irq_restore(flags);
60 asmlinkage __visible void dump_stack(void)
65 EXPORT_SYMBOL(dump_stack);