public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] lib/cpumask.c: Optimize __any_online_cpu() calculation
@ 2012-02-15 12:35 Srivatsa S. Bhat
  2012-02-15 12:57 ` Eric Dumazet
  0 siblings, 1 reply; 5+ messages in thread
From: Srivatsa S. Bhat @ 2012-02-15 12:35 UTC (permalink / raw)
  To: akpm; +Cc: kosaki.motohiro, linux-kernel, venki, rusty

__any_online_cpu() uses a for loop at the moment.
Instead, use cpumask_* operations to speed it up.

Signed-off-by: Srivatsa S. Bhat <srivatsa.bhat@linux.vnet.ibm.com>
---
Actually, the patch posted at https://lkml.org/lkml/2012/2/15/101 removed
the last user of any_online_cpu() (and hence __any_online_cpu()).
However, since this is an exported symbol, I refrained from removing this
function altogether.

 lib/cpumask.c |    8 +-------
 1 files changed, 1 insertions(+), 7 deletions(-)

diff --git a/lib/cpumask.c b/lib/cpumask.c
index af3e5817..b25f53d 100644
--- a/lib/cpumask.c
+++ b/lib/cpumask.c
@@ -28,13 +28,7 @@ EXPORT_SYMBOL(__next_cpu_nr);
 
 int __any_online_cpu(const cpumask_t *mask)
 {
-	int cpu;
-
-	for_each_cpu(cpu, mask) {
-		if (cpu_online(cpu))
-			break;
-	}
-	return cpu;
+	return cpumask_any_and(mask, cpu_online_mask);
 }
 EXPORT_SYMBOL(__any_online_cpu);
 


^ permalink raw reply related	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2012-02-17 12:19 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-02-15 12:35 [PATCH] lib/cpumask.c: Optimize __any_online_cpu() calculation Srivatsa S. Bhat
2012-02-15 12:57 ` Eric Dumazet
2012-02-15 14:19   ` Srivatsa S. Bhat
2012-02-15 22:51     ` Rusty Russell
2012-02-17 12:19       ` Srivatsa S. Bhat

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