• Tom Parkin's avatar
    net/l2tp: convert tunnel rwlock_t to rcu · 07b8ca37
    Tom Parkin authored
    Previously commit e02d494d ("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: default avatarTom Parkin <tparkin@katalix.com>
    Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
    07b8ca37
l2tp_core.c 44.7 KB