xfrm: avoid spinlock in get_acqseq()
authorEric Dumazet <eric.dumazet@gmail.com>
Fri, 29 Jan 2010 04:05:52 +0000 (04:05 +0000)
committerDavid S. Miller <davem@davemloft.net>
Tue, 2 Feb 2010 23:55:41 +0000 (15:55 -0800)
Use atomic_inc_return() in get_acqseq() to avoid taking a spinlock

Signed-off-by: Eric Dumazet <eric.dumazet@gmail.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
net/key/af_key.c

index 4744b1f6372f9c6c7de7bd4ad38ec1c8d676b49d..e2aacf0ba013047fb15d86a2b2a0e07f38580633 100644 (file)
@@ -3019,12 +3019,11 @@ static int pfkey_send_policy_notify(struct xfrm_policy *xp, int dir, struct km_e
 static u32 get_acqseq(void)
 {
        u32 res;
-       static u32 acqseq;
-       static DEFINE_SPINLOCK(acqseq_lock);
+       static atomic_t acqseq;
 
-       spin_lock_bh(&acqseq_lock);
-       res = (++acqseq ? : ++acqseq);
-       spin_unlock_bh(&acqseq_lock);
+       do {
+               res = atomic_inc_return(&acqseq);
+       } while (!res);
        return res;
 }