From: Kunwu Chan <[email protected]>

Atomic SRCU must remain in the small size state. Warn if this
invariant is violated and avoid transitioning to big in that case.

[ paulmck: Folded "if" onto one line for 100-character limit. ]

Signed-off-by: Kunwu Chan <[email protected]>
Signed-off-by: Paul E. McKenney <[email protected]>
Reviewed-by: Bradley Morgan <[email protected]>
---
 kernel/rcu/srcutree.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/kernel/rcu/srcutree.c b/kernel/rcu/srcutree.c
index 4e9a0b8ea344..6a05bd8a6f39 100644
--- a/kernel/rcu/srcutree.c
+++ b/kernel/rcu/srcutree.c
@@ -1073,8 +1073,10 @@ 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.40.1


Reply via email to