[dpdk-dev,v5,4/9] examples/vm_power_mgr: add scale to medium freq fn

Message ID 1507130720-48891-5-git-send-email-david.hunt@intel.com (mailing list archive)
State Superseded, archived
Headers

Checks

Context Check Description
ci/checkpatch success coding style OK

Commit Message

Hunt, David Oct. 4, 2017, 3:25 p.m. UTC
  Signed-off-by: Nemanja Marjanovic <nemanja.marjanovic@intel.com>
Signed-off-by: Rory Sexton <rory.sexton@intel.com>
Signed-off-by: David Hunt <david.hunt@intel.com>
---
 examples/vm_power_manager/power_manager.c | 15 +++++++++++++++
 examples/vm_power_manager/power_manager.h | 13 +++++++++++++
 2 files changed, 28 insertions(+)
  

Comments

Santosh Shukla Oct. 4, 2017, 4:04 p.m. UTC | #1
Hi David,


On Wednesday 04 October 2017 08:55 PM, David Hunt wrote:
> Signed-off-by: Nemanja Marjanovic <nemanja.marjanovic@intel.com>
> Signed-off-by: Rory Sexton <rory.sexton@intel.com>
> Signed-off-by: David Hunt <david.hunt@intel.com>
> ---
>  examples/vm_power_manager/power_manager.c | 15 +++++++++++++++
>  examples/vm_power_manager/power_manager.h | 13 +++++++++++++
>  2 files changed, 28 insertions(+)
>
> diff --git a/examples/vm_power_manager/power_manager.c b/examples/vm_power_manager/power_manager.c
> index 80705f9..c021c1d 100644
> --- a/examples/vm_power_manager/power_manager.c
> +++ b/examples/vm_power_manager/power_manager.c
> @@ -286,3 +286,18 @@ power_manager_disable_turbo_core(unsigned int core_num)
>  	POWER_SCALE_CORE(disable_turbo, core_num, ret);
>  	return ret;
>  }
> +
> +int
> +power_manager_scale_core_med(unsigned int core_num)
> +{
> +	int ret = 0;
> +
> +	if (core_num >= POWER_MGR_MAX_CPUS)
> +		return -1;
> +	if (!(global_enabled_cpus & (1ULL << core_num)))
> +		return -1;
> +	rte_spinlock_lock(&global_core_freq_info[core_num].power_sl);
> +	ret = rte_power_set_freq(core_num, 5);

nits:
what is 5? also should be enum or macro.

Thanks.
  
Hunt, David Oct. 5, 2017, 8:47 a.m. UTC | #2
Hi Santosh,


On 4/10/2017 5:04 PM, santosh wrote:
> Hi David,
>
>
> On Wednesday 04 October 2017 08:55 PM, David Hunt wrote:
>> Signed-off-by: Nemanja Marjanovic <nemanja.marjanovic@intel.com>
>> Signed-off-by: Rory Sexton <rory.sexton@intel.com>
>> Signed-off-by: David Hunt <david.hunt@intel.com>
>> ---
>>   examples/vm_power_manager/power_manager.c | 15 +++++++++++++++
>>   examples/vm_power_manager/power_manager.h | 13 +++++++++++++
>>   2 files changed, 28 insertions(+)
>>
>> diff --git a/examples/vm_power_manager/power_manager.c b/examples/vm_power_manager/power_manager.c
>> index 80705f9..c021c1d 100644
>> --- a/examples/vm_power_manager/power_manager.c
>> +++ b/examples/vm_power_manager/power_manager.c
>> @@ -286,3 +286,18 @@ power_manager_disable_turbo_core(unsigned int core_num)
>>   	POWER_SCALE_CORE(disable_turbo, core_num, ret);
>>   	return ret;
>>   }
>> +
>> +int
>> +power_manager_scale_core_med(unsigned int core_num)
>> +{
>> +	int ret = 0;
>> +
>> +	if (core_num >= POWER_MGR_MAX_CPUS)
>> +		return -1;
>> +	if (!(global_enabled_cpus & (1ULL << core_num)))
>> +		return -1;
>> +	rte_spinlock_lock(&global_core_freq_info[core_num].power_sl);
>> +	ret = rte_power_set_freq(core_num, 5);
> nits:
> what is 5? also should be enum or macro.
>
> Thanks.
>

This probably shouldn't be hard-coded. The intention is to select a 
middle frequency. I can add a helper function to get the value
that is halfway between min and max, and use that instead.

Thanks,
Dave.
  
Santosh Shukla Oct. 5, 2017, 9:07 a.m. UTC | #3
Hi David,


On Thursday 05 October 2017 02:17 PM, Hunt, David wrote:
> Hi Santosh,
>
>
> On 4/10/2017 5:04 PM, santosh wrote:
>> Hi David,
>>
>>
>> On Wednesday 04 October 2017 08:55 PM, David Hunt wrote:
>>> Signed-off-by: Nemanja Marjanovic <nemanja.marjanovic@intel.com>
>>> Signed-off-by: Rory Sexton <rory.sexton@intel.com>
>>> Signed-off-by: David Hunt <david.hunt@intel.com>
>>> ---
>>>   examples/vm_power_manager/power_manager.c | 15 +++++++++++++++
>>>   examples/vm_power_manager/power_manager.h | 13 +++++++++++++
>>>   2 files changed, 28 insertions(+)
>>>
>>> diff --git a/examples/vm_power_manager/power_manager.c b/examples/vm_power_manager/power_manager.c
>>> index 80705f9..c021c1d 100644
>>> --- a/examples/vm_power_manager/power_manager.c
>>> +++ b/examples/vm_power_manager/power_manager.c
>>> @@ -286,3 +286,18 @@ power_manager_disable_turbo_core(unsigned int core_num)
>>>       POWER_SCALE_CORE(disable_turbo, core_num, ret);
>>>       return ret;
>>>   }
>>> +
>>> +int
>>> +power_manager_scale_core_med(unsigned int core_num)
>>> +{
>>> +    int ret = 0;
>>> +
>>> +    if (core_num >= POWER_MGR_MAX_CPUS)
>>> +        return -1;
>>> +    if (!(global_enabled_cpus & (1ULL << core_num)))
>>> +        return -1;
>>> +    rte_spinlock_lock(&global_core_freq_info[core_num].power_sl);
>>> +    ret = rte_power_set_freq(core_num, 5);
>> nits:
>> what is 5? also should be enum or macro.
>>
>> Thanks.
>>
>
> This probably shouldn't be hard-coded. The intention is to select a middle frequency. I can add a helper function to get the value
> that is halfway between min and max, and use that instead.
>
I'm ok with your proposition.
Thanks.

> Thanks,
> Dave.
>
>
>
  

Patch

diff --git a/examples/vm_power_manager/power_manager.c b/examples/vm_power_manager/power_manager.c
index 80705f9..c021c1d 100644
--- a/examples/vm_power_manager/power_manager.c
+++ b/examples/vm_power_manager/power_manager.c
@@ -286,3 +286,18 @@  power_manager_disable_turbo_core(unsigned int core_num)
 	POWER_SCALE_CORE(disable_turbo, core_num, ret);
 	return ret;
 }
