Re: [PATCH] kernel/trace: Stop and wait for kthread on preempt irq module unload

From: Steven Rostedt
Date: Tue Apr 28 2020 - 10:44:14 EST


On Tue, 28 Apr 2020 18:19:05 +0800
Xiao Yang <yangx.jy@xxxxxxxxxxxxxx> wrote:

> Hi Joel,
>
> Thanks for your quick fix.
>
> Unfortunately, it fixes my original panic but introduces other
> issues(two wanings and one panic) on my arm64 vm, as below:
>

Does the following on top of Joel's patch fix it?

-- Steve

diff --git a/kernel/trace/preemptirq_delay_test.c b/kernel/trace/preemptirq_delay_test.c
index 1c28ca20e30b..6d9131ae7e8c 100644
--- a/kernel/trace/preemptirq_delay_test.c
+++ b/kernel/trace/preemptirq_delay_test.c
@@ -113,15 +113,27 @@ static int preemptirq_delay_run(void *data)

for (i = 0; i < s; i++)
(testfuncs[i])(i);
+
+ while (!kthread_should_stop()) {
+ schedule();
+ set_current_state(TASK_INTERRUPTIBLE);
+ }
+
+ __set_current_state(TASK_RUNNING);
+
return 0;
}

static struct task_struct *preemptirq_start_test(void)
{
+ struct task_struct *task;
char task_name[50];

snprintf(task_name, sizeof(task_name), "%s_test", test_mode);
- return kthread_run(preemptirq_delay_run, NULL, task_name);
+ task = kthread_run(preemptirq_delay_run, NULL, task_name);
+ if (IS_ERR(task))
+ return NULL;
+ return task;
}