1 // SPDX-License-Identifier: GPL-2.0-only
3 * Simple stack backtrace regression test module
5 * (C) Copyright 2008 Intel Corporation
6 * Author: Arjan van de Ven <arjan@linux.intel.com>
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");
24 static void backtrace_test_bh_workfn(struct work_struct
*work
)
29 static DECLARE_WORK(backtrace_bh_work
, &backtrace_test_bh_workfn
);
31 static void backtrace_test_bh(void)
33 pr_info("Testing a backtrace from BH context.\n");
34 pr_info("The following trace is a kernel self test and not a bug!\n");
36 queue_work(system_bh_wq
, &backtrace_bh_work
);
37 flush_work(&backtrace_bh_work
);
40 #ifdef CONFIG_STACKTRACE
41 static void backtrace_test_saved(void)
43 unsigned long entries
[8];
44 unsigned int nr_entries
;
46 pr_info("Testing a saved backtrace.\n");
47 pr_info("The following trace is a kernel self test and not a bug!\n");
49 nr_entries
= stack_trace_save(entries
, ARRAY_SIZE(entries
), 0);
50 stack_trace_print(entries
, nr_entries
, 0);
53 static void backtrace_test_saved(void)
55 pr_info("Saved backtrace test skipped.\n");
59 static int backtrace_regression_test(void)
61 pr_info("====[ backtrace testing ]===========\n");
63 backtrace_test_normal();
65 backtrace_test_saved();
67 pr_info("====[ end of backtrace testing ]====\n");
71 static void exitf(void)
75 module_init(backtrace_regression_test
);
77 MODULE_DESCRIPTION("Simple stack backtrace regression test module");
78 MODULE_LICENSE("GPL");
79 MODULE_AUTHOR("Arjan van de Ven <arjan@linux.intel.com>");