]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
scftorture: Move memory allocation outside of preempt_disable region.
authorSebastian Andrzej Siewior <bigeasy@linutronix.de>
Fri, 8 Nov 2024 10:39:33 +0000 (11:39 +0100)
committerPaul E. McKenney <paulmck@kernel.org>
Sat, 9 Nov 2024 17:00:46 +0000 (09:00 -0800)
Memory allocations can not happen within regions with explicit disabled
preemption PREEMPT_RT. The problem is that the locking structures
underneath are sleeping locks.

Move the memory allocation outside of the preempt-disabled section. Keep
the GFP_ATOMIC for the allocation to behave like a "ememergncy
allocation".

Tested-by: Paul E. McKenney <paulmck@kernel.org>
Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
Reviewed-by: Boqun Feng <boqun.feng@gmail.com>
Tested-by: Boqun Feng <boqun.feng@gmail.com>
Signed-off-by: Paul E. McKenney <paulmck@kernel.org>
kernel/scftorture.c

index 654702f75c54b240b5e45193f87015e47024aabc..e3c60f6dd547778f60cf4b98d2348ffffe29c831 100644 (file)
@@ -320,10 +320,6 @@ static void scftorture_invoke_one(struct scf_statistics *scfp, struct torture_ra
        struct scf_check *scfcp = NULL;
        struct scf_selector *scfsp = scf_sel_rand(trsp);
 
-       if (use_cpus_read_lock)
-               cpus_read_lock();
-       else
-               preempt_disable();
        if (scfsp->scfs_prim == SCF_PRIM_SINGLE || scfsp->scfs_wait) {
                scfcp = kmalloc(sizeof(*scfcp), GFP_ATOMIC);
                if (!scfcp) {
@@ -337,6 +333,10 @@ static void scftorture_invoke_one(struct scf_statistics *scfp, struct torture_ra
                        scfcp->scfc_rpc = false;
                }
        }
+       if (use_cpus_read_lock)
+               cpus_read_lock();
+       else
+               preempt_disable();
        switch (scfsp->scfs_prim) {
        case SCF_PRIM_RESCHED:
                if (IS_BUILTIN(CONFIG_SCF_TORTURE_TEST)) {