Skip to content

Commit 7245d24

Browse files
committed
backtracetest: Convert from tasklet to BH workqueue
The only generic interface to execute asynchronously in the BH context is tasklet; however, it's marked deprecated and has some design flaws. To replace tasklets, BH workqueue support was recently added. A BH workqueue behaves similarly to regular workqueues except that the queued work items are executed in the BH context. This patch converts backtracetest from tasklet to BH workqueue. - Replace "irq" with "bh" in names and message to better reflect what's happening. - Replace completion usage with a flush_work() call. Signed-off-by: Tejun Heo <tj@kernel.org> Cc: Arjan van de Ven <arjan@linux.intel.com>
1 parent 8eb17dc commit 7245d24

File tree

1 file changed

+7
-11
lines changed

1 file changed

+7
-11
lines changed

kernel/backtracetest.c

Lines changed: 7 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -21,24 +21,20 @@ static void backtrace_test_normal(void)
2121
dump_stack();
2222
}
2323

24-
static DECLARE_COMPLETION(backtrace_work);
25-
26-
static void backtrace_test_irq_callback(unsigned long data)
24+
static void backtrace_test_bh_workfn(struct work_struct *work)
2725
{
2826
dump_stack();
29-
complete(&backtrace_work);
3027
}
3128

32-
static DECLARE_TASKLET_OLD(backtrace_tasklet, &backtrace_test_irq_callback);
29+
static DECLARE_WORK(backtrace_bh_work, &backtrace_test_bh_workfn);
3330

34-
static void backtrace_test_irq(void)
31+
static void backtrace_test_bh(void)
3532
{
36-
pr_info("Testing a backtrace from irq context.\n");
33+
pr_info("Testing a backtrace from BH context.\n");
3734
pr_info("The following trace is a kernel self test and not a bug!\n");
3835

39-
init_completion(&backtrace_work);
40-
tasklet_schedule(&backtrace_tasklet);
41-
wait_for_completion(&backtrace_work);
36+
queue_work(system_bh_wq, &backtrace_bh_work);
37+
flush_work(&backtrace_bh_work);
4238
}
4339

4440
#ifdef CONFIG_STACKTRACE
@@ -65,7 +61,7 @@ static int backtrace_regression_test(void)
6561
pr_info("====[ backtrace testing ]===========\n");
6662

6763
backtrace_test_normal();
68-
backtrace_test_irq();
64+
backtrace_test_bh();
6965
backtrace_test_saved();
7066

7167
pr_info("====[ end of backtrace testing ]====\n");

0 commit comments

Comments
 (0)