diff mbox series

[15/19] cpupower: add amd-pstate sysfs entries into libcpufreq

Message ID 20210908150001.3702552-16-ray.huang@amd.com
State New
Headers show
Series [01/19] x86/cpufreatures: add AMD CPPC extension feature flag | expand

Commit Message

Huang Rui Sept. 8, 2021, 2:59 p.m. UTC
These amd-pstate sysfs entries will be used on cpupower for amd-pstate
kernel module.

Signed-off-by: Huang Rui <ray.huang@amd.com>
---
 tools/power/cpupower/lib/cpufreq.c | 18 +++++++++++++++++-
 1 file changed, 17 insertions(+), 1 deletion(-)

Comments

Shuah Khan Sept. 9, 2021, 10:26 p.m. UTC | #1
On 9/8/21 8:59 AM, Huang Rui wrote:
> These amd-pstate sysfs entries will be used on cpupower for amd-pstate

> kernel module.

> 


This commit log doesn't make sense. If these sysfs entries are used
for amd-pstate kernel module, why are they defined here.

Describe how these are used and the relationship between these defines
and the amd-pstate kernel module

> Signed-off-by: Huang Rui <ray.huang@amd.com>

> ---

>   tools/power/cpupower/lib/cpufreq.c | 18 +++++++++++++++++-

>   1 file changed, 17 insertions(+), 1 deletion(-)

> 

> diff --git a/tools/power/cpupower/lib/cpufreq.c b/tools/power/cpupower/lib/cpufreq.c

> index c3b56db8b921..3f92ddadaad2 100644

> --- a/tools/power/cpupower/lib/cpufreq.c

> +++ b/tools/power/cpupower/lib/cpufreq.c

> @@ -69,6 +69,14 @@ enum cpufreq_value {

>   	SCALING_MIN_FREQ,

>   	SCALING_MAX_FREQ,

>   	STATS_NUM_TRANSITIONS,

> +	AMD_PSTATE_HIGHEST_PERF,

> +	AMD_PSTATE_NOMINAL_PERF,

> +	AMD_PSTATE_LOWEST_NONLINEAR_PERF,

> +	AMD_PSTATE_LOWEST_PERF,

> +	AMD_PSTATE_MAX_FREQ,

> +	AMD_PSTATE_NOMINAL_FREQ,

> +	AMD_PSTATE_LOWEST_NONLINEAR_FREQ,

> +	AMD_PSTATE_MIN_FREQ,

>   	MAX_CPUFREQ_VALUE_READ_FILES

>   };

>   


These are AMD specific values being added to a common code.

> @@ -80,7 +88,15 @@ static const char *cpufreq_value_files[MAX_CPUFREQ_VALUE_READ_FILES] = {

>   	[SCALING_CUR_FREQ] = "scaling_cur_freq",

>   	[SCALING_MIN_FREQ] = "scaling_min_freq",

>   	[SCALING_MAX_FREQ] = "scaling_max_freq",

> -	[STATS_NUM_TRANSITIONS] = "stats/total_trans"

> +	[STATS_NUM_TRANSITIONS] = "stats/total_trans",

> +	[AMD_PSTATE_HIGHEST_PERF] = "amd_pstate_highest_perf",

> +	[AMD_PSTATE_NOMINAL_PERF] = "amd_pstate_nominal_perf",

> +	[AMD_PSTATE_LOWEST_NONLINEAR_PERF] = "amd_pstate_lowest_nonlinear_perf",

> +	[AMD_PSTATE_LOWEST_PERF] = "amd_pstate_lowest_perf",

> +	[AMD_PSTATE_MAX_FREQ] = "amd_pstate_max_freq",

> +	[AMD_PSTATE_NOMINAL_FREQ] = "amd_pstate_nominal_freq",

> +	[AMD_PSTATE_LOWEST_NONLINEAR_FREQ] = "amd_pstate_lowest_nonlinear_freq",

> +	[AMD_PSTATE_MIN_FREQ] = "amd_pstate_min_freq"

>   };

>   

>   

> 


These are AMD specific values being added to a common code.
It doesn't sound right. What happens if there is a conflict
between AMD values and another vendor values?

This doesn't seem a good place to add these.

thanks,
-- Shuah
Huang Rui Sept. 16, 2021, 8:47 a.m. UTC | #2
On Fri, Sep 10, 2021 at 06:26:06AM +0800, Shuah Khan wrote:
> On 9/8/21 8:59 AM, Huang Rui wrote:

> > These amd-pstate sysfs entries will be used on cpupower for amd-pstate

> > kernel module.

> > 

> 

> This commit log doesn't make sense. If these sysfs entries are used

> for amd-pstate kernel module, why are they defined here.

> 

> Describe how these are used and the relationship between these defines

> and the amd-pstate kernel module

> 

> > Signed-off-by: Huang Rui <ray.huang@amd.com>

> > ---

> >   tools/power/cpupower/lib/cpufreq.c | 18 +++++++++++++++++-

> >   1 file changed, 17 insertions(+), 1 deletion(-)

> > 

> > diff --git a/tools/power/cpupower/lib/cpufreq.c b/tools/power/cpupower/lib/cpufreq.c

> > index c3b56db8b921..3f92ddadaad2 100644

> > --- a/tools/power/cpupower/lib/cpufreq.c

> > +++ b/tools/power/cpupower/lib/cpufreq.c

