2014-04-10 13:44:09

by Chander Kashyap

[permalink] [raw]
Subject: [PATCH] cpuidle: governor: menu: move repeated correction factor check to init

In menu_select function we check for correction factor every time.
If it is zero we are initializing to unity. Hence move it to init function
and initialise by unity, hence avoid repeated comparisons.

Signed-off-by: Chander Kashyap <[email protected]>
---
drivers/cpuidle/governors/menu.c | 15 ++++++++-------
1 file changed, 8 insertions(+), 7 deletions(-)

diff --git a/drivers/cpuidle/governors/menu.c b/drivers/cpuidle/governors/menu.c
index cf7f2f0..048f6d9 100644
--- a/drivers/cpuidle/governors/menu.c
+++ b/drivers/cpuidle/governors/menu.c
@@ -315,13 +315,6 @@ static int menu_select(struct cpuidle_driver *drv, struct cpuidle_device *dev)
multiplier = performance_multiplier();

/*
- * if the correction factor is 0 (eg first time init or cpu hotplug
- * etc), we actually want to start out with a unity factor.
- */
- if (data->correction_factor[data->bucket] == 0)
- data->correction_factor[data->bucket] = RESOLUTION * DECAY;
-
- /*
* Force the result of multiplication to be 64 bits even if both
* operands are 32 bits.
* Make sure to round up for half microseconds.
@@ -453,9 +446,17 @@ static int menu_enable_device(struct cpuidle_driver *drv,
struct cpuidle_device *dev)
{
struct menu_device *data = &per_cpu(menu_devices, dev->cpu);
+ int i;

memset(data, 0, sizeof(struct menu_device));

+ /*
+ * if the correction factor is 0 (eg first time init or cpu hotplug
+ * etc), we actually want to start out with a unity factor.
+ */
+ for(i = 0; i < BUCKETS; i++)
+ data->correction_factor[i] = RESOLUTION * DECAY;
+
return 0;
}

--
1.7.9.5


2014-04-10 14:27:31

by Tuukka Tikkanen

[permalink] [raw]
Subject: Re: [PATCH] cpuidle: governor: menu: move repeated correction factor check to init

On 10 April 2014 16:43, Chander Kashyap <[email protected]> wrote:
> In menu_select function we check for correction factor every time.
> If it is zero we are initializing to unity. Hence move it to init function
> and initialise by unity, hence avoid repeated comparisons.
>
> Signed-off-by: Chander Kashyap <[email protected]>
> ---
> drivers/cpuidle/governors/menu.c | 15 ++++++++-------
> 1 file changed, 8 insertions(+), 7 deletions(-)
>
> diff --git a/drivers/cpuidle/governors/menu.c b/drivers/cpuidle/governors/menu.c
> index cf7f2f0..048f6d9 100644
> --- a/drivers/cpuidle/governors/menu.c
> +++ b/drivers/cpuidle/governors/menu.c
> @@ -315,13 +315,6 @@ static int menu_select(struct cpuidle_driver *drv, struct cpuidle_device *dev)
> multiplier = performance_multiplier();
>
> /*
> - * if the correction factor is 0 (eg first time init or cpu hotplug
> - * etc), we actually want to start out with a unity factor.
> - */
> - if (data->correction_factor[data->bucket] == 0)
> - data->correction_factor[data->bucket] = RESOLUTION * DECAY;
> -
> - /*
> * Force the result of multiplication to be 64 bits even if both
> * operands are 32 bits.
> * Make sure to round up for half microseconds.
> @@ -453,9 +446,17 @@ static int menu_enable_device(struct cpuidle_driver *drv,
> struct cpuidle_device *dev)
> {
> struct menu_device *data = &per_cpu(menu_devices, dev->cpu);
> + int i;
>
> memset(data, 0, sizeof(struct menu_device));
>
> + /*
> + * if the correction factor is 0 (eg first time init or cpu hotplug
> + * etc), we actually want to start out with a unity factor.
> + */
> + for(i = 0; i < BUCKETS; i++)
> + data->correction_factor[i] = RESOLUTION * DECAY;
> +
> return 0;
> }
>
> --
> 1.7.9.5
>

Reviewed-by: Tuukka Tikkanen <[email protected]>

2014-04-22 02:57:57

by Chander Kashyap

[permalink] [raw]
Subject: Re: [PATCH] cpuidle: governor: menu: move repeated correction factor check to init

ping

