netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] xfrm: avoid spinlock in get_acqseq()
@ 2010-01-29 14:05 Eric Dumazet
  2010-01-29 15:11 ` Benjamin LaHaise
  2010-02-02 23:59 ` David Miller
  0 siblings, 2 replies; 5+ messages in thread
From: Eric Dumazet @ 2010-01-29 14:05 UTC (permalink / raw)
  To: David Miller; +Cc: netdev

Use atomic_inc_return() in get_acqseq() to avoid taking a spinlock

Signed-off-by: Eric Dumazet <eric.dumazet@gmail.com>
---

diff --git a/net/key/af_key.c b/net/key/af_key.c
index 4744b1f..e2aacf0 100644
--- a/net/key/af_key.c
+++ b/net/key/af_key.c
@@ -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;
 }
 



^ permalink raw reply related	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2010-02-02 23:59 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-01-29 14:05 [PATCH] xfrm: avoid spinlock in get_acqseq() Eric Dumazet
2010-01-29 15:11 ` Benjamin LaHaise
2010-01-29 16:00   ` Eric Dumazet
2010-01-29 17:01     ` Benjamin LaHaise
2010-02-02 23:59 ` David Miller

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).