[PATCH v3 3/4] rcu/nocb: Protect NOCB state via local_lock() under PREEMPT_RT
Valentin Schneider
valentin.schneider at arm.com
Sun Aug 22 11:15:32 PDT 2021
On 17/08/21 17:36, Sebastian Andrzej Siewior wrote:
>> +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.
>
The above was required due to the (previous) definition of local_lock_t:
typedef struct {
spinlock_t lock;
} local_lock_t;
On -rt11 I see this is now:
typedef spinlock_t local_lock_t;
which indeed means the iffdefery can (actually it *has* to) go.
>> 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?
>
Not anymore, you're right.
>> /* Lockdep check that ->cblist may be safely accessed. */
>> static void rcu_lockdep_assert_cblist_protected(struct rcu_data *rdp)
>> {
>
> Sebastian
More information about the linux-arm-kernel
mailing list