kgdboc: Use a platform device to handle tty drivers showing up late
[linux/fpc-iii.git] / kernel / backtracetest.c
bloba2a97fa3071b1c7ee6595d61a172f7ccc73ea40b
1 // SPDX-License-Identifier: GPL-2.0-only
2 /*
3 * Simple stack backtrace regression test module
5 * (C) Copyright 2008 Intel Corporation
6 * Author: Arjan van de Ven <arjan@linux.intel.com>
7 */
9 #include <linux/completion.h>
10 #include <linux/delay.h>
11 #include <linux/interrupt.h>
12 #include <linux/module.h>
13 #include <linux/sched.h>
14 #include <linux/stacktrace.h>
16 static void backtrace_test_normal(void)
18 pr_info("Testing a backtrace from process context.\n");
19 pr_info("The following trace is a kernel self test and not a bug!\n");
21 dump_stack();
24 static DECLARE_COMPLETION(backtrace_work);
26 static void backtrace_test_irq_callback(unsigned long data)
28 dump_stack();
29 complete(&backtrace_work);
32 static DECLARE_TASKLET(backtrace_tasklet, &backtrace_test_irq_callback, 0);
34 static void backtrace_test_irq(void)
36 pr_info("Testing a backtrace from irq context.\n");
37 pr_info("The following trace is a kernel self test and not a bug!\n");
39 init_completion(&backtrace_work);
40 tasklet_schedule(&backtrace_tasklet);
41 wait_for_completion(&backtrace_work);
44 #ifdef CONFIG_STACKTRACE
45 static void backtrace_test_saved(void)
47 unsigned long entries[8];
48 unsigned int nr_entries;
50 pr_info("Testing a saved backtrace.\n");
51 pr_info("The following trace is a kernel self test and not a bug!\n");
53 nr_entries = stack_trace_save(entries, ARRAY_SIZE(entries), 0);
54 stack_trace_print(entries, nr_entries, 0);
56 #else
57 static void backtrace_test_saved(void)
59 pr_info("Saved backtrace test skipped.\n");
61 #endif
63 static int backtrace_regression_test(void)
65 pr_info("====[ backtrace testing ]===========\n");
67 backtrace_test_normal();
68 backtrace_test_irq();
69 backtrace_test_saved();
71 pr_info("====[ end of backtrace testing ]====\n");
72 return 0;
75 static void exitf(void)
79 module_init(backtrace_regression_test);
80 module_exit(exitf);
81 MODULE_LICENSE("GPL");
82 MODULE_AUTHOR("Arjan van de Ven <arjan@linux.intel.com>");