On 10 April 2014 19:57, Tuukka Tikkanen <[email protected]> wrote:
> On 10 April 2014 16:43, Chander Kashyap <[email protected]> wrote:
>> In menu_select function we check for correction factor every time.
>> If it is zero we are initializing to unity. Hence move it to init function
>> and initialise by unity, hence avoid repeated comparisons.
>>
>> Signed-off-by: Chander Kashyap <[email protected]>
>> ---
>> drivers/cpuidle/governors/menu.c | 15 ++++++++-------
>> 1 file changed, 8 insertions(+), 7 deletions(-)
>>
>> diff --git a/drivers/cpuidle/governors/menu.c b/drivers/cpuidle/governors/menu.c
>> index cf7f2f0..048f6d9 100644
>> --- a/drivers/cpuidle/governors/menu.c
>> +++ b/drivers/cpuidle/governors/menu.c
>> @@ -315,13 +315,6 @@ static int menu_select(struct cpuidle_driver *drv, struct cpuidle_device *dev)
>> multiplier = performance_multiplier();
>>
>> /*
>> - * if the correction factor is 0 (eg first time init or cpu hotplug
>> - * etc), we actually want to start out with a unity factor.
>> - */
>> - if (data->correction_factor[data->bucket] == 0)
>> - data->correction_factor[data->bucket] = RESOLUTION * DECAY;
>> -
>> - /*
>> * Force the result of multiplication to be 64 bits even if both
>> * operands are 32 bits.
>> * Make sure to round up for half microseconds.
>> @@ -453,9 +446,17 @@ static int menu_enable_device(struct cpuidle_driver *drv,
>> struct cpuidle_device *dev)
>> {
>> struct menu_device *data = &per_cpu(menu_devices, dev->cpu);
>> + int i;
>>
>> memset(data, 0, sizeof(struct menu_device));
>>
>> + /*
>> + * if the correction factor is 0 (eg first time init or cpu hotplug
>> + * etc), we actually want to start out with a unity factor.
>> + */
>> + for(i = 0; i < BUCKETS; i++)
>> + data->correction_factor[i] = RESOLUTION * DECAY;
>> +
>> return 0;
>> }
>>
>> --
>> 1.7.9.5
>>
>
> Reviewed-by: Tuukka Tikkanen <[email protected]>



--
with warm regards,
Chander Kashyap

2014-04-22 09:46:52

by Rafael J. Wysocki

[permalink] [raw]
Subject: Re: [PATCH] cpuidle: governor: menu: move repeated correction factor check to init

On Tuesday, April 22, 2014 08:27:53 AM Chander Kashyap wrote:
> ping

Please CC cpuidle patches to [email protected].

Thanks!

> On 10 April 2014 19:57, Tuukka Tikkanen <[email protected]> wrote:
> > On 10 April 2014 16:43, Chander Kashyap <[email protected]> wrote:
> >> In menu_select function we check for correction factor every time.
> >> If it is zero we are initializing to unity. Hence move it to init function
> >> and initialise by unity, hence avoid repeated comparisons.
> >>
> >> Signed-off-by: Chander Kashyap <[email protected]>
> >> ---
> >> drivers/cpuidle/governors/menu.c | 15 ++++++++-------
> >> 1 file changed, 8 insertions(+), 7 deletions(-)
> >>
> >> diff --git a/drivers/cpuidle/governors/menu.c b/drivers/cpuidle/governors/menu.c
> >> index cf7f2f0..048f6d9 100644
> >> --- a/drivers/cpuidle/governors/menu.c
> >> +++ b/drivers/cpuidle/governors/menu.c
> >> @@ -315,13 +315,6 @@ static int menu_select(struct cpuidle_driver *drv, struct cpuidle_device *dev)
> >> multiplier = performance_multiplier();
> >>
> >> /*
> >> - * if the correction factor is 0 (eg first time init or cpu hotplug
> >> - * etc), we actually want to start out with a unity factor.
> >> - */
> >> - if (data->correction_factor[data->bucket] == 0)
> >> - data->correction_factor[data->bucket] = RESOLUTION * DECAY;
> >> -
> >> - /*
> >> * Force the result of multiplication to be 64 bits even if both
> >> * operands are 32 bits.
> >> * Make sure to round up for half microseconds.
> >> @@ -453,9 +446,17 @@ static int menu_enable_device(struct cpuidle_driver *drv,
> >> struct cpuidle_device *dev)
> >> {
> >> struct menu_device *data = &per_cpu(menu_devices, dev->cpu);
> >> + int i;
> >>
> >> memset(data, 0, sizeof(struct menu_device));
> >>
> >> + /*
> >> + * if the correction factor is 0 (eg first time init or cpu hotplug
> >> + * etc), we actually want to start out with a unity factor.
> >> + */
> >> + for(i = 0; i < BUCKETS; i++)
> >> + data->correction_factor[i] = RESOLUTION * DECAY;
> >> +
> >> return 0;
> >> }
> >>
> >> --
> >> 1.7.9.5
> >>
> >
> > Reviewed-by: Tuukka Tikkanen <[email protected]>
>
>
>
>

