From: James Bottomley <James.Bottomley@steeleye.com>
To: Rusty Russell <rusty@rustcorp.com.au>
Cc: linux-kernel@vger.kernel.org, James.Bottomley@SteelEye.com
Subject: Optimisation for smp_num_cpus loop in hotplug
Date: Thu, 20 Jun 2002 19:41:52 -0400 [thread overview]
Message-ID: <200206202341.g5KNfqU07377@localhost.localdomain> (raw)
The hotplug CPU patch introduces this to replace the loop over all active CPUs
abstraction:
for (i = 0; i < NR_CPUS; i++) {
if (!cpu_online(i))
continue;
Since the cpu online map is probably going to be quite sparse, could I suggest
this alternative, which doesn't have to loop 32 times:
===== smp.h 1.11 vs edited =====
--- 1.11/include/asm-i386/smp.h Thu Jun 20 14:04:21 2002
+++ edited/smp.h Thu Jun 20 12:39:33 2002
@@ -95,6 +95,11 @@
#define cpu_online(cpu) (cpu_online_map & (1<<(cpu)))
+#define for_each_cpu(cpu, mask) \
+ for(mask = cpu_online_map; \
+ cpu = __ffs(mask), mask != 0; \
+ mask &= ~(1<<cpu))
+
extern inline unsigned int num_online_cpus(void)
{
return hweight32(cpu_online_map);
I've implemented this for my voyager system (8 cpus, but still a sparse online
bitmap), mainly because (for historical reasons), I have to do this loop in
time critical IPI code.
James
next reply other threads:[~2002-06-20 23:42 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2002-06-20 23:41 James Bottomley [this message]
2002-06-21 15:14 ` Optimisation for smp_num_cpus loop in hotplug Rusty Russell
2002-06-21 15:31 ` James Bottomley
2002-06-21 19:17 ` Rusty Russell
[not found] <mailman.1024617156.25656.linux-kernel2news@redhat.com>
2002-06-21 4:16 ` Pete Zaitcev
2002-06-21 13:10 ` James Bottomley
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=200206202341.g5KNfqU07377@localhost.localdomain \
--to=james.bottomley@steeleye.com \
--cc=linux-kernel@vger.kernel.org \
--cc=rusty@rustcorp.com.au \
/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