Browse Source

xfrm: avoid spinlock in get_acqseq()

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>
imx_3.10.17_1.0.0_ga
Eric Dumazet 11 years ago
committed by David S. Miller
parent
commit
28aecb9d77
1 changed files with 4 additions and 5 deletions
  1. +4
    -5
      net/key/af_key.c

+ 4
- 5
net/key/af_key.c View 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;
}


Loading…
Cancel
Save