]> git.baikalelectronics.ru Git - kernel.git/commit
net/l2tp: convert tunnel rwlock_t to rcu
authorTom Parkin <tparkin@katalix.com>
Fri, 26 Nov 2021 16:09:03 +0000 (16:09 +0000)
committerDavid S. Miller <davem@davemloft.net>
Mon, 29 Nov 2021 12:11:25 +0000 (12:11 +0000)
commitb5b0b19e02b8bb36097669b4b58a0e21a09b3f8a
treec81885305ce539395a579ca6e009d21ed4d7fdfe
parente229c5c679b389bb6b88fcb5f81f6a03cd216ddc
net/l2tp: convert tunnel rwlock_t to rcu

Previously commit 63edf8f6b927 ("l2tp: Convert rwlock to RCU") converted
most, but not all, rwlock instances in the l2tp subsystem to RCU.

The remaining rwlock protects the per-tunnel hashlist of sessions which
is used for session lookups in the UDP-encap data path.

Convert the remaining rwlock to rcu to improve performance of UDP-encap
tunnels.

Note that the tunnel and session, which both live on RCU-protected
lists, use slightly different approaches to incrementing their refcounts
in the various getter functions.

The tunnel has to use refcount_inc_not_zero because the tunnel shutdown
process involves dropping the refcount to zero prior to synchronizing
RCU readers (via. kfree_rcu).

By contrast, the session shutdown removes the session from the list(s)
it is on, synchronizes with readers, and then decrements the session
refcount.  Since the getter functions increment the session refcount
with the RCU read lock held we prevent getters seeing a zero session
refcount, and therefore don't need to use refcount_inc_not_zero.

Signed-off-by: Tom Parkin <tparkin@katalix.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
net/l2tp/l2tp_core.c
net/l2tp/l2tp_core.h
net/l2tp/l2tp_debugfs.c