Thread (42 messages) 42 messages, 5 authors, 2009-02-20

Re: [PATCH] netfilter: unfold two critical loops in ip_packet_match()

From: Andi Kleen <hidden>
Date: 2009-01-30 15:48:04
Also in: netfilter-devel

Eric Dumazet [off-list ref] writes:
While doing oprofile tests I noticed two loops are not properly unrolled by gcc
That's because nobody passed -funroll-loops. Did you try that for
that file? Likely will need -O2 too
+static unsigned long ifname_compare(const void *_a, const void *_b, const void *_mask)
+{
+	const unsigned long *a = (const unsigned long *)_a;
+	const unsigned long *b = (const unsigned long *)_b;
+	const unsigned long *mask = (const unsigned long *)_mask;
+	unsigned long ret;
+
+	ret = (a[0] ^ b[0]) & mask[0];
+	ret |= (a[1] ^ b[1]) & mask[1];
+	if (IFNAMSIZ > 2 * sizeof(unsigned long))
+		ret |= (a[2] ^ b[2]) & mask[2];
+	if (IFNAMSIZ > 3 * sizeof(unsigned long))
+		ret |= (a[3] ^ b[3]) & mask[3];
That will silently break for IFNAMSIZ >= 4*sizeof(unsigned long)
You should add a dummy loop for that or at least a BUILD_BUG_ON

-Andi

-- 
ak@linux.intel.com -- Speaking for myself only.
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help