[PATCH] cpumask: uninline any_online_cpu()
authorAndrew Morton <akpm@osdl.org>
Sat, 25 Mar 2006 11:08:10 +0000 (03:08 -0800)
committerLinus Torvalds <torvalds@g5.osdl.org>
Sat, 25 Mar 2006 16:23:00 +0000 (08:23 -0800)
           text    data     bss     dec     hex filename
before: 3605597 1363528  363328 5332453  515de5 vmlinux
after:  3605295 1363612  363200 5332107  515c8b vmlinux

218 bytes saved.

Also, optimise any_online_cpu() out of existence on CONFIG_SMP=n.

This function seems inefficient.  Can't we simply AND the two masks, then use
find_first_bit()?

Cc: Paul Jackson <pj@sgi.com>
Signed-off-by: Andrew Morton <akpm@osdl.org>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
include/linux/cpumask.h
lib/cpumask.c

index f770039..99e6115 100644 (file)
@@ -398,22 +398,15 @@ extern cpumask_t cpu_present_map;
 
 #ifdef CONFIG_SMP
 int highest_possible_processor_id(void);
+#define any_online_cpu(mask) __any_online_cpu(&(mask))
+int __any_online_cpu(const cpumask_t *mask);
 #else
 #define highest_possible_processor_id()        0
+#define any_online_cpu(mask)           0
 #endif
 
-#define any_online_cpu(mask)                   \
-({                                             \
-       int cpu;                                \
-       for_each_cpu_mask(cpu, (mask))          \
-               if (cpu_online(cpu))            \
-                       break;                  \
-       cpu;                                    \
-})
-
 #define for_each_cpu(cpu)        for_each_cpu_mask((cpu), cpu_possible_map)
 #define for_each_online_cpu(cpu)  for_each_cpu_mask((cpu), cpu_online_map)
 #define for_each_present_cpu(cpu) for_each_cpu_mask((cpu), cpu_present_map)
 
-
 #endif /* __LINUX_CPUMASK_H */
index ea25a03..3a67dc5 100644 (file)
@@ -31,3 +31,15 @@ int highest_possible_processor_id(void)
        return highest;
 }
 EXPORT_SYMBOL(highest_possible_processor_id);
+
+int __any_online_cpu(const cpumask_t *mask)
+{
+       int cpu;
+
+       for_each_cpu_mask(cpu, *mask) {
+               if (cpu_online(cpu))
+                       break;
+       }
+       return cpu;
+}
+EXPORT_SYMBOL(__any_online_cpu);