Skip to content

Commit

Permalink
[PATCH] mm/slob.c: for_each_possible_cpu(), not NR_CPUS
Browse files Browse the repository at this point in the history
Convert for-loops that explicitly reference "NR_CPUS" into the
potentially more efficient for_each_possible_cpu() construct.

Signed-off-by: John Hawkes <hawkes@sgi.com>
Cc: Matt Mackall <mpm@selenic.com>
Signed-off-by: Andrew Morton <akpm@osdl.org>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
  • Loading branch information
John Hawkes authored and Linus Torvalds committed Apr 19, 2006
1 parent 4a3b98a commit 75129e2
Showing 1 changed file with 3 additions and 7 deletions.
10 changes: 3 additions & 7 deletions mm/slob.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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);
Expand Down

0 comments on commit 75129e2

Please sign in to comment.