--
I speak only for myself.
Rafael J. Wysocki, Intel Open Source Technology Center.

2014-04-22 09:54:23

by Chander Kashyap

[permalink] [raw]
Subject: Re: [PATCH] cpuidle: governor: menu: move repeated correction factor check to init

+cc
[email protected].

On 22 April 2014 15:33, Rafael J. Wysocki <[email protected]> wrote:
> On Tuesday, April 22, 2014 08:27:53 AM Chander Kashyap wrote:
>> ping
>
> Please CC cpuidle patches to [email protected].

+cc to [email protected].
Thanks Rafael

>
> Thanks!
>
>> On 10 April 2014 19:57, Tuukka Tikkanen <[email protected]> wrote:
>> > On 10 April 2014 16:43, Chander Kashyap <[email protected]> wrote:
>> >> In menu_select function we check for correction factor every time.
>> >> If it is zero we are initializing to unity. Hence move it to init function
>> >> and initialise by unity, hence avoid repeated comparisons.
>> >>
>> >> Signed-off-by: Chander Kashyap <[email protected]>
>> >> ---
>> >> drivers/cpuidle/governors/menu.c | 15 ++++++++-------
>> >> 1 file changed, 8 insertions(+), 7 deletions(-)
>> >>
>> >> diff --git a/drivers/cpuidle/governors/menu.c b/drivers/cpuidle/governors/menu.c
>> >> index cf7f2f0..048f6d9 100644
>> >> --- a/drivers/cpuidle/governors/menu.c
>> >> +++ b/drivers/cpuidle/governors/menu.c
>> >> @@ -315,13 +315,6 @@ static int menu_select(struct cpuidle_driver *drv, struct cpuidle_device *dev)
>> >> multiplier = performance_multiplier();
>> >>
>> >> /*
>> >> - * if the correction factor is 0 (eg first time init or cpu hotplug
>> >> - * etc), we actually want to start out with a unity factor.
>> >> - */
>> >> - if (data->correction_factor[data->bucket] == 0)
>> >> - data->correction_factor[data->bucket] = RESOLUTION * DECAY;
>> >> -
>> >> - /*
>> >> * Force the result of multiplication to be 64 bits even if both
>> >> * operands are 32 bits.
>> >> * Make sure to round up for half microseconds.
>> >> @@ -453,9 +446,17 @@ static int menu_enable_device(struct cpuidle_driver *drv,
>> >> struct cpuidle_device *dev)
>> >> {
>> >> struct menu_device *data = &per_cpu(menu_devices, dev->cpu);
>> >> + int i;
>> >>
>> >> memset(data, 0, sizeof(struct menu_device));
>> >>
>> >> + /*
>> >> + * if the correction factor is 0 (eg first time init or cpu hotplug
>> >> + * etc), we actually want to start out with a unity factor.
>> >> + */
>> >> + for(i = 0; i < BUCKETS; i++)
>> >> + data->correction_factor[i] = RESOLUTION * DECAY;
>> >> +
>> >> return 0;
>> >> }
>> >>
>> >> --
>> >> 1.7.9.5
>> >>
>> >
>> > Reviewed-by: Tuukka Tikkanen <[email protected]>
>>
>>
>>
>>
>
> --
> I speak only for myself.
> Rafael J. Wysocki, Intel Open Source Technology Center.



--
with warm regards,
Chander Kashyap

2014-04-22 11:08:06

by Rafael J. Wysocki

[permalink] [raw]
Subject: Re: [PATCH] cpuidle: governor: menu: move repeated correction factor check to init

On Tuesday, April 22, 2014 03:24:21 PM Chander Kashyap wrote:
> +cc
> [email protected].

And can you please resend the patch? So that it shows up in Patchwork,
for example?


