~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~

TOMOYO Linux Cross Reference
Linux/lib/dump_stack.c

Version: ~ [ linux-5.3 ] ~ [ linux-5.2.15 ] ~ [ linux-5.1.21 ] ~ [ linux-5.0.21 ] ~ [ linux-4.20.17 ] ~ [ linux-4.19.73 ] ~ [ linux-4.18.20 ] ~ [ linux-4.17.19 ] ~ [ linux-4.16.18 ] ~ [ linux-4.15.18 ] ~ [ linux-4.14.144 ] ~ [ linux-4.13.16 ] ~ [ linux-4.12.14 ] ~ [ linux-4.11.12 ] ~ [ linux-4.10.17 ] ~ [ linux-4.9.193 ] ~ [ linux-4.8.17 ] ~ [ linux-4.7.10 ] ~ [ linux-4.6.7 ] ~ [ linux-4.5.7 ] ~ [ linux-4.4.193 ] ~ [ linux-4.3.6 ] ~ [ linux-4.2.8 ] ~ [ linux-4.1.52 ] ~ [ linux-4.0.9 ] ~ [ linux-3.19.8 ] ~ [ linux-3.18.140 ] ~ [ linux-3.17.8 ] ~ [ linux-3.16.73 ] ~ [ linux-3.15.10 ] ~ [ linux-3.14.79 ] ~ [ linux-3.13.11 ] ~ [ linux-3.12.74 ] ~ [ linux-3.11.10 ] ~ [ linux-3.10.108 ] ~ [ linux-3.9.11 ] ~ [ linux-3.8.13 ] ~ [ linux-3.7.10 ] ~ [ linux-3.6.11 ] ~ [ linux-3.5.7 ] ~ [ linux-3.4.113 ] ~ [ linux-3.3.8 ] ~ [ linux-3.2.102 ] ~ [ linux-3.1.10 ] ~ [ linux-3.0.101 ] ~ [ linux-2.6.32.71 ] ~ [ linux-2.6.0 ] ~ [ linux-2.4.37.11 ] ~ [ unix-v6-master ] ~ [ ccs-tools-1.8.5 ] ~ [ policy-sample ] ~
Architecture: ~ [ i386 ] ~ [ alpha ] ~ [ m68k ] ~ [ mips ] ~ [ ppc ] ~ [ sparc ] ~ [ sparc64 ] ~

  1 /*
  2  * Provide a default dump_stack() function for architectures
  3  * which don't implement their own.
  4  */
  5 
  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>
 12 
 13 static void __dump_stack(void)
 14 {
 15         dump_stack_print_info(KERN_DEFAULT);
 16         show_stack(NULL, NULL);
 17 }
 18 
 19 /**
 20  * dump_stack - dump the current task information and its stack trace
 21  *
 22  * Architectures can override this implementation by implementing its own.
 23  */
 24 #ifdef CONFIG_SMP
 25 static atomic_t dump_lock = ATOMIC_INIT(-1);
 26 
 27 asmlinkage __visible void dump_stack(void)
 28 {
 29         unsigned long flags;
 30         int was_locked;
 31         int old;
 32         int cpu;
 33 
 34         /*
 35          * Permit this cpu to perform nested stack dumps while serialising
 36          * against other CPUs
 37          */
 38 retry:
 39         local_irq_save(flags);
 40         cpu = smp_processor_id();
 41         old = atomic_cmpxchg(&dump_lock, -1, cpu);
 42         if (old == -1) {
 43                 was_locked = 0;
 44         } else if (old == cpu) {
 45                 was_locked = 1;
 46         } else {
 47                 local_irq_restore(flags);
 48                 cpu_relax();
 49                 goto retry;
 50         }
 51 
 52         __dump_stack();
 53 
 54         if (!was_locked)
 55                 atomic_set(&dump_lock, -1);
 56 
 57         local_irq_restore(flags);
 58 }
 59 #else
 60 asmlinkage __visible void dump_stack(void)
 61 {
 62         __dump_stack();
 63 }
 64 #endif
 65 EXPORT_SYMBOL(dump_stack);
 66 

~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~

kernel.org | git.kernel.org | LWN.net | Project Home | Wiki (Japanese) | Wiki (English) | SVN repository | Mail admin

Linux® is a registered trademark of Linus Torvalds in the United States and other countries.
TOMOYO® is a registered trademark of NTT DATA CORPORATION.

osdn.jp