Commit 75129e29 authored by John Hawkes's avatar John Hawkes Committed by Linus Torvalds

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

Convert for-loops that explicitly reference "NR_CPUS" into the
potentially more efficient for_each_possible_cpu() construct.
Signed-off-by: default avatarJohn Hawkes <hawkes@sgi.com>
Cc: Matt Mackall <mpm@selenic.com>
Signed-off-by: default avatarAndrew Morton <akpm@osdl.org>
Signed-off-by: default avatarLinus Torvalds <torvalds@osdl.org>
parent 4a3b98a4
...@@ -354,9 +354,7 @@ void *__alloc_percpu(size_t size) ...@@ -354,9 +354,7 @@ void *__alloc_percpu(size_t size)
if (!pdata) if (!pdata)
return NULL; return NULL;
for (i = 0; i < NR_CPUS; i++) { for_each_possible_cpu(i) {
if (!cpu_possible(i))
continue;
pdata->ptrs[i] = kmalloc(size, GFP_KERNEL); pdata->ptrs[i] = kmalloc(size, GFP_KERNEL);
if (!pdata->ptrs[i]) if (!pdata->ptrs[i])
goto unwind_oom; goto unwind_oom;
...@@ -383,11 +381,9 @@ free_percpu(const void *objp) ...@@ -383,11 +381,9 @@ free_percpu(const void *objp)
int i; int i;
struct percpu_data *p = (struct percpu_data *) (~(unsigned long) objp); struct percpu_data *p = (struct percpu_data *) (~(unsigned long) objp);
for (i = 0; i < NR_CPUS; i++) { for_each_possible_cpu(i)
if (!cpu_possible(i))
continue;
kfree(p->ptrs[i]); kfree(p->ptrs[i]);
}
kfree(p); kfree(p);
} }
EXPORT_SYMBOL(free_percpu); EXPORT_SYMBOL(free_percpu);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment