On Thu, Jun 25, 2026 at 08:42:54PM -0400, Joel Fernandes wrote:
> Currently rdp->defer_qs_pending transitions from DEFER_QS_PENDING to
> DEFER_QS_IDLE at two sites: rcu_preempt_deferred_qs_irqrestore() and
> rcu_preempt_deferred_qs_handler() (depth>0 reset). Both write the
> IDLE value directly.
>
> Introduce a single inline helper rcu_defer_qs_clear() in tree.h and
> route both sites through it. This becomes the single
> PENDING->IDLE transition point for upcoming work.
>
> Signed-off-by: Joel Fernandes <[email protected]>
No argument here, and I have pulled this in for further review and
testing. I don't see any reason why thing cannot go into the upcoming
merge window.
Thanx, Paul
> ---
> kernel/rcu/tree.h | 5 +++++
> kernel/rcu/tree_plugin.h | 4 ++--
> 2 files changed, 7 insertions(+), 2 deletions(-)
>
> diff --git a/kernel/rcu/tree.h b/kernel/rcu/tree.h
> index 750b98f0c6bc..dc03231b2d46 100644
> --- a/kernel/rcu/tree.h
> +++ b/kernel/rcu/tree.h
> @@ -311,6 +311,11 @@ struct rcu_data {
> int cpu;
> };
>
> +static inline void rcu_defer_qs_clear(struct rcu_data *rdp)
> +{
> + WRITE_ONCE(rdp->defer_qs_pending, DEFER_QS_IDLE);
> +}
> +
> /* Values for nocb_defer_wakeup field in struct rcu_data. */
> #define RCU_NOCB_WAKE_NOT 0
> #define RCU_NOCB_WAKE_BYPASS 1
> diff --git a/kernel/rcu/tree_plugin.h b/kernel/rcu/tree_plugin.h
> index c22f033e0136..7555022bf38a 100644
> --- a/kernel/rcu/tree_plugin.h
> +++ b/kernel/rcu/tree_plugin.h
> @@ -582,7 +582,7 @@ rcu_preempt_deferred_qs_irqrestore(struct task_struct *t,
> unsigned long flags)
>
> rdp = this_cpu_ptr(&rcu_data);
> if (rdp->defer_qs_pending == DEFER_QS_PENDING)
> - rdp->defer_qs_pending = DEFER_QS_IDLE;
> + rcu_defer_qs_clear(rdp);
>
> /*
> * If RCU core is waiting for this CPU to exit its critical section,
> @@ -725,7 +725,7 @@ static void rcu_preempt_deferred_qs_handler(struct
> irq_work *iwp)
> * 5. Deferred QS reporting does not happen.
> */
> if (rcu_preempt_depth() > 0)
> - WRITE_ONCE(rdp->defer_qs_pending, DEFER_QS_IDLE);
> + rcu_defer_qs_clear(rdp);
> }
>
> /*
> --
> 2.34.1
>