On Sat, Sep 12, 2026 at 12:37 AM Paul E. McKenney <[email protected]> wrote: > > On Fri, Sep 11, 2026 at 03:21:25PM +0800, Kunwu Chan wrote: > > Atomic SRCU must remain in the small size state. Warn if this > > invariant is violated and avoid transitioning to big in that case. > > > > Signed-off-by: Kunwu Chan <[email protected]> > > Very good, queued for further testing and review, thank you! > > I folded the new "if" statement onto one line because some years back the > Linux kernel liberated itself from the 80-column constraint imposed by IBM > back in 1928. We can now have up to 100 characters in a line of code. ;-)
Thanks, Paul. And thanks for sharing that interesting bit of kernel history! I didn't know about the IBM 80-column constraint from 1928. I had assumed that 80 columns was still the current convention, so it's good to know we can use up to 100 now. ;-) Thanks, Kunwu > > Thanx, Paul > > > --- > > Changes since v2: > > - Also prevent the transition when the atomic SRCU size-state > > invariant is violated, per Paul McKenney's suggestion. > > -v2: > > https://lore.kernel.org/rcu/[email protected]/ > > > > Changes since v1: > > - Drop the !is_atomic guard from v1 and add WARN_ON_ONCE() instead, > > per Paul McKenney's suggestion. > > - v1: > > https://lore.kernel.org/rcu/[email protected]/ > > --- > > kernel/rcu/srcutree.c | 7 +++++-- > > 1 file changed, 5 insertions(+), 2 deletions(-) > > > > diff --git a/kernel/rcu/srcutree.c b/kernel/rcu/srcutree.c > > index 84c022ec8e09..07db4e459b30 100644 > > --- a/kernel/rcu/srcutree.c > > +++ b/kernel/rcu/srcutree.c > > @@ -1073,8 +1073,11 @@ static void srcu_gp_end(struct srcu_struct *ssp, > > bool is_atomic) > > raw_spin_unlock_irq_rcu_node(sup); > > } > > > > - /* Transition to big if needed. */ > > - if (ss_state != SRCU_SIZE_SMALL && ss_state != SRCU_SIZE_BIG) { > > + /* Transition to big if needed, but never for atomic SRCU. */ > > + if (ssp->srcu_reader_flavor == SRCU_READ_FLAVOR_ATOMIC && > > + ss_state != SRCU_SIZE_SMALL) { > > + WARN_ON_ONCE(1); > > + } else if (ss_state != SRCU_SIZE_SMALL && ss_state != SRCU_SIZE_BIG) { > > if (ss_state == SRCU_SIZE_ALLOC) > > init_srcu_struct_nodes(ssp, GFP_KERNEL); > > else > > -- > > 2.43.0 > > > >

