mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH] mm/slob.c: for_each_possible_cpu(), not NR_CPUS
@ 2006-04-13 23:11 hawkes
  0 siblings, 0 replies; only message in thread
From: hawkes @ 2006-04-13 23:11 UTC (permalink / raw)
  To: Andrew Morton; +Cc: hawkes, linux-kernel

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>

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);

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2006-04-13 23:13 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2006-04-13 23:11 [PATCH] mm/slob.c: for_each_possible_cpu(), not NR_CPUS hawkes

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®