2020-05-13 16:49:20

by Frederic Weisbecker

[permalink] [raw]
Subject: [PATCH 03/10] rcu: Make locking explicit in do_nocb_deferred_wakeup_common()

It can either be called inline (locally or CPU hotplug locked) when
rdp->nocb_defer_wakeup is pending or from the nocb timer. In both cases
the rdp is offlined and we want to take the nocb lock.

Clarify the locking rules and expectations.

Signed-off-by: Frederic Weisbecker <[email protected]>
Cc: Paul E. McKenney <[email protected]>
Cc: Josh Triplett <[email protected]>
Cc: Steven Rostedt <[email protected]>
Cc: Mathieu Desnoyers <[email protected]>
Cc: Lai Jiangshan <[email protected]>
Cc: Joel Fernandes <[email protected]>
---
kernel/rcu/tree_plugin.h | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/kernel/rcu/tree_plugin.h b/kernel/rcu/tree_plugin.h
index 1d22b16c03e0..1dd3fdd675a1 100644
--- a/kernel/rcu/tree_plugin.h
+++ b/kernel/rcu/tree_plugin.h
@@ -2142,9 +2142,9 @@ static void do_nocb_deferred_wakeup_common(struct rcu_data *rdp)
unsigned long flags;
int ndw;

- rcu_nocb_lock_irqsave(rdp, flags);
+ raw_spin_lock_irqsave(&rdp->nocb_lock, flags);
if (!rcu_nocb_need_deferred_wakeup(rdp)) {
- rcu_nocb_unlock_irqrestore(rdp, flags);
+ raw_spin_unlock_irqrestore(&rdp->nocb_lock, flags);
return;
}
ndw = READ_ONCE(rdp->nocb_defer_wakeup);
--
2.25.0


2020-05-26 23:25:12

by Joel Fernandes

[permalink] [raw]
Subject: Re: [PATCH 03/10] rcu: Make locking explicit in do_nocb_deferred_wakeup_common()

On Wed, May 13, 2020 at 06:47:07PM +0200, Frederic Weisbecker wrote:
> It can either be called inline (locally or CPU hotplug locked) when
> rdp->nocb_defer_wakeup is pending or from the nocb timer. In both cases
> the rdp is offlined and we want to take the nocb lock.

s/offlined/offloaded/

thanks,

- Joel

>
> Clarify the locking rules and expectations.
>
> Signed-off-by: Frederic Weisbecker <[email protected]>
> Cc: Paul E. McKenney <[email protected]>
> Cc: Josh Triplett <[email protected]>
> Cc: Steven Rostedt <[email protected]>
> Cc: Mathieu Desnoyers <[email protected]>
> Cc: Lai Jiangshan <[email protected]>
> Cc: Joel Fernandes <[email protected]>
> ---
> kernel/rcu/tree_plugin.h | 4 ++--
> 1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/kernel/rcu/tree_plugin.h b/kernel/rcu/tree_plugin.h
> index 1d22b16c03e0..1dd3fdd675a1 100644
> --- a/kernel/rcu/tree_plugin.h
> +++ b/kernel/rcu/tree_plugin.h
> @@ -2142,9 +2142,9 @@ static void do_nocb_deferred_wakeup_common(struct rcu_data *rdp)
> unsigned long flags;
> int ndw;
>
> - rcu_nocb_lock_irqsave(rdp, flags);
> + raw_spin_lock_irqsave(&rdp->nocb_lock, flags);
> if (!rcu_nocb_need_deferred_wakeup(rdp)) {
> - rcu_nocb_unlock_irqrestore(rdp, flags);
> + raw_spin_unlock_irqrestore(&rdp->nocb_lock, flags);
> return;
> }
> ndw = READ_ONCE(rdp->nocb_defer_wakeup);
> --
> 2.25.0
>

2020-05-27 00:04:40

by Joel Fernandes

[permalink] [raw]
Subject: Re: [PATCH 03/10] rcu: Make locking explicit in do_nocb_deferred_wakeup_common()

On Wed, May 13, 2020 at 06:47:07PM +0200, Frederic Weisbecker wrote:
> It can either be called inline (locally or CPU hotplug locked) when
> rdp->nocb_defer_wakeup is pending or from the nocb timer. In both cases
> the rdp is offlined and we want to take the nocb lock.
>
> Clarify the locking rules and expectations.

And you did inline the code in the locking helper already as I was suggesting
in 01/10. :-) So that's settled ;-)

thanks,

- Joel

>
> Signed-off-by: Frederic Weisbecker <[email protected]>
> Cc: Paul E. McKenney <[email protected]>
> Cc: Josh Triplett <[email protected]>
> Cc: Steven Rostedt <[email protected]>
> Cc: Mathieu Desnoyers <[email protected]>
> Cc: Lai Jiangshan <[email protected]>
> Cc: Joel Fernandes <[email protected]>
> ---
> kernel/rcu/tree_plugin.h | 4 ++--
> 1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/kernel/rcu/tree_plugin.h b/kernel/rcu/tree_plugin.h
> index 1d22b16c03e0..1dd3fdd675a1 100644
> --- a/kernel/rcu/tree_plugin.h
> +++ b/kernel/rcu/tree_plugin.h
> @@ -2142,9 +2142,9 @@ static void do_nocb_deferred_wakeup_common(struct rcu_data *rdp)
> unsigned long flags;
> int ndw;
>
> - rcu_nocb_lock_irqsave(rdp, flags);
> + raw_spin_lock_irqsave(&rdp->nocb_lock, flags);
> if (!rcu_nocb_need_deferred_wakeup(rdp)) {
> - rcu_nocb_unlock_irqrestore(rdp, flags);
> + raw_spin_unlock_irqrestore(&rdp->nocb_lock, flags);
> return;
> }
> ndw = READ_ONCE(rdp->nocb_defer_wakeup);
> --
> 2.25.0
>