From: "Zqiang" <qiang.zhang@linux.dev>
To: "Joel Fernandes" <joelagnelf@nvidia.com>
Cc: paulmck@kernel.org, frederic@kernel.org,
neeraj.upadhyay@kernel.org, rcu@vger.kernel.org,
linux-kernel@vger.kernel.org
Subject: Re: [PATCH] srcu: Use suitable gfp_flags for the init_srcu_struct_nodes()
Date: Sun, 14 Dec 2025 03:27:44 +0000 [thread overview]
Message-ID: <e4030c94bbc55d1e78f0d26039561f583ff0cadf@linux.dev> (raw)
In-Reply-To: <2D296DB9-2F60-47B2-A48A-D490A291A0EB@nvidia.com>
>
> >
> > On Dec 13, 2025, at 10:56 PM, Zqiang <qiang.zhang@linux.dev> wrote:
> >
> > In some kernels which is set convert_to_big to SRCU_SIZING_INIT,
> > for use the init_srcu_struct*() to initialized srcu structure,
> > the is_static parameters is always false, the memory allocation
> > for srcu_sup structure's->node can use GFP_KERNEL flags.
> >
> > Signed-off-by: Zqiang <qiang.zhang@linux.dev>
> > ---
> > kernel/rcu/srcutree.c | 2 +-
> > 1 file changed, 1 insertion(+), 1 deletion(-)
> >
> > diff --git a/kernel/rcu/srcutree.c b/kernel/rcu/srcutree.c
> > index ea3f128de06f..e4571b569752 100644
> > --- a/kernel/rcu/srcutree.c
> > +++ b/kernel/rcu/srcutree.c
> > @@ -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_KERNEL : GFP_ATOMIC))
> >
> Nit: please avoid double negatives, becomes a bit harder to read:
>
> Instead,
> is_static ? GFP_ATOMIC : GFP_KERNEL
Ok, will do that.
>
> Is it also worthwhile adding a might_sleep() here for additional robustness?
Would it be more appropriate to add might_sleep() before
allocating ssp->srcu_sup ?
Thanks
Zqiang
>
> Thanks.
>
> >
> > goto err_free_sda;
> > WRITE_ONCE(ssp->srcu_sup->srcu_size_state, SRCU_SIZE_BIG);
> > }
> > --
> > 2.48.1
> >
>
next prev parent reply other threads:[~2025-12-14 3:27 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-12-13 13:55 [PATCH] srcu: Use suitable gfp_flags for the init_srcu_struct_nodes() Zqiang
2025-12-13 19:02 ` Joel Fernandes
2025-12-14 3:27 ` Zqiang [this message]
2025-12-14 7:50 ` Joel Fernandes
2025-12-14 8:09 ` Zqiang
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=e4030c94bbc55d1e78f0d26039561f583ff0cadf@linux.dev \
--to=qiang.zhang@linux.dev \
--cc=frederic@kernel.org \
--cc=joelagnelf@nvidia.com \
--cc=linux-kernel@vger.kernel.org \
--cc=neeraj.upadhyay@kernel.org \
--cc=paulmck@kernel.org \
--cc=rcu@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.