Thread (215 messages) 215 messages, 22 authors, 2009-05-01
STALE6279d

[PATCH] netfilter: use likely() in xt_info_rdlock_bh()

From: Eric Dumazet <hidden>
Date: 2009-05-01 08:38:20
Also in: netfilter-devel
Subsystem: netfilter, the rest · Maintainers: Pablo Neira Ayuso, Florian Westphal, Linus Torvalds

David Miller a écrit :
From: Linus Torvalds <torvalds@linux-foundation.org>
Date: Tue, 28 Apr 2009 09:55:32 -0700 (PDT)
quoted
On Tue, 28 Apr 2009, Linus Torvalds wrote:
quoted
Ack. 

It could do with the update from Eric about how non-current CPU writelocks 
only require preemp-disable around get_counters() (and then the 
local_bh_disable() only around the current-CPU case).
Btw, regardless, that's an incremental improvement, and does not negate 
the "Ack" part.
I've applied this, thanks everyone!
Small followup on this one, since the likely() were forgotten.
(I trimmed down CCed list, which was insane)

It makes a difference on my x86_32 machine, gcc-4.4.0

Thank you

[PATCH] netfilter: use likely() in xt_info_rdlock_bh()

Signed-off-by: Eric Dumazet <redacted>
---
diff --git a/include/linux/netfilter/x_tables.h b/include/linux/netfilter/x_tables.h
index 1b2e435..c9efe03 100644
--- a/include/linux/netfilter/x_tables.h
+++ b/include/linux/netfilter/x_tables.h
@@ -472,7 +472,7 @@ static inline void xt_info_rdlock_bh(void)
 
 	local_bh_disable();
 	lock = &__get_cpu_var(xt_info_locks);
-	if (!lock->readers++)
+	if (likely(!lock->readers++))
 		spin_lock(&lock->lock);
 }
 
@@ -480,7 +480,7 @@ static inline void xt_info_rdunlock_bh(void)
 {
 	struct xt_info_lock *lock = &__get_cpu_var(xt_info_locks);
 
-	if (!--lock->readers)
+	if (likely(!--lock->readers))
 		spin_unlock(&lock->lock);
 	local_bh_enable();
 }

--
To unsubscribe from this list: send the line "unsubscribe netfilter-devel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help