Message ID | 20210503192810.36084-11-jandryuk@gmail.com (mailing list archive) |
---|---|
State | New, archived |
Headers | show |
Series | Intel Hardware P-States (HWP) support | expand |
On 03.05.2021 21:28, Jason Andryuk wrote: > Add xc_set_cpufreq_hwp to allow calling xen_systctl_pm_op > SET_CPUFREQ_HWP. > > Signed-off-by: Jason Andryuk <jandryuk@gmail.com> > > --- > Am I allowed to do set_hwp = *set_hwp struct assignment? I'm puzzled by the question - why would you not be? Jan
On Tue, May 4, 2021 at 4:03 AM Jan Beulich <jbeulich@suse.com> wrote: > > On 03.05.2021 21:28, Jason Andryuk wrote: > > Add xc_set_cpufreq_hwp to allow calling xen_systctl_pm_op > > SET_CPUFREQ_HWP. > > > > Signed-off-by: Jason Andryuk <jandryuk@gmail.com> > > > > --- > > Am I allowed to do set_hwp = *set_hwp struct assignment? > > I'm puzzled by the question - why would you not be? Yes, I thought it perfectly sensible to do. However, I didn't see other places in the file assigning structs, so I was not sure if there was some reason against it. Thanks for taking a look. Regards, Jason
On 03.05.2021 21:28, Jason Andryuk wrote: > --- a/tools/libs/ctrl/xc_pm.c > +++ b/tools/libs/ctrl/xc_pm.c > @@ -330,6 +330,24 @@ int xc_set_cpufreq_para(xc_interface *xch, int cpuid, > return xc_sysctl(xch, &sysctl); > } > > +int xc_set_cpufreq_hwp(xc_interface *xch, int cpuid, > + xc_set_hwp_para_t *set_hwp) Besides for general considerations, for xenpm to legitimately pass the same struct instance into this function multiple times, the last parameter wants to be pointer-to-const, declaring the intent of the function to leave the struct unaltered. Jan
diff --git a/tools/include/xenctrl.h b/tools/include/xenctrl.h index 82dfa1613a..0fd1e756cb 100644 --- a/tools/include/xenctrl.h +++ b/tools/include/xenctrl.h @@ -1994,11 +1994,15 @@ struct xc_get_cpufreq_para { int32_t turbo_enabled; }; +typedef struct xen_set_hwp_para xc_set_hwp_para_t; + int xc_get_cpufreq_para(xc_interface *xch, int cpuid, struct xc_get_cpufreq_para *user_para); int xc_set_cpufreq_gov(xc_interface *xch, int cpuid, char *govname); int xc_set_cpufreq_para(xc_interface *xch, int cpuid, int ctrl_type, int ctrl_value); +int xc_set_cpufreq_hwp(xc_interface *xch, int cpuid, + xc_set_hwp_para_t *set_hwp); 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); diff --git a/tools/libs/ctrl/xc_pm.c b/tools/libs/ctrl/xc_pm.c index 76d7eb7f26..407a24d2aa 100644 --- a/tools/libs/ctrl/xc_pm.c +++ b/tools/libs/ctrl/xc_pm.c @@ -330,6 +330,24 @@ int xc_set_cpufreq_para(xc_interface *xch, int cpuid, return xc_sysctl(xch, &sysctl); } +int xc_set_cpufreq_hwp(xc_interface *xch, int cpuid, + xc_set_hwp_para_t *set_hwp) +{ + DECLARE_SYSCTL; + + if ( !xch ) + { + errno = EINVAL; + return -1; + } + sysctl.cmd = XEN_SYSCTL_pm_op; + sysctl.u.pm_op.cmd = SET_CPUFREQ_HWP; + sysctl.u.pm_op.cpuid = cpuid; + sysctl.u.pm_op.u.set_hwp = *set_hwp; + + return xc_sysctl(xch, &sysctl); +} + int xc_get_cpufreq_avgfreq(xc_interface *xch, int cpuid, int *avg_freq) { int ret = 0;
Add xc_set_cpufreq_hwp to allow calling xen_systctl_pm_op SET_CPUFREQ_HWP. Signed-off-by: Jason Andryuk <jandryuk@gmail.com> --- Am I allowed to do set_hwp = *set_hwp struct assignment? --- tools/include/xenctrl.h | 4 ++++ tools/libs/ctrl/xc_pm.c | 18 ++++++++++++++++++ 2 files changed, 22 insertions(+)