提交 75129e29 编写于 作者: J John Hawkes 提交者: 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: NJohn Hawkes <hawkes@sgi.com>
Cc: Matt Mackall <mpm@selenic.com>
Signed-off-by: NAndrew Morton <akpm@osdl.org>
Signed-off-by: NLinus Torvalds <torvalds@osdl.org>
上级 4a3b98a4
......@@ -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);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册