Skip to content

Commit 6b8646a

Browse files
committed
torture: Wake up kthreads after storing task_struct pointer
Currently, _torture_create_kthread() uses kthread_run() to create torture-test kthreads, which means that the resulting task_struct pointer is stored after the newly created kthread has been marked runnable. This in turn can cause spurious failure of checks for code being run by a particular kthread. This commit therefore changes _torture_create_kthread() to use kthread_create(), then to do an explicit wake_up_process() after the task_struct pointer has been stored. Reported-by: Frederic Weisbecker <frederic@kernel.org> Reviewed-by: Neeraj Upadhyay <quic_neeraju@quicinc.com> Reviewed-by: Uladzislau Rezki (Sony) <urezki@gmail.com> Reviewed-by: Frederic Weisbecker <frederic@kernel.org> Signed-off-by: Paul E. McKenney <paulmck@kernel.org>
1 parent 89440d2 commit 6b8646a

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

kernel/torture.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -931,12 +931,14 @@ int _torture_create_kthread(int (*fn)(void *arg), void *arg, char *s, char *m,
931931
int ret = 0;
932932

933933
VERBOSE_TOROUT_STRING(m);
934-
*tp = kthread_run(fn, arg, "%s", s);
934+
*tp = kthread_create(fn, arg, "%s", s);
935935
if (IS_ERR(*tp)) {
936936
ret = PTR_ERR(*tp);
937937
TOROUT_ERRSTRING(f);
938938
*tp = NULL;
939+
return ret;
939940
}
941+
wake_up_process(*tp); // Process is sleeping, so ordering provided.
940942
torture_shuffle_task_register(*tp);
941943
return ret;
942944
}

0 commit comments

Comments
 (0)