[RESEND] cpuidle: governor: menu: move repeated correction factor check to init

Message ID 1398170284-7551-1-git-send-email-chander.kashyap@linaro.org
State Accepted
Commit bed4d597a0f99b380d24ab3a9da47b62cbf1ad0e
Headers show

Commit Message

Chander Kashyap April 22, 2014, 12:38 p.m.
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 <chander.kashyap@linaro.org>
Reviewed-by: Tuukka Tikkanen <tuukka.tikkanen@linaro.org>
---
 drivers/cpuidle/governors/menu.c |   15 ++++++++-------
 1 file changed, 8 insertions(+), 7 deletions(-)

Comments

Chander Kashyap May 16, 2014, 8:16 a.m. | #1
On 22 April 2014 18:08, Chander Kashyap <chander.kashyap@linaro.org> 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 <chander.kashyap@linaro.org>
> Reviewed-by: Tuukka Tikkanen <tuukka.tikkanen@linaro.org>
> ---
>  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;
>  }
>

ping.

> --
> 1.7.9.5
>
Rafael J. Wysocki May 16, 2014, 9:46 a.m. | #2
On 5/16/2014 10:16 AM, Chander Kashyap wrote:
> On 22 April 2014 18:08, Chander Kashyap <chander.kashyap@linaro.org> 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 <chander.kashyap@linaro.org>
>> Reviewed-by: Tuukka Tikkanen <tuukka.tikkanen@linaro.org>
>> ---
>>   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;
>>   }
>>
> ping.

I believe this is in linux-next today, care to check?

Rafael

--
To unsubscribe from this list: send the line "unsubscribe linux-pm" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Chander Kashyap May 16, 2014, 9:54 a.m. | #3
On 16 May 2014 15:16, Rafael J. Wysocki <rafael.j.wysocki@intel.com> wrote:
> On 5/16/2014 10:16 AM, Chander Kashyap wrote:
>>
>> On 22 April 2014 18:08, Chander Kashyap <chander.kashyap@linaro.org>
>> 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 <chander.kashyap@linaro.org>
>>> Reviewed-by: Tuukka Tikkanen <tuukka.tikkanen@linaro.org>
>>> ---
>>>   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;
>>>   }
>>>
>> ping.
>
>
> I believe this is in linux-next today, care to check?
>
> Rafael
>

Thanks, Rafael

Patch

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;
 }