> On 22 April 2014 15:33, Rafael J. Wysocki <[email protected]> wrote:
> > On Tuesday, April 22, 2014 08:27:53 AM Chander Kashyap wrote:
> >> ping
> >
> > Please CC cpuidle patches to [email protected].
>
> +cc to [email protected].
> Thanks Rafael
>
> >
> > Thanks!
> >
> >> On 10 April 2014 19:57, Tuukka Tikkanen <[email protected]> wrote:
> >> > On 10 April 2014 16:43, Chander Kashyap <[email protected]> wrote:
> >> >> In menu_select function we check for correction factor every time.
> >> >> If it is zero we are initializing to unity. Hence move it to init function
> >> >> and initialise by unity, hence avoid repeated comparisons.
> >> >>
> >> >> Signed-off-by: Chander Kashyap <[email protected]>
> >> >> ---
> >> >> drivers/cpuidle/governors/menu.c | 15 ++++++++-------
> >> >> 1 file changed, 8 insertions(+), 7 deletions(-)
> >> >>
> >> >> diff --git a/drivers/cpuidle/governors/menu.c b/drivers/cpuidle/governors/menu.c
> >> >> index cf7f2f0..048f6d9 100644
> >> >> --- a/drivers/cpuidle/governors/menu.c
> >> >> +++ b/drivers/cpuidle/governors/menu.c
> >> >> @@ -315,13 +315,6 @@ static int menu_select(struct cpuidle_driver *drv, struct cpuidle_device *dev)
> >> >> multiplier = performance_multiplier();
> >> >>
> >> >> /*
> >> >> - * if the correction factor is 0 (eg first time init or cpu hotplug
> >> >> - * etc), we actually want to start out with a unity factor.
> >> >> - */
> >> >> - if (data->correction_factor[data->bucket] == 0)
> >> >> - data->correction_factor[data->bucket] = RESOLUTION * DECAY;
> >> >> -
> >> >> - /*
> >> >> * Force the result of multiplication to be 64 bits even if both
> >> >> * operands are 32 bits.
> >> >> * Make sure to round up for half microseconds.
> >> >> @@ -453,9 +446,17 @@ static int menu_enable_device(struct cpuidle_driver *drv,
> >> >> struct cpuidle_device *dev)
> >> >> {
> >> >> struct menu_device *data = &per_cpu(menu_devices, dev->cpu);
> >> >> + int i;
> >> >>
> >> >> memset(data, 0, sizeof(struct menu_device));
> >> >>
> >> >> + /*
> >> >> + * if the correction factor is 0 (eg first time init or cpu hotplug
> >> >> + * etc), we actually want to start out with a unity factor.
> >> >> + */
> >> >> + for(i = 0; i < BUCKETS; i++)
> >> >> + data->correction_factor[i] = RESOLUTION * DECAY;
> >> >> +
> >> >> return 0;
> >> >> }
> >> >>
> >> >> --
> >> >> 1.7.9.5
> >> >>
> >> >
> >> > Reviewed-by: Tuukka Tikkanen <[email protected]>
> >>
> >>
> >>
> >>
> >
> > --
> > I speak only for myself.
> > Rafael J. Wysocki, Intel Open Source Technology Center.
>
>
>
>

--
I speak only for myself.
Rafael J. Wysocki, Intel Open Source Technology Center.

2014-04-22 12:26:49

by Chander Kashyap

[permalink] [raw]
Subject: Re: [PATCH] cpuidle: governor: menu: move repeated correction factor check to init

On 22 April 2014 16:54, Rafael J. Wysocki <[email protected]> wrote:
> On Tuesday, April 22, 2014 03:24:21 PM Chander Kashyap wrote:
>> +cc
>> [email protected].
>
> And can you please resend the patch? So that it shows up in Patchwork,
> for example?
>

Yes i will resend it again.

