[PATCH 0/5] srcu: Add lockdep coverage for atomic SRCU and fix IRQ-state bug

Kunwu Chan posted 5 patches 1 week, 4 days ago
kernel/rcu/rcutorture.c                       | 109 +++++++++++++++++-
kernel/rcu/srcutree.c                         |  42 ++++---
.../selftests/rcutorture/bin/srcu_lockdep.sh  |  77 ++++++++++++-
3 files changed, 205 insertions(+), 23 deletions(-)
[PATCH 0/5] srcu: Add lockdep coverage for atomic SRCU and fix IRQ-state bug
Posted by Kunwu Chan 1 week, 4 days ago
The atomic SRCU fastpath enables synchronize_srcu_atomic() to be called                                   
from contexts with interrupts disabled. This series extends the                                          
rcutorture lockdep tests to cover the atomic SRCU path and fixes an                                       
IRQ-state preservation bug discovered along the way.                                                      
                                                                                                       
Patch 1-2 add lockdep test coverage for atomic SRCU:                                                      
- testtype 4: same-type atomic SRCU deadlock                                                            
- testtype 5: atomic SRCU + raw spinlock dependency cycle                                               
- testtype 6: rcu_read_lock() → synchronize_srcu_atomic()                                               
  legitimate nesting, must not trigger lockdep warning                                                  
                                                                                                       
Patch 3 fixes a bug where the synchronize_srcu_atomic() call chain                                        
unconditionally re-enables interrupts on unlock, by switching to the                                      
irqsave/irqrestore variants throughout the call chain.                                                    
                                                                                                       
Patch 4 fixes a pre-existing double nerrs count in the script.                                            
                                                                                                       
Patch 5 adds testtype 7: cross-CPU IRQ context mismatch detection,                                        
where an atomic SRCU reader held with IRQs enabled on one CPU is                                          
paired with synchronize_srcu_atomic() via IPI on another CPU.
 
Kunwu Chan (5):
  rcutorture: Add atomic SRCU lockdep support
  selftests/rcutorture: Wire atomic SRCU into srcu_lockdep.sh
  srcutree: Preserve IRQ state in synchronize_srcu_atomic() callchain
  selftests/rcutorture: Fix double nerrs count in srcu_lockdep.sh
  rcutorture: Add atomic SRCU cross-CPU IRQ context mismatch test

 kernel/rcu/rcutorture.c                       | 109 +++++++++++++++++-
 kernel/rcu/srcutree.c                         |  42 ++++---
 .../selftests/rcutorture/bin/srcu_lockdep.sh  |  77 ++++++++++++-
 3 files changed, 205 insertions(+), 23 deletions(-)

-- 
2.43.0

Re: [PATCH 0/5] srcu: Add lockdep coverage for atomic SRCU and fix IRQ-state bug
Posted by Boqun Feng 3 days, 13 hours ago
On Mon, Sep 14, 2026 at 05:34:14PM +0800, Kunwu Chan wrote:
> The atomic SRCU fastpath enables synchronize_srcu_atomic() to be called                                   
> from contexts with interrupts disabled. This series extends the                                          
> rcutorture lockdep tests to cover the atomic SRCU path and fixes an                                       
> IRQ-state preservation bug discovered along the way.                                                      
>                                                                                                        
> Patch 1-2 add lockdep test coverage for atomic SRCU:                                                      
> - testtype 4: same-type atomic SRCU deadlock                                                            
> - testtype 5: atomic SRCU + raw spinlock dependency cycle                                               
> - testtype 6: rcu_read_lock() -> synchronize_srcu_atomic()                                               
>   legitimate nesting, must not trigger lockdep warning                                                  
>                                                                                                        
> Patch 3 fixes a bug where the synchronize_srcu_atomic() call chain                                        
> unconditionally re-enables interrupts on unlock, by switching to the                                      
> irqsave/irqrestore variants throughout the call chain.                                                    
>                                                                                                        
> Patch 4 fixes a pre-existing double nerrs count in the script.                                            
>                                                                                                        
> Patch 5 adds testtype 7: cross-CPU IRQ context mismatch detection,                                        
> where an atomic SRCU reader held with IRQs enabled on one CPU is                                          
> paired with synchronize_srcu_atomic() via IPI on another CPU.
>  

