Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

xfrm: avoid spinlock in get_acqseq() used by xfrm user

Eric's version fixed it for pfkey. This one is for xfrm user.
I thought about amortizing those two get_acqseq()s but it seems
reasonable to have two of these sequence spaces for the two different
interfaces.

cheers,
jamal
commit d5168d5addbc999c94aacda8f28a4a173756a72b
Author: Jamal Hadi Salim <hadi@cyberus.ca>
Date: Tue Feb 16 06:51:22 2010 -0500

xfrm: avoid spinlock in get_acqseq() used by xfrm user

This is in the same spirit as commit 28aecb9d7728dc26bf03ce7925fe622023a83a2a
by Eric Dumazet.
Use atomic_inc_return() in get_acqseq() to avoid taking a spinlock

Signed-off-by: Jamal Hadi Salim <hadi@cyberus.ca>
Acked-by: Eric Dumazet <eric.dumazet@gmail.com>

Signed-off-by: David S. Miller <davem@davemloft.net>

authored by

jamal and committed by
David S. Miller
6836b9bd e06d41d0

+5 -5
+5 -5
net/xfrm/xfrm_state.c
··· 1462 1462 u32 xfrm_get_acqseq(void) 1463 1463 { 1464 1464 u32 res; 1465 - static u32 acqseq; 1466 - static DEFINE_SPINLOCK(acqseq_lock); 1465 + static atomic_t acqseq; 1467 1466 1468 - spin_lock_bh(&acqseq_lock); 1469 - res = (++acqseq ? : ++acqseq); 1470 - spin_unlock_bh(&acqseq_lock); 1467 + do { 1468 + res = atomic_inc_return(&acqseq); 1469 + } while (!res); 1470 + 1471 1471 return res; 1472 1472 } 1473 1473 EXPORT_SYMBOL(xfrm_get_acqseq);