Skip to content

Commit

Permalink
xfrm: avoid spinlock in get_acqseq()
Browse files Browse the repository at this point in the history
Use atomic_inc_return() in get_acqseq() to avoid taking a spinlock

Signed-off-by: Eric Dumazet <[email protected]>
Signed-off-by: David S. Miller <[email protected]>
  • Loading branch information
Eric Dumazet authored and davem330 committed Feb 2, 2010
1 parent d1c9ae6 commit 28aecb9
Showing 1 changed file with 4 additions and 5 deletions.
9 changes: 4 additions & 5 deletions net/key/af_key.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand Down

0 comments on commit 28aecb9

Please sign in to comment.