From: John Hawkes Date: Wed, 19 Apr 2006 05:20:33 +0000 (-0700) Subject: [PATCH] mm/slob.c: for_each_possible_cpu(), not NR_CPUS X-Git-Url: https://git.stricted.de/?a=commitdiff_plain;h=75129e297e861e6c61038aa4cdbf604b022de4ff;p=GitHub%2FLineageOS%2Fandroid_kernel_samsung_universal7580.git [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: John Hawkes Cc: Matt Mackall Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- diff --git a/mm/slob.c b/mm/slob.c index 9bcc7e2cabf..a68255ba455 100644 --- a/mm/slob.c +++ b/mm/slob.c @@ -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);