+
+int
+power_manager_scale_core_med(unsigned int core_num)
+{
+	int ret = 0;
+
+	if (core_num >= POWER_MGR_MAX_CPUS)
+		return -1;
+	if (!(global_enabled_cpus & (1ULL << core_num)))
+		return -1;
+	rte_spinlock_lock(&global_core_freq_info[core_num].power_sl);
+	ret = rte_power_set_freq(core_num, 5);
+	rte_spinlock_unlock(&global_core_freq_info[core_num].power_sl);
+	return ret;
+}
diff --git a/examples/vm_power_manager/power_manager.h b/examples/vm_power_manager/power_manager.h
index b74d09b..b52fb4c 100644
--- a/examples/vm_power_manager/power_manager.h
+++ b/examples/vm_power_manager/power_manager.h
@@ -231,6 +231,19 @@  int power_manager_disable_turbo_core(unsigned int core_num);
  */
 uint32_t power_manager_get_current_frequency(unsigned core_num);
 
+/**
+ * Scale to medium frequency for the core specified by core_num.
+ * It is thread-safe.
+ *
+ * @param core_num
+ *  The core number to change frequency
+ *
+ * @return
+ *  - 1 on success.
+ *  - 0 if frequency not changed.
+ *  - Negative on error.
+ */
+int power_manager_scale_core_med(unsigned int core_num);
 
 #ifdef __cplusplus
 }