[lkml]   [2002]   [Jun]   [21]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
Messages in this thread
SubjectRe: Optimisation for smp_num_cpus loop in hotplug
In message <200206211531.g5LFViZ07396@localhost.localdomain> you write:
> 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;

Anyone who quotes me in their sig is an idiot. -- Rusty Russell.
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to
More majordomo info at
Please read the FAQ at

 \ /
  Last update: 2005-03-22 13:26    [W:0.030 / U:11.072 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site