> > @@ -69,6 +69,14 @@ enum cpufreq_value {

> >   	SCALING_MIN_FREQ,

> >   	SCALING_MAX_FREQ,

> >   	STATS_NUM_TRANSITIONS,

> > +	AMD_PSTATE_HIGHEST_PERF,

> > +	AMD_PSTATE_NOMINAL_PERF,

> > +	AMD_PSTATE_LOWEST_NONLINEAR_PERF,

> > +	AMD_PSTATE_LOWEST_PERF,

> > +	AMD_PSTATE_MAX_FREQ,

> > +	AMD_PSTATE_NOMINAL_FREQ,

> > +	AMD_PSTATE_LOWEST_NONLINEAR_FREQ,

> > +	AMD_PSTATE_MIN_FREQ,

> >   	MAX_CPUFREQ_VALUE_READ_FILES

> >   };

> >   

> 

> These are AMD specific values being added to a common code.

> 

> > @@ -80,7 +88,15 @@ static const char *cpufreq_value_files[MAX_CPUFREQ_VALUE_READ_FILES] = {

> >   	[SCALING_CUR_FREQ] = "scaling_cur_freq",

> >   	[SCALING_MIN_FREQ] = "scaling_min_freq",

> >   	[SCALING_MAX_FREQ] = "scaling_max_freq",

> > -	[STATS_NUM_TRANSITIONS] = "stats/total_trans"

> > +	[STATS_NUM_TRANSITIONS] = "stats/total_trans",

> > +	[AMD_PSTATE_HIGHEST_PERF] = "amd_pstate_highest_perf",

> > +	[AMD_PSTATE_NOMINAL_PERF] = "amd_pstate_nominal_perf",

> > +	[AMD_PSTATE_LOWEST_NONLINEAR_PERF] = "amd_pstate_lowest_nonlinear_perf",

> > +	[AMD_PSTATE_LOWEST_PERF] = "amd_pstate_lowest_perf",

> > +	[AMD_PSTATE_MAX_FREQ] = "amd_pstate_max_freq",

> > +	[AMD_PSTATE_NOMINAL_FREQ] = "amd_pstate_nominal_freq",

> > +	[AMD_PSTATE_LOWEST_NONLINEAR_FREQ] = "amd_pstate_lowest_nonlinear_freq",

> > +	[AMD_PSTATE_MIN_FREQ] = "amd_pstate_min_freq"

> >   };

> >   

> >   

> > 

> 

> These are AMD specific values being added to a common code.

> It doesn't sound right. What happens if there is a conflict

> between AMD values and another vendor values?

> 

> This doesn't seem a good place to add these.

> 


Shuah, thanks for your suggestion, I went through the cpupower patches
again. And yes, we should not combine the amd specific and common things
together.

Could I expose a simliar sysfs_cpufreq_get_one_value in cpupower_intern.h
header, and move amd_pstate_* function implementation into
utils/helpers/amd.c? It can keep the lib/cpufreq still general.

Thanks,
Ray
diff mbox series

Patch

diff --git a/tools/power/cpupower/lib/cpufreq.c b/tools/power/cpupower/lib/cpufreq.c
index c3b56db8b921..3f92ddadaad2 100644
--- a/tools/power/cpupower/lib/cpufreq.c
+++ b/tools/power/cpupower/lib/cpufreq.c
@@ -69,6 +69,14 @@  enum cpufreq_value {
 	SCALING_MIN_FREQ,
 	SCALING_MAX_FREQ,
 	STATS_NUM_TRANSITIONS,
+	AMD_PSTATE_HIGHEST_PERF,
+	AMD_PSTATE_NOMINAL_PERF,
+	AMD_PSTATE_LOWEST_NONLINEAR_PERF,
+	AMD_PSTATE_LOWEST_PERF,
+	AMD_PSTATE_MAX_FREQ,
+	AMD_PSTATE_NOMINAL_FREQ,
+	AMD_PSTATE_LOWEST_NONLINEAR_FREQ,
+	AMD_PSTATE_MIN_FREQ,
 	MAX_CPUFREQ_VALUE_READ_FILES
 };
 
@@ -80,7 +88,15 @@  static const char *cpufreq_value_files[MAX_CPUFREQ_VALUE_READ_FILES] = {
 	[SCALING_CUR_FREQ] = "scaling_cur_freq",
 	[SCALING_MIN_FREQ] = "scaling_min_freq",
 	[SCALING_MAX_FREQ] = "scaling_max_freq",
-	[STATS_NUM_TRANSITIONS] = "stats/total_trans"
+	[STATS_NUM_TRANSITIONS] = "stats/total_trans",
+	[AMD_PSTATE_HIGHEST_PERF] = "amd_pstate_highest_perf",
+	[AMD_PSTATE_NOMINAL_PERF] = "amd_pstate_nominal_perf",
+	[AMD_PSTATE_LOWEST_NONLINEAR_PERF] = "amd_pstate_lowest_nonlinear_perf",
+	[AMD_PSTATE_LOWEST_PERF] = "amd_pstate_lowest_perf",
+	[AMD_PSTATE_MAX_FREQ] = "amd_pstate_max_freq",
+	[AMD_PSTATE_NOMINAL_FREQ] = "amd_pstate_nominal_freq",
+	[AMD_PSTATE_LOWEST_NONLINEAR_FREQ] = "amd_pstate_lowest_nonlinear_freq",
+	[AMD_PSTATE_MIN_FREQ] = "amd_pstate_min_freq"
 };