Re: [PATCH net-next] ppp: remove rwlock usage
Eric Dumazet <[email protected]> Mon, 4 Aug 2025 00:36:31 -0700
| Newsgroups | gmane.linux.kernel,gmane.linux.ppp,gmane.linux.network |
|---|---|
| Message-ID | <CANn89iJ3Lau_3W5bJdmRWL9BFUf3a40XqNgfjr7nCEu5PQ_otg@mail.gmail.com> |
On Sun, Aug 3, 2025 at 11:20 PM Qingfang Deng <[email protected]> wrote: > > In struct channel, the upl lock is implemented using rwlock_t, > protecting access to pch->ppp and pch->bridge. > > As previously discussed on the list, using rwlock in the network fast > path is not recommended. > This patch replaces the rwlock with a spinlock for writers, and uses RCU > for readers. > > - pch->ppp and pch->bridge are now declared as __rcu pointers. > - Readers use rcu_dereference_bh() under rcu_read_lock_bh(). > - Writers use spin_lock_bh() to update, followed by synchronize_rcu() > where required. > > Signed-off-by: Qingfang Deng <[email protected]> > --- .... For all your patch : Since the spinlock is now only used from the control path in process context, what is the reason you use _bh() suffix blocking BH while holding it ? Also, a mere rcu_read_lock() is enough for ppp_dev_name() and ppp_unit_number() : No need to disable BH there. > - write_lock_bh(&pch->upl); > - ppp = pch->ppp; > - pch->ppp = NULL; > - write_unlock_bh(&pch->upl); > + spin_lock_bh(&pch->upl); > + ppp = rcu_replace_pointer(pch->ppp, NULL, lockdep_is_held(&pch->upl)); > + spin_unlock_bh(&pch->upl); > + synchronize_rcu(); > + > if (ppp) { You probably could move the synchronize_rcu() here, there is no need to call it if ppp is NULL > /* remove it from the ppp unit's list */ > ppp_lock(ppp); > -- > 2.43.0 >