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)
commit07b8ca3792dec6bc3288b08ff85d80b5330de1d6
treec81885305ce539395a579ca6e009d21ed4d7fdfe
parent275f37ea50acdda09cc0863b8a0edcaaf1ae7f23
net/l2tp: convert tunnel rwlock_t to rcu

Previously commit e02d494d2c60 ("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