]> www.infradead.org Git - users/jedix/linux-maple.git/commitdiff
torture: Wake up kthreads after storing task_struct pointer
authorPaul E. McKenney <paulmck@kernel.org>
Mon, 3 Jan 2022 14:07:09 +0000 (06:07 -0800)
committerPaul E. McKenney <paulmck@kernel.org>
Wed, 2 Feb 2022 01:24:39 +0000 (17:24 -0800)
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>
kernel/torture.c

index f55d803f995d45911a753b8030e7fdf416419cf6..789aeb0e1159c6a0f031f06db40dd28cec75c092 100644 (file)
@@ -931,12 +931,14 @@ int _torture_create_kthread(int (*fn)(void *arg), void *arg, char *s, char *m,
        int ret = 0;
 
        VERBOSE_TOROUT_STRING(m);
-       *tp = kthread_run(fn, arg, "%s", s);
+       *tp = kthread_create(fn, arg, "%s", s);
        if (IS_ERR(*tp)) {
                ret = PTR_ERR(*tp);
                TOROUT_ERRSTRING(f);
                *tp = NULL;
+               return ret;
        }
+       wake_up_process(*tp);  // Process is sleeping, so ordering provided.
        torture_shuffle_task_register(*tp);
        return ret;
 }