Subject: Re: [PATCH] net: dst_release() cleanup

From: Eric Dumazet <[email-masked]>
Date: Mon, 07 Dec 2009 19:12:03 +0100

Stephen Hemminger a écrit :
 
> I don't like to put actual necessary code in WARN or BUG macro
> args because some embedded type developer is likely to build
> with
> 
> #define WARN_ON(x)
> 
> to get rid of all warnings.

Oops, I thought WARN_ON(X) must evaluate X once, my bad, since its not documented.

Thanks

[PATCH] net: dst_release() cleanup

atomic_dec_return() is a full memory barrier, we can omit
the smp_mb__before_atomic_dec() call.

Signed-off-by: Eric Dumazet <[email-masked]>
---
diff --git a/net/core/dst.c b/net/core/dst.c
index 57bc4d5..c3d0cfa 100644
--- a/net/core/dst.c
+++ b/net/core/dst.c
@@ -263,11 +263,9 @@ again:
 void dst_release(struct dst_entry *dst)
 {
 	if (dst) {
-               int newrefcnt;
+		int newrefcnt = atomic_dec_return(&dst->__refcnt);
 
-		smp_mb__before_atomic_dec();
-               newrefcnt = atomic_dec_return(&dst->__refcnt);
-               WARN_ON(newrefcnt < 0);
+		WARN_ON(newrefcnt < 0);
 	}
 }
 EXPORT_SYMBOL(dst_release);