lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-Id: <1295929298-13163-1-git-send-email-xiaosuo@gmail.com>
Date:	Tue, 25 Jan 2011 12:21:38 +0800
From:	Changli Gao <xiaosuo@...il.com>
To:	"David S. Miller" <davem@...emloft.net>
Cc:	Alexey Kuznetsov <kuznet@....inr.ac.ru>,
	"Pekka Savola (ipv6)" <pekkas@...core.fi>,
	James Morris <jmorris@...ei.org>,
	Hideaki YOSHIFUJI <yoshfuji@...ux-ipv6.org>,
	Patrick McHardy <kaber@...sh.net>, netdev@...r.kernel.org,
	Changli Gao <xiaosuo@...il.com>
Subject: [PATCH] net: remove tests on 64bit platforms

On 64bit platforms, >31 bit shifting of a unsigned long variable is
valid, so we can remove the related boundary tests, which may slow
down the CPU if branch prediction fails.

The size of text becomes smaller:
before:
   text	   data	    bss	    dec	    hex	filename
  15721	     16	     16	  15753	   3d89	net/ipv4/fib_trie.o
after:
   text	   data	    bss	    dec	    hex	filename
  15656	     16	     16	  15688	   3d48	net/ipv4/fib_trie.o

Signed-off-by: Changli Gao <xiaosuo@...il.com>
---
 net/ipv4/fib_trie.c |    8 ++++++++
 1 file changed, 8 insertions(+)
diff --git a/net/ipv4/fib_trie.c b/net/ipv4/fib_trie.c
index 0f28034..95c8bb3 100644
--- a/net/ipv4/fib_trie.c
+++ b/net/ipv4/fib_trie.c
@@ -219,15 +219,23 @@ static inline int tnode_child_length(const struct tnode *tn)
 
 static inline t_key mask_pfx(t_key k, unsigned short l)
 {
+#if BITS_PER_LONG > 32
+	return ((u64)k) >> (KEYLENGTH-l) << (KEYLENGTH-l);
+#else
 	return (l == 0) ? 0 : k >> (KEYLENGTH-l) << (KEYLENGTH-l);
+#endif
 }
 
 static inline t_key tkey_extract_bits(t_key a, int offset, int bits)
 {
+#if BITS_PER_LONG > 32
+	return (t_key)((u64)a << offset) >> (KEYLENGTH - bits);
+#else
 	if (offset < KEYLENGTH)
 		return ((t_key)(a << offset)) >> (KEYLENGTH - bits);
 	else
 		return 0;
+#endif
 }
 
 static inline int tkey_equals(t_key a, t_key b)
--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