tools/cpufreq: extract CPPC para from cpufreq para
PATCH v8 6/8 tools/cpufreq: extract CPPC para from cpufreq para
We extract cppc info from "struct xen_get_cpufreq_para", where it acts as a member of union, and share the space with governor info. However, it may fail in amd-cppc passive mode, in which governor info and CPPC info could co-exist, and both need to be printed together via xenpm tool. If we tried to still put it in "struct xen_get_cpufreq_para" (e.g. just move out of union), "struct xen_get_cpufreq_para" will enlarge too much to further make xen_sysctl.u exceed 128 bytes.
So we introduce a new sub-field GET_CPUFREQ_CPPC to dedicatedly acquire CPPC-related para, and make get-cpufreq-para invoke GET_CPUFREQ_CPPC if available.
New helpers print_cppc_para() and get_cpufreq_cppc() are introduced to extract CPPC-related parameters process from cpufreq para.
---
v4 -> v5:
- new commit
---
v5 -> v6:
- remove the changes for get-cpufreq-para
---
v6 -> v7:
- make get-cpufreq-para invoke GET_CPUFREQ_CPPC
---
v7 -> v8:
- use structure assignment as it is a alias
- add errno info to the error print
--- tools/include/xenctrl.h | 3 +- tools/libs/ctrl/xc_pm.c | 25 +++++++++++- tools/misc/xenpm.c | 79 ++++++++++++++++++++++++------------- xen/drivers/acpi/pm-op.c | 19 +++++++-- xen/include/public/sysctl.h | 3 +- 5 files changed, 96 insertions(+), 33 deletions(-)
tools/include/xenctrl.h +2 -1
@@ -1938,7 +1938,6 @@ struct xc_get_cpufreq_para {xc_ondemand_t ondemand; } u; } s; -xc_cppc_para_t cppc_para; } u;int32_t turbo_enabled;
@@ -1953,6 +1952,8 @@ int xc_set_cpufreq_para(xc_interface *xch, int cpuid, int ctrl_type, int ctrl_value);int xc_set_cpufreq_cppc (xc_interface *xch,int cpuid,xc_set_cppc_para_t *set_cppc); +int xc_get_cppc_para (xc_interface *xch,unsigned int cpuid, +xc_cppc_para_t *cppc_para);int xc_get_cpufreq_avgfreq (xc_interface *xch,int cpuid,int *avg_freq);int xc_set_sched_opt_smt (xc_interface *xch,uint32_t value);
tools/libs/ctrl/xc_pm.c +24 -1
@@ -288,7 +288,6 @@ int xc_get_cpufreq_para(xc_interface *xch, int cpuid,CHK_FIELD (s.scaling_min_freq);CHK_FIELD (s.u.userspace);CHK_FIELD (s.u.ondemand); -CHK_FIELD (cppc_para);#undef CHK_FIELD
@@ -366,6 +365,30 @@ int xc_set_cpufreq_cppc(xc_interface *xch, int cpuid,return ret; } +int xc_get_cppc_para (xc_interface *xch,unsigned int cpuid, +xc_cppc_para_t *cppc_para) +{ +int ret; +struct xen_sysctl sysctl = {}; + +if ( !xch || !cppc_para ) + { + errno =EINVAL ; +return -1 ; + } + + sysctl.cmd = XEN_SYSCTL_pm_op; + sysctl.u.pm_op.cmd =GET_CPUFREQ_CPPC ; + sysctl.u.pm_op.cpuid = cpuid; + + ret =xc_sysctl (xch, &sysctl); +if ( ret ) +return ret; + + *cppc_para = sysctl.u.pm_op.u.get_cppc; +return ret; +} +int xc_get_cpufreq_avgfreq (xc_interface *xch,int cpuid,int *avg_freq) {int ret =0 ;
tools/misc/xenpm.c +52 -27
104 lines not on this page · raw message
xen/drivers/acpi/pm-op.c +16 -3
@@ -77,6 +77,17 @@ static int read_scaling_available_governors(char *scaling_available_governors,return 0 ; } +static int get_cpufreq_cppc (unsigned int cpu, +struct xen_get_cppc_para *cppc_para) +{ +int ret = -ENODEV ; + +if (hwp_active () ) + ret =get_hwp_para (cpu, cppc_para); + +return ret; +} +static int get_cpufreq_para (struct xen_sysctl_pm_op *op) {uint32_t ret =0 ;
@@ -143,9 +154,7 @@ static int get_cpufreq_para(struct xen_sysctl_pm_op *op)else strlcpy (op->u.get_para.scaling_driver,"Unknown" ,CPUFREQ_NAME_LEN ); -if (hwp_active () ) - ret =get_hwp_para (policy->cpu, &op->u.get_para.u.cppc_para); -else +if ( !hwp_active () ) {if ( !(scaling_available_governors =xzalloc_array (char, gov_num *CPUFREQ_NAME_LEN )) )
@@ -385,6 +394,10 @@ int do_pm_op(struct xen_sysctl_pm_op *op) ret =set_cpufreq_para (op);break ; +case GET_CPUFREQ_CPPC : + ret =get_cpufreq_cppc (op->cpuid, &op->u.get_cppc); +break ; +case SET_CPUFREQ_CPPC : ret =set_cpufreq_cppc (op);break ;
xen/include/public/sysctl.h +2 -1
@@ -492,7 +492,6 @@ struct xen_get_cpufreq_para {struct xen_ondemand ondemand; } u; } s; -struct xen_get_cppc_para cppc_para; } u;int32_t turbo_enabled;
@@ -523,6 +522,7 @@ struct xen_sysctl_pm_op {#define SET_CPUFREQ_PARA (CPUFREQ_PARA | 0x03)#define GET_CPUFREQ_AVGFREQ (CPUFREQ_PARA | 0x04)#define SET_CPUFREQ_CPPC (CPUFREQ_PARA | 0x05) +#define GET_CPUFREQ_CPPC (CPUFREQ_PARA | 0x06)/* set/reset scheduler power saving option */ #define XEN_SYSCTL_pm_op_set_sched_opt_smt 0x21
@@ -547,6 +547,7 @@ struct xen_sysctl_pm_op {uint32_t cpuid;union {struct xen_get_cpufreq_para get_para; +struct xen_get_cppc_para get_cppc;struct xen_set_cpufreq_gov set_gov;struct xen_set_cpufreq_para set_para;struct xen_set_cppc_para set_cppc;
Signature · 1 line
2.34.1