Re: [PATCH v3 3/4] rcu/nocb: Protect NOCB state via local_lock() under PREEMPT_RT

Sebastian Andrzej Siewior
2021-08-17T15:36:21Z

On 2021-08-11 21:13:53 [+0100], Valentin Schneider wrote:
> diff --git a/kernel/rcu/tree_plugin.h b/kernel/rcu/tree_plugin.h
> index 0ff5e4fb933e..11c4ff00afde 100644
> --- a/kernel/rcu/tree_plugin.h
> +++ b/kernel/rcu/tree_plugin.h
> @@ -21,6 +21,17 @@ static inline int rcu_lockdep_is_held_nocb(struct rcu_data *rdp)
> return lockdep_is_held(&rdp->nocb_lock);
> }
>
> +static inline int rcu_lockdep_is_held_nocb_local(struct rcu_data *rdp)
> +{
> + return lockdep_is_held(
> +#ifdef CONFIG_PREEMPT_RT
> + &rdp->nocb_local_lock.lock
> +#else
> + &rdp->nocb_local_lock
> +#endif
> + );
> +}

Now that I see it and Paul asked for it, please just use !RT version.
return lockdep_is_held(&rdp->nocb_local_lock);

and RT will work, too.

> static inline bool rcu_current_is_nocb_kthread(struct rcu_data *rdp)
> {
> /* Race on early boot between thread creation and assignment */
> @@ -1629,6 +1664,22 @@ static void rcu_nocb_unlock_irqrestore(struct rcu_data *rdp,
> }
> }
>
> +/*
> + * The invocation of rcu_core() within the RCU core kthreads remains preemptible
> + * under PREEMPT_RT, thus the offload state of a CPU could change while
> + * said kthreads are preempted. Prevent this from happening by protecting the
> + * offload state with a local_lock().
> + */
> +static void rcu_nocb_local_lock(struct rcu_data *rdp)
> +{
> + local_lock(&rcu_data.nocb_local_lock);
> +}
> +
> +static void rcu_nocb_local_unlock(struct rcu_data *rdp)
> +{
> + local_unlock(&rcu_data.nocb_local_lock);
> +}
> +
Do you need to pass rdp given that it is not used?

> /* Lockdep check that ->cblist may be safely accessed. */
> static void rcu_lockdep_assert_cblist_protected(struct rcu_data *rdp)
> {

Sebastian