rcu: Remove local_irq_save/restore() in rcu_preempt_deferred_qs_handler()
Zqiang
reviewerPATCH v2 1/1 rcu: Remove local_irq_save/restore() in rcu_preempt_deferred_qs_handler()
Currently, the per-cpu rcu_data structure's->defer_qs_iw is initialized by IRQ_WORK_INIT_HARD(), this means the rcu_preempt_deferred_qs_handler() always be executed in the hardirq context of irq-disabled. This commit therefore remove local_irq_save/restore() operations in rcu_preempt_deferred_qs_handler() and add lockdep_assert_irqs_disabled() check, if someone mistakenly invokes this function in hardirq enabled context will splat.
--- kernel/rcu/tree_plugin.h | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-)
kernel/rcu/tree_plugin.h +1 -4
@@ -626,11 +626,10 @@ notrace void rcu_preempt_deferred_qs(struct task_struct *t)*/ static void rcu_preempt_deferred_qs_handler (struct irq_work *iwp) { -unsigned long flags;struct rcu_data *rdp; +lockdep_assert_irqs_disabled (); rdp = container_of(iwp, struct rcu_data, defer_qs_iw); -local_irq_save (flags);/* * If the IRQ work handler happens to run in the middle of RCU read-side
@@ -647,8 +646,6 @@ static void rcu_preempt_deferred_qs_handler(struct irq_work *iwp)*/ if (rcu_preempt_depth () >0 )WRITE_ONCE (rdp->defer_qs_iw_pending,DEFER_QS_IDLE ); - -local_irq_restore (flags); }/*
Signature · 1 line
2.48.1
Paul E. McKenney
maintainerQuoted 9 lines · Zqiang
Currently, the per-cpu
rcu_datastructure's->defer_qs_iw is initialized byIRQ_WORK_INIT_HARD(), this means thercu_preempt_deferred_qs_handler()always be executed in the hardirq context of irq-disabled. This commit therefore remove local_irq_save/restore() operations inrcu_preempt_deferred_qs_handler()and addlockdep_assert_irqs_disabled()check, if someone mistakenly invokes this function in hardirq enabled context will splat.Signed-off-by Zqiang <[email protected]>
Queued for further review and testing. With luck, this will make the v6.18 merge window. I could not resist editing the commit log, so could you please check whether I messed something up?
Thanx, Paul
------------------------------------------------------------------------
commit 523e71ba3007f8f7c260b9c2baf69c9461a84f55
Author: Zqiang <[email protected]> Date: Wed Aug 13 21:30:02 2025 +0800
rcu: Remove local_irq_save/restore() in rcu_preempt_deferred_qs_handler()
The per-CPU rcu_data structure's ->defer_qs_iw field is initialized by IRQ_WORK_INIT_HARD(), which means that the subsequent invocation of rcu_preempt_deferred_qs_handler() will always be executed with interrupts disabled. This commit therefore removes the local_irq_save/restore() operations from rcu_preempt_deferred_qs_handler() and adds a call to lockdep_assert_irqs_disabled() in order to enable lockdep to diagnose mistaken invocations of this function from interrupts-enabled code.
kernel/rcu/tree_plugin.h +1 -4
@@ -626,11 +626,10 @@ notrace void rcu_preempt_deferred_qs(struct task_struct *t)*/ static void rcu_preempt_deferred_qs_handler (struct irq_work *iwp) { -unsigned long flags;struct rcu_data *rdp; +lockdep_assert_irqs_disabled (); rdp = container_of(iwp, struct rcu_data, defer_qs_iw); -local_irq_save (flags);/* * If the IRQ work handler happens to run in the middle of RCU read-side
@@ -647,8 +646,6 @@ static void rcu_preempt_deferred_qs_handler(struct irq_work *iwp)*/ if (rcu_preempt_depth () >0 )WRITE_ONCE (rdp->defer_qs_iw_pending,DEFER_QS_IDLE ); - -local_irq_restore (flags); }/*
Zqiang
reviewerQuoted 12 lines · Zqiang
Quoted 10 lines
Currently, the per-cpu
rcu_datastructure's->defer_qs_iw is initialized by
IRQ_WORK_INIT_HARD(), this means thercu_preempt_deferred_qs_handler()always be executed in the hardirq context of irq-disabled. This commit therefore remove local_irq_save/restore() operations inrcu_preempt_deferred_qs_handler()and addlockdep_assert_irqs_disabled()check, if someone mistakenly invokes this function in hardirq enabled context will splat.
Quoted 5 lines
Quoted 2 lines
Signed-off-by Zqiang <[email protected]>Queued for further review and testing. With luck, this will make the v6.18 merge window. I could not resist editing the commit log, so could you please check whether I messed something up?
No problem, thanks for editing the commit log :) .
Thanks
Zqiang
Quoted 49 lines
Thanx, Paul
------------------------------------------------------------------------
commit
523e71ba3007f8f7c260b9c2baf69c9461a84f55
Author: Zqiang <[email protected]>
Date: Wed Aug 13 21:30:02 2025 +0800rcu: Remove local_irq_save/restore() in
rcu_preempt_deferred_qs_handler()The per-CPU
rcu_datastructure's ->defer_qs_iw field is initialized byIRQ_WORK_INIT_HARD(), which means that the subsequent invocation ofrcu_preempt_deferred_qs_handler()will always be executed with interrupts disabled. This commit therefore removes the local_irq_save/restore() operations fromrcu_preempt_deferred_qs_handler()and adds a call tolockdep_assert_irqs_disabled()in order to enable lockdep to diagnose mistaken invocations of this function from interrupts-enabled code.Signed-off-by Zqiang <[email protected]>Signed-off-by Paul E. McKenney <[email protected]>kernel/rcu/tree_plugin.h +1
-4@@ -626,11 +626,10 @@ notrace void rcu_preempt_deferred_qs(struct task_struct *t)*/ static void rcu_preempt_deferred_qs_handler (struct irq_work *iwp) { -unsigned long flags;struct rcu_data *rdp; +lockdep_assert_irqs_disabled (); rdp = container_of(iwp, struct rcu_data, defer_qs_iw); -local_irq_save (flags);/* * If the IRQ work handler happens to run in the middle of RCU read-side @@ -647,8 +646,6 @@ static void rcu_preempt_deferred_qs_handler(struct irq_work *iwp)*/ if (rcu_preempt_depth () >0 )WRITE_ONCE (rdp->defer_qs_iw_pending,DEFER_QS_IDLE ); - -local_irq_restore (flags); }/*