* [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
* Re: [PATCH] lib/cpumask.c: Optimize __any_online_cpu() calculation
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
0 siblings, 1 reply; 5+ messages in thread
From: Eric Dumazet @ 2012-02-15 12:57 UTC (permalink / raw)
To: Srivatsa S. Bhat; +Cc: akpm, kosaki.motohiro, linux-kernel, venki, rusty
Le mercredi 15 février 2012 à 18:05 +0530, Srivatsa S. Bhat a écrit :
> __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.
Just remove the export/function and eventually leave the helper ?
#define any_online_cpu(mask) cpumask_any_and(mask, cpu_online_mask)
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] lib/cpumask.c: Optimize __any_online_cpu() calculation
2012-02-15 12:57 ` Eric Dumazet
@ 2012-02-15 14:19 ` Srivatsa S. Bhat
2012-02-15 22:51 ` Rusty Russell
0 siblings, 1 reply; 5+ messages in thread
From: Srivatsa S. Bhat @ 2012-02-15 14:19 UTC (permalink / raw)
To: Eric Dumazet
Cc: akpm, kosaki.motohiro, linux-kernel, venki, rusty, Mike Travis
On 02/15/2012 06:27 PM, Eric Dumazet wrote:
> Le mercredi 15 février 2012 à 18:05 +0530, Srivatsa S. Bhat a écrit :
>> __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.
>
> Just remove the export/function and eventually leave the helper ?
>
> #define any_online_cpu(mask) cpumask_any_and(mask, cpu_online_mask)
>
That sounds good. Here is v2 of the patch.
(Since this v2 touches include/linux/cpumask.h, I rebased it on top of the
patch posted at: https://lkml.org/lkml/2012/2/15/2. Even without that
patch it should apply with minor line number changes..)
---
From: Srivatsa S. Bhat <srivatsa.bhat@linux.vnet.ibm.com>
Subject: [PATCH v2] lib/cpumask.c: Remove __any_online_cpu()
__any_online_cpu() is not optimal and also unnecessary.
So, replace its use by faster cpumask_* operations.
Signed-off-by: Srivatsa S. Bhat <srivatsa.bhat@linux.vnet.ibm.com>
---
include/linux/cpumask.h | 3 +--
lib/cpumask.c | 12 ------------
2 files changed, 1 insertions(+), 14 deletions(-)
diff --git a/include/linux/cpumask.h b/include/linux/cpumask.h
index 42fec19..d3ccd2d 100644
--- a/include/linux/cpumask.h
+++ b/include/linux/cpumask.h
@@ -808,11 +808,10 @@ static inline const struct cpumask *get_cpu_mask(unsigned int cpu)
#else /* NR_CPUS > 1 */
int __first_cpu(const cpumask_t *srcp);
int __next_cpu(int n, const cpumask_t *srcp);
-int __any_online_cpu(const cpumask_t *mask);
#define first_cpu(src) __first_cpu(&(src))
#define next_cpu(n, src) __next_cpu((n), &(src))
-#define any_online_cpu(mask) __any_online_cpu(&(mask))
+#define any_online_cpu(mask) cpumask_any_and(&mask, cpu_online_mask)
#define for_each_cpu_mask(cpu, mask) \
for ((cpu) = -1; \
(cpu) = next_cpu((cpu), (mask)), \
diff --git a/lib/cpumask.c b/lib/cpumask.c
index af3e5817..0470742 100644
--- a/lib/cpumask.c
+++ b/lib/cpumask.c
@@ -26,18 +26,6 @@ int __next_cpu_nr(int n, const cpumask_t *srcp)
EXPORT_SYMBOL(__next_cpu_nr);
#endif
-int __any_online_cpu(const cpumask_t *mask)
-{
- int cpu;
-
- for_each_cpu(cpu, mask) {
- if (cpu_online(cpu))
- break;
- }
- return cpu;
-}
-EXPORT_SYMBOL(__any_online_cpu);
-
/**
* cpumask_next_and - get the next cpu in *src1p & *src2p
* @n: the cpu prior to the place to search (ie. return will be > @n)
^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: [PATCH] lib/cpumask.c: Optimize __any_online_cpu() calculation
2012-02-15 14:19 ` Srivatsa S. Bhat
@ 2012-02-15 22:51 ` Rusty Russell
2012-02-17 12:19 ` Srivatsa S. Bhat
0 siblings, 1 reply; 5+ messages in thread
From: Rusty Russell @ 2012-02-15 22:51 UTC (permalink / raw)
To: Srivatsa S. Bhat, Eric Dumazet
Cc: akpm, kosaki.motohiro, linux-kernel, venki, Mike Travis
On Wed, 15 Feb 2012 19:49:00 +0530, "Srivatsa S. Bhat" <srivatsa.bhat@linux.vnet.ibm.com> wrote:
> On 02/15/2012 06:27 PM, Eric Dumazet wrote:
>
> > Le mercredi 15 février 2012 à 18:05 +0530, Srivatsa S. Bhat a écrit :
> >> __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.
> >
> > Just remove the export/function and eventually leave the helper ?
> >
> > #define any_online_cpu(mask) cpumask_any_and(mask, cpu_online_mask)
> >
>
>
> That sounds good. Here is v2 of the patch.
> (Since this v2 touches include/linux/cpumask.h, I rebased it on top of the
> patch posted at: https://lkml.org/lkml/2012/2/15/2. Even without that
> patch it should apply with minor line number changes..)
No. Just git rid of the only caller of any_online_cpu():
arch/ia64/kernel/smpboot.c:693: new_cpei_cpu = any_online_cpu(cpu_online_map);
Thanks,
Rusty.
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] lib/cpumask.c: Optimize __any_online_cpu() calculation
2012-02-15 22:51 ` Rusty Russell
@ 2012-02-17 12:19 ` Srivatsa S. Bhat
0 siblings, 0 replies; 5+ messages in thread
From: Srivatsa S. Bhat @ 2012-02-17 12:19 UTC (permalink / raw)
To: Rusty Russell
Cc: Eric Dumazet, akpm, kosaki.motohiro, linux-kernel, venki,
Mike Travis
On 02/16/2012 04:21 AM, Rusty Russell wrote:
> On Wed, 15 Feb 2012 19:49:00 +0530, "Srivatsa S. Bhat" <srivatsa.bhat@linux.vnet.ibm.com> wrote:
>> On 02/15/2012 06:27 PM, Eric Dumazet wrote:
>>
>>> Le mercredi 15 février 2012 à 18:05 +0530, Srivatsa S. Bhat a écrit :
>>>> __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.
>>>
>>> Just remove the export/function and eventually leave the helper ?
>>>
>>> #define any_online_cpu(mask) cpumask_any_and(mask, cpu_online_mask)
>>>
>>
>>
>> That sounds good. Here is v2 of the patch.
>> (Since this v2 touches include/linux/cpumask.h, I rebased it on top of the
>> patch posted at: https://lkml.org/lkml/2012/2/15/2. Even without that
>> patch it should apply with minor line number changes..)
>
> No. Just git rid of the only caller of any_online_cpu():
>
> arch/ia64/kernel/smpboot.c:693: new_cpei_cpu = any_online_cpu(cpu_online_map);
>
My ia64 patch already got rid of that caller! So this patch should be fine as
is. And it looks like Andrew Morton has taken this patch into -mm. So nothing
more needs to be done about this :-)
Regards,
Srivatsa S. Bhat
^ permalink raw reply [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