>
>> On 22 April 2014 15:33, Rafael J. Wysocki <[email protected]> wrote:
>> > On Tuesday, April 22, 2014 08:27:53 AM Chander Kashyap wrote:
>> >> ping
>> >
>> > Please CC cpuidle patches to [email protected].
>>
>> +cc to [email protected].
>> Thanks Rafael
>>
>> >
>> > Thanks!
>> >
>> >> On 10 April 2014 19:57, Tuukka Tikkanen <[email protected]> wrote:
>> >> > On 10 April 2014 16:43, Chander Kashyap <[email protected]> wrote:
>> >> >> In menu_select function we check for correction factor every time.
>> >> >> If it is zero we are initializing to unity. Hence move it to init function
>> >> >> and initialise by unity, hence avoid repeated comparisons.
>> >> >>
>> >> >> Signed-off-by: Chander Kashyap <[email protected]>
>> >> >> ---
>> >> >> drivers/cpuidle/governors/menu.c | 15 ++++++++-------
>> >> >> 1 file changed, 8 insertions(+), 7 deletions(-)
>> >> >>
>> >> >> diff --git a/drivers/cpuidle/governors/menu.c b/drivers/cpuidle/governors/menu.c
>> >> >> index cf7f2f0..048f6d9 100644
>> >> >> --- a/drivers/cpuidle/governors/menu.c
>> >> >> +++ b/drivers/cpuidle/governors/menu.c
>> >> >> @@ -315,13 +315,6 @@ static int menu_select(struct cpuidle_driver *drv, struct cpuidle_device *dev)
>> >> >> multiplier = performance_multiplier();
>> >> >>
>> >> >> /*
>> >> >> - * if the correction factor is 0 (eg first time init or cpu hotplug
>> >> >> - * etc), we actually want to start out with a unity factor.
>> >> >> - */
>> >> >> - if (data->correction_factor[data->bucket] == 0)
>> >> >> - data->correction_factor[data->bucket] = RESOLUTION * DECAY;
>> >> >> -
>> >> >> - /*
>> >> >> * Force the result of multiplication to be 64 bits even if both
>> >> >> * operands are 32 bits.
>> >> >> * Make sure to round up for half microseconds.
>> >> >> @@ -453,9 +446,17 @@ static int menu_enable_device(struct cpuidle_driver *drv,
>> >> >> struct cpuidle_device *dev)
>> >> >> {
>> >> >> struct menu_device *data = &per_cpu(menu_devices, dev->cpu);
>> >> >> + int i;
>> >> >>
>> >> >> memset(data, 0, sizeof(struct menu_device));
>> >> >>
>> >> >> + /*
>> >> >> + * if the correction factor is 0 (eg first time init or cpu hotplug
>> >> >> + * etc), we actually want to start out with a unity factor.
>> >> >> + */
>> >> >> + for(i = 0; i < BUCKETS; i++)
>> >> >> + data->correction_factor[i] = RESOLUTION * DECAY;
>> >> >> +
>> >> >> return 0;
>> >> >> }
>> >> >>
>> >> >> --
>> >> >> 1.7.9.5
>> >> >>
>> >> >
>> >> > Reviewed-by: Tuukka Tikkanen <[email protected]>
>> >>
>> >>
>> >>
>> >>
>> >
>> > --
>> > I speak only for myself.
>> > Rafael J. Wysocki, Intel Open Source Technology Center.
>>
>>
>>
>>
>
> --
> I speak only for myself.
> Rafael J. Wysocki, Intel Open Source Technology Center.



--
with warm regards,
Chander Kashyap

2014-04-22 12:38:20

by Chander Kashyap

[permalink] [raw]
Subject: [RESEND][PATCH] cpuidle: governor: menu: move repeated correction factor check to init

In menu_select function we check for correction factor every time.
If it is zero we are initializing to unity. Hence move it to init function
and initialise by unity, hence avoid repeated comparisons.

Signed-off-by: Chander Kashyap <[email protected]>
Reviewed-by: Tuukka Tikkanen <[email protected]>
---
drivers/cpuidle/governors/menu.c | 15 ++++++++-------
1 file changed, 8 insertions(+), 7 deletions(-)

diff --git a/drivers/cpuidle/governors/menu.c b/drivers/cpuidle/governors/menu.c
index 71b5232..9b7918c 100644
--- a/drivers/cpuidle/governors/menu.c
+++ b/drivers/cpuidle/governors/menu.c
@@ -311,13 +311,6 @@ static int menu_select(struct cpuidle_driver *drv, struct cpuidle_device *dev)
data->bucket = which_bucket(data->next_timer_us);

/*
- * if the correction factor is 0 (eg first time init or cpu hotplug
- * etc), we actually want to start out with a unity factor.
- */
- if (data->correction_factor[data->bucket] == 0)
- data->correction_factor[data->bucket] = RESOLUTION * DECAY;
-
- /*
* Force the result of multiplication to be 64 bits even if both
* operands are 32 bits.
* Make sure to round up for half microseconds.
@@ -466,9 +459,17 @@ static int menu_enable_device(struct cpuidle_driver *drv,
struct cpuidle_device *dev)
{
struct menu_device *data = &per_cpu(menu_devices, dev->cpu);
+ int i;

memset(data, 0, sizeof(struct menu_device));

+ /*
+ * if the correction factor is 0 (eg first time init or cpu hotplug
+ * etc), we actually want to start out with a unity factor.
+ */
+ for(i = 0; i < BUCKETS; i++)
+ data->correction_factor[i] = RESOLUTION * DECAY;
+
return 0;
}

--
1.7.9.5