Skip to contentSkip to conversation

xfrm: state lookup can be lockless

PATCH Applied Florian Westphal 2 participants 2 messages Sep 20, 2016 – Sep 22, 2016

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 xfrm: state lookup can be lockless

This is called from the packet input path, we get lock contention if many cpus handle ipsec in parallel.

After recent rcu conversion it is safe to call __xfrm_state_lookup without the spinlock.

---
 net/xfrm/xfrm_state.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
net/xfrm/xfrm_state.c +2 -2
index ba8bf51..a38fdea 100644
@@ -1431,9 +1431,9 @@ xfrm_state_lookup(struct net *net, u32 mark, const xfrm_address_t *daddr, __be32
 {
 	struct xfrm_state *x;
 
-	spin_lock_bh(&net->xfrm.xfrm_state_lock);
+	rcu_read_lock();
 	x = __xfrm_state_lookup(net, mark, daddr, spi, proto, family);
-	spin_unlock_bh(&net->xfrm.xfrm_state_lock);
+	rcu_read_unlock();
 	return x;
 }
 EXPORT_SYMBOL(xfrm_state_lookup);
Signature · 1 line
2.7.3
maintainer Applied
#1 lore raw
Quoted 7 lines · Florian Westphal

This is called from the packet input path, we get lock contention if many cpus handle ipsec in parallel.

After recent rcu conversion it is safe to call __xfrm_state_lookup without the spinlock.

Applied to ipsec-next, thanks a lot!