From: Andi Kleen <ak@suse.de>

Optimize first/node_node

Optimize nodemask_t slightly.  The x86-64 find_first/next_bit uses
__builtin_constant_p on the size argument to special cases small single
long word searches.  But most gccs don't make __builtin_constant_p true
when an argument is passed through an inline function.  Move the constant
into the inline function to avoid this.  This generates a lot better code
for node searches on x86-64.

Signed-off-by: Andi Kleen <ak@suse.de>
Signed-off-by: Andrew Morton <akpm@osdl.org>
---

 25-akpm/include/linux/nodemask.h |   15 +++++++++------
 1 files changed, 9 insertions(+), 6 deletions(-)

diff -puN include/linux/nodemask.h~x86_64-optimize-nodemask-operations-slightly include/linux/nodemask.h
--- 25/include/linux/nodemask.h~x86_64-optimize-nodemask-operations-slightly	Wed Jan 12 15:48:53 2005
+++ 25-akpm/include/linux/nodemask.h	Wed Jan 12 15:48:53 2005
@@ -217,16 +217,19 @@ static inline void __nodes_shift_left(no
 	bitmap_shift_left(dstp->bits, srcp->bits, n, nbits);
 }
 
-#define first_node(src) __first_node(&(src), MAX_NUMNODES)
-static inline int __first_node(const nodemask_t *srcp, int nbits)
+/* FIXME: better would be to fix all architectures to never return
+          > MAX_NUMNODES, then the silly min_ts could be dropped. */
+
+#define first_node(src) __first_node(&(src))
+static inline int __first_node(const nodemask_t *srcp)
 {
-	return min_t(int, nbits, find_first_bit(srcp->bits, nbits));
+	return min_t(int, MAX_NUMNODES, find_first_bit(srcp->bits, MAX_NUMNODES));
 }
 
-#define next_node(n, src) __next_node((n), &(src), MAX_NUMNODES)
-static inline int __next_node(int n, const nodemask_t *srcp, int nbits)
+#define next_node(n, src) __next_node((n), &(src))
+static inline int __next_node(int n, const nodemask_t *srcp)
 {
-	return min_t(int, nbits, find_next_bit(srcp->bits, nbits, n+1));
+	return min_t(int,MAX_NUMNODES,find_next_bit(srcp->bits, MAX_NUMNODES, n+1));
 }
 
 #define nodemask_of_node(node)						\
_