[PATCH] mm/slob.c: for_each_possible_cpu(), not NR_CPUS

From: hawkes
Date: Thu Apr 13 2006 - 19:13:40 EST


Convert for-loops that explicitly reference "NR_CPUS" into the potentially
more efficient for_each_possible_cpu() construct.

Signed-off-by: John Hawkes <hawkes@xxxxxxx>

Index: linux/mm/slob.c
===================================================================
--- linux.orig/mm/slob.c 2006-04-13 12:48:21.000000000 -0700
+++ linux/mm/slob.c 2006-04-13 15:55:08.000000000 -0700
@@ -354,9 +354,7 @@ void *__alloc_percpu(size_t size)
if (!pdata)
return NULL;

- for (i = 0; i < NR_CPUS; i++) {
- if (!cpu_possible(i))
- continue;
+ for_each_possible_cpu(i) {
pdata->ptrs[i] = kmalloc(size, GFP_KERNEL);
if (!pdata->ptrs[i])
goto unwind_oom;
@@ -383,11 +381,9 @@ free_percpu(const void *objp)
int i;
struct percpu_data *p = (struct percpu_data *) (~(unsigned long) objp);

- for (i = 0; i < NR_CPUS; i++) {
- if (!cpu_possible(i))
- continue;
+ for_each_possible_cpu(i)
kfree(p->ptrs[i]);
- }
+
kfree(p);
}
EXPORT_SYMBOL(free_percpu);
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/