public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Rusty Russell <rusty@rustcorp.com.au>
To: James Bottomley <James.Bottomley@steeleye.com>
Cc: linux-kernel@vger.kernel.org, mingo@redhat.com
Subject: Re: Optimisation for smp_num_cpus loop in hotplug
Date: Sat, 22 Jun 2002 05:17:19 +1000	[thread overview]
Message-ID: <E17LTuK-0003HM-00@wagner.rustcorp.com.au> (raw)
In-Reply-To: Your message of "Fri, 21 Jun 2002 11:31:44 -0400." <200206211531.g5LFViZ07396@localhost.localdomain>

In message <200206211531.g5LFViZ07396@localhost.localdomain> you write:
> rusty@rustcorp.com.au said:
> > Yeah, it's simple, and none of the current ones are really critical.
> > But I think we're better off with:
> > 	for (i = first_cpu(); i < NR_CPUS; i = next_cpu(i)) {
> 
> > Which is simple enough not to need an iterator macro, and also has the
> > bonus of giving irq-balancing et al. an efficient, portable way of
> > looking for the "next" cpu. 
> 
> So you're thinking that next_cpu(i) is something like
> 
> __ffs((~(unsigned)((1<<i)-1) & cpu_online_map)
> 
> plus an extra exception piece to take next_cpu(i) above NR_CPUS if we have no
 
> remaining CPUs (because __ffs would be undefined)?  It's the exception piece 
> that I don't see how to do really efficiently.

find_next_bit already does this, but the generic one would look
something like:

	unsigned long mask = ~(unsigned long)((1<<(cpu+1))-1);
	if (mask & cpu_online_map)
		return _ffs(mask & cpu_online_map);
	return NR_CPUS;

Cheers!
Rusty.
--
  Anyone who quotes me in their sig is an idiot. -- Rusty Russell.

  reply	other threads:[~2002-06-21 19:13 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2002-06-20 23:41 Optimisation for smp_num_cpus loop in hotplug James Bottomley
2002-06-21 15:14 ` Rusty Russell
2002-06-21 15:31   ` James Bottomley
2002-06-21 19:17     ` Rusty Russell [this message]
     [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=E17LTuK-0003HM-00@wagner.rustcorp.com.au \
    --to=rusty@rustcorp.com.au \
    --cc=James.Bottomley@steeleye.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mingo@redhat.com \
    /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