Acked-by: Boqun Feng <boqun@kernel.org>

Regards,
Boqun

> Kunwu Chan (5):
>   rcutorture: Add atomic SRCU lockdep support
>   selftests/rcutorture: Wire atomic SRCU into srcu_lockdep.sh
>   srcutree: Preserve IRQ state in synchronize_srcu_atomic() callchain
>   selftests/rcutorture: Fix double nerrs count in srcu_lockdep.sh
>   rcutorture: Add atomic SRCU cross-CPU IRQ context mismatch test
> 
>  kernel/rcu/rcutorture.c                       | 109 +++++++++++++++++-
>  kernel/rcu/srcutree.c                         |  42 ++++---
>  .../selftests/rcutorture/bin/srcu_lockdep.sh  |  77 ++++++++++++-
>  3 files changed, 205 insertions(+), 23 deletions(-)
> 
> -- 
> 2.43.0
> 
>
Re: [PATCH 0/5] srcu: Add lockdep coverage for atomic SRCU and fix IRQ-state bug
Posted by Paul E. McKenney 3 days, 12 hours ago
On Mon, Sep 21, 2026 at 10:27:29PM +0200, Boqun Feng wrote:
> On Mon, Sep 14, 2026 at 05:34:14PM +0800, Kunwu Chan wrote:
> > The atomic SRCU fastpath enables synchronize_srcu_atomic() to be called
> > from contexts with interrupts disabled. This series extends the
> > rcutorture lockdep tests to cover the atomic SRCU path and fixes an
> > IRQ-state preservation bug discovered along the way.
> >
> > Patch 1-2 add lockdep test coverage for atomic SRCU:
> > - testtype 4: same-type atomic SRCU deadlock
> > - testtype 5: atomic SRCU + raw spinlock dependency cycle
> > - testtype 6: rcu_read_lock() -> synchronize_srcu_atomic()
> >   legitimate nesting, must not trigger lockdep warning
> >
> > Patch 3 fixes a bug where the synchronize_srcu_atomic() call chain
> > unconditionally re-enables interrupts on unlock, by switching to the
> > irqsave/irqrestore variants throughout the call chain.
> >
> > Patch 4 fixes a pre-existing double nerrs count in the script.
> >
> > Patch 5 adds testtype 7: cross-CPU IRQ context mismatch detection,
> > where an atomic SRCU reader held with IRQs enabled on one CPU is
> > paired with synchronize_srcu_atomic() via IPI on another CPU.
>
> Acked-by: Boqun Feng <boqun@kernel.org>

Queued for testing and further review, thank you both!

						Thanx, Paul

> Regards,
> Boqun
>
> > Kunwu Chan (5):
> >   rcutorture: Add atomic SRCU lockdep support
> >   selftests/rcutorture: Wire atomic SRCU into srcu_lockdep.sh
> >   srcutree: Preserve IRQ state in synchronize_srcu_atomic() callchain
> >   selftests/rcutorture: Fix double nerrs count in srcu_lockdep.sh
> >   rcutorture: Add atomic SRCU cross-CPU IRQ context mismatch test
> >
> >  kernel/rcu/rcutorture.c                       | 109 +++++++++++++++++-
> >  kernel/rcu/srcutree.c                         |  42 ++++---
> >  .../selftests/rcutorture/bin/srcu_lockdep.sh  |  77 ++++++++++++-
> >  3 files changed, 205 insertions(+), 23 deletions(-)
> >
> > --
> > 2.43.0
> >
> >