[PATCH] lib/cpumask.c: Optimize __any_online_cpu() calculation

From: Srivatsa S. Bhat
Date: Wed Feb 15 2012 - 07:35:40 EST


__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@xxxxxxxxxxxxxxxxxx>
---
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);


--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/