mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: hawkes@sgi.com
To: Andrew Morton <akpm@osdl.org>
Cc: hawkes@sgi.com, linux-kernel@vger.kernel.org
Subject: [PATCH] mm/slob.c: for_each_possible_cpu(), not NR_CPUS
Date: Thu, 13 Apr 2006 16:11:52 -0700	[thread overview]
Message-ID: <20060413231152.3398.31561.sendpatchset@tomahawk.engr.sgi.com> (raw)

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

                 reply	other threads:[~2006-04-13 23:13 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20060413231152.3398.31561.sendpatchset@tomahawk.engr.sgi.com \
    --to=hawkes@sgi.com \
    --cc=akpm@osdl.org \
    --cc=linux-kernel@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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®