public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH v2] srcu: Use suitable gfp_flags for the init_srcu_struct_nodes()
@ 2025-12-14 10:14 Zqiang
  2025-12-23  0:57 ` Joel Fernandes
  0 siblings, 1 reply; 2+ messages in thread
From: Zqiang @ 2025-12-14 10:14 UTC (permalink / raw)
  To: paulmck, frederic, neeraj.upadhyay, joelagnelf
  Cc: rcu, linux-kernel, qiang.zhang

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>
---
 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..c469c708fdd6 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_ATOMIC : GFP_KERNEL))
 			goto err_free_sda;
 		WRITE_ONCE(ssp->srcu_sup->srcu_size_state, SRCU_SIZE_BIG);
 	}
-- 
2.48.1


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH v2] srcu: Use suitable gfp_flags for the init_srcu_struct_nodes()
  2025-12-14 10:14 [PATCH v2] srcu: Use suitable gfp_flags for the init_srcu_struct_nodes() Zqiang
@ 2025-12-23  0:57 ` Joel Fernandes
  0 siblings, 0 replies; 2+ messages in thread
From: Joel Fernandes @ 2025-12-23  0:57 UTC (permalink / raw)
  To: Zqiang, paulmck, frederic, neeraj.upadhyay; +Cc: rcu, linux-kernel

On 12/14/2025 5:14 AM, Zqiang wrote:
> 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>

Will apply and send out to the list (soon) with other patches for further review
and testing.

 - Joel

> ---
>  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..c469c708fdd6 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_ATOMIC : GFP_KERNEL))
>  			goto err_free_sda;
>  		WRITE_ONCE(ssp->srcu_sup->srcu_size_state, SRCU_SIZE_BIG);
>  	}


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2025-12-23  0:57 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-12-14 10:14 [PATCH v2] srcu: Use suitable gfp_flags for the init_srcu_struct_nodes() Zqiang
2025-12-23  0:57 ` Joel Fernandes

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox