Re: [RFC][PATCH v3 6/6] rcu/tree: Use irq_work_queue_remote()

From: Peter Zijlstra
Date: Thu Oct 29 2020 - 05:15:49 EST


On Wed, Oct 28, 2020 at 01:15:54PM -0700, Paul E. McKenney wrote:
> On Wed, Oct 28, 2020 at 09:02:43PM +0100, Peter Zijlstra wrote:
> > -#ifdef CONFIG_IRQ_WORK
> > + raw_spin_lock_rcu_node(rnp);
>
> The caller of rcu_implicit_dynticks_qs() already holds this lock.
> Please see the force_qs_rnp() function and its second call site,
> to which rcu_implicit_dynticks_qs() is passed as an argument.

Like this then.

---
Subject: rcu/tree: Use irq_work_queue_remote()
From: Peter Zijlstra <peterz@xxxxxxxxxxxxx>
Date: Wed Oct 28 11:53:40 CET 2020

The effect of an self-IPI here would be setting rcu_iw_gp_seq to the
value we just set it to (pointless) and clearing rcu_iw_pending, which
we just set, so don't set it.

Signed-off-by: Peter Zijlstra (Intel) <peterz@xxxxxxxxxxxxx>
---
kernel/rcu/tree.c | 10 ++++++----
1 file changed, 6 insertions(+), 4 deletions(-)

--- a/kernel/rcu/tree.c
+++ b/kernel/rcu/tree.c
@@ -1204,6 +1204,8 @@ static int rcu_implicit_dynticks_qs(stru
bool *ruqp;
struct rcu_node *rnp = rdp->mynode;

+ raw_lockdep_assert_held_rcu_node(rnp);
+
/*
* If the CPU passed through or entered a dynticks idle phase with
* no active irq/NMI handlers, then we can safely pretend that the CPU
@@ -1308,14 +1310,14 @@ static int rcu_implicit_dynticks_qs(stru
resched_cpu(rdp->cpu);
WRITE_ONCE(rdp->last_fqs_resched, jiffies);
}
-#ifdef CONFIG_IRQ_WORK
if (!rdp->rcu_iw_pending && rdp->rcu_iw_gp_seq != rnp->gp_seq &&
(rnp->ffmask & rdp->grpmask)) {
- rdp->rcu_iw_pending = true;
rdp->rcu_iw_gp_seq = rnp->gp_seq;
- irq_work_queue_on(&rdp->rcu_iw, rdp->cpu);
+ if (likely(rdp->cpu != smp_processor_id())) {
+ rdp->rcu_iw_pending = true;
+ irq_work_queue_remote(rdp->cpu, &rdp->rcu_iw);
+ }
}
-#endif
}

return 0;