]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
srcu: Use suitable gfp_flags for the init_srcu_struct_nodes()
authorZqiang <qiang.zhang@linux.dev>
Thu, 1 Jan 2026 16:34:11 +0000 (11:34 -0500)
committerBoqun Feng <boqun.feng@gmail.com>
Wed, 7 Jan 2026 13:59:41 +0000 (21:59 +0800)
For use the init_srcu_struct*() to initialized srcu structure,
the srcu structure's->srcu_sup and sda use GFP_KERNEL flags to
allocate memory. similarly, if set SRCU_SIZING_INIT, the
srcu_sup's->node can still use GFP_KERNEL flags to allocate
memory, not need to use GFP_ATOMIC flags all the time.

Signed-off-by: Zqiang <qiang.zhang@linux.dev>
Reviewed-by: Joel Fernandes <joelagnelf@nvidia.com>
Tested-by: Paul E. McKenney <paulmck@kernel.org>
Signed-off-by: Joel Fernandes <joelagnelf@nvidia.com>
Signed-off-by: Boqun Feng <boqun.feng@gmail.com>
kernel/rcu/srcutree.c

index ea3f128de06fbc846244e23e0b309dafab63f98b..c469c708fdd6a91cff38a6abc80ce9e65956b5c0 100644 (file)
@@ -262,7 +262,7 @@ static int init_srcu_struct_fields(struct srcu_struct *ssp, bool is_static)
        ssp->srcu_sup->srcu_gp_seq_needed_exp = SRCU_GP_SEQ_INITIAL_VAL;
        ssp->srcu_sup->srcu_last_gp_end = ktime_get_mono_fast_ns();
        if (READ_ONCE(ssp->srcu_sup->srcu_size_state) == SRCU_SIZE_SMALL && SRCU_SIZING_IS_INIT()) {
-               if (!init_srcu_struct_nodes(ssp, GFP_ATOMIC))
+               if (!init_srcu_struct_nodes(ssp, is_static ? GFP_ATOMIC : GFP_KERNEL))
                        goto err_free_sda;
                WRITE_ONCE(ssp->srcu_sup->srcu_size_state, SRCU_SIZE_BIG);
        }