On Mon, Sep 07, 2026 at 03:58:22PM +0800, Kunwu Chan wrote:
> From: Kunwu Chan <[email protected]>
> 
> The is_atomic parameter of init_srcu_struct_fields() exists so that
> atomic SRCU never transitions to big, but neither
> init_srcu_struct_atomic() nor its lockdep counterpart
> __init_srcu_struct_atomic() sets it.
> 
> On systems where srcutree.convert_to_big selects SRCU_SIZING_INIT,
> this needlessly allocates a full srcu_node combining tree for any
> dynamically initialized atomic srcu_struct, despite atomic SRCU
> having neither callbacks nor srcu_barrier() operations.
> 
> Pass true from both atomic entry points, adding an is_atomic parameter
> to __init_srcu_struct_common().
> 
> Signed-off-by: Kunwu Chan <[email protected]>

Given that we have this commit, is this patch needed?

4e01d5320a2f ("srcutree: Suppress to-big transition for atomic SRCU")

If so, please tell me what I am missing.

                                                Thanx, Paul

> ---
>  kernel/rcu/srcutree.c | 15 ++++++++-------
>  1 file changed, 8 insertions(+), 7 deletions(-)
> 
> diff --git a/kernel/rcu/srcutree.c b/kernel/rcu/srcutree.c
> index 2af36db37fa9..01f224a56b41 100644
> --- a/kernel/rcu/srcutree.c
> +++ b/kernel/rcu/srcutree.c
> @@ -305,26 +305,27 @@ static int init_srcu_struct_fields(struct srcu_struct 
> *ssp, bool is_static, bool
>  #ifdef CONFIG_DEBUG_LOCK_ALLOC
>  
>  static int
> -__init_srcu_struct_common(struct srcu_struct *ssp, const char *name, struct 
> lock_class_key *key)
> +__init_srcu_struct_common(struct srcu_struct *ssp, const char *name,
> +                       struct lock_class_key *key, bool is_atomic)
>  {
>       /* Don't re-initialize a lock while it is held. */
>       debug_check_no_locks_freed((void *)ssp, sizeof(*ssp));
>       lockdep_init_map(&ssp->dep_map, name, key, 0);
> -     return init_srcu_struct_fields(ssp, false, false);
> +     return init_srcu_struct_fields(ssp, false, is_atomic);
>  }
>  
>  int init_srcu_struct_lockdep(struct srcu_struct *ssp, const char *name,
>                            struct lock_class_key *key)
>  {
>       ssp->srcu_reader_flavor = 0;
> -     return __init_srcu_struct_common(ssp, name, key);
> +     return __init_srcu_struct_common(ssp, name, key, false);
>  }
>  EXPORT_SYMBOL_GPL(init_srcu_struct_lockdep);
>  
>  int __init_srcu_struct_fast(struct srcu_struct *ssp, const char *name, 
> struct lock_class_key *key)
>  {
>       ssp->srcu_reader_flavor = SRCU_READ_FLAVOR_FAST;
> -     return __init_srcu_struct_common(ssp, name, key);
> +     return __init_srcu_struct_common(ssp, name, key, false);
>  }
>  EXPORT_SYMBOL_GPL(__init_srcu_struct_fast);
>  
> @@ -332,14 +333,14 @@ int __init_srcu_struct_fast_updown(struct srcu_struct 
> *ssp, const char *name,
>                                  struct lock_class_key *key)
>  {
>       ssp->srcu_reader_flavor = SRCU_READ_FLAVOR_FAST_UPDOWN;
> -     return __init_srcu_struct_common(ssp, name, key);
> +     return __init_srcu_struct_common(ssp, name, key, false);
>  }
>  EXPORT_SYMBOL_GPL(__init_srcu_struct_fast_updown);
>  
>  int __init_srcu_struct_atomic(struct srcu_struct *ssp, const char *name, 
> struct lock_class_key *key)
>  {
>       ssp->srcu_reader_flavor = SRCU_READ_FLAVOR_ATOMIC;
> -     return __init_srcu_struct_common(ssp, name, key);
> +     return __init_srcu_struct_common(ssp, name, key, true);
>  }
>  EXPORT_SYMBOL_GPL(__init_srcu_struct_atomic);
>  
> @@ -414,7 +415,7 @@ EXPORT_SYMBOL_GPL(init_srcu_struct_fast_updown);
>  int init_srcu_struct_atomic(struct srcu_struct *ssp)
>  {
>       ssp->srcu_reader_flavor = SRCU_READ_FLAVOR_ATOMIC;
> -     return init_srcu_struct_fields(ssp, false, false);
> +     return init_srcu_struct_fields(ssp, false, true);
>  }
>  EXPORT_SYMBOL_GPL(init_srcu_struct_atomic);
>  
> -- 
> 2.43.0
> 

Reply via email to