From: Jason Andryuk <jandryuk@gmail.com>
To: xen-devel@lists.xenproject.org
Cc: "Jason Andryuk" <jandryuk@gmail.com>,
"Jan Beulich" <jbeulich@suse.com>,
"Andrew Cooper" <andrew.cooper3@citrix.com>,
"Roger Pau Monné" <roger.pau@citrix.com>, "Wei Liu" <wl@xen.org>,
"George Dunlap" <george.dunlap@citrix.com>,
"Ian Jackson" <iwj@xenproject.org>,
"Julien Grall" <julien@xen.org>,
"Stefano Stabellini" <sstabellini@kernel.org>
Subject: [PATCH 06/13] cpufreq: Export HWP parameters to userspace
Date: Mon, 3 May 2021 15:28:03 -0400 [thread overview]
Message-ID: <20210503192810.36084-7-jandryuk@gmail.com> (raw)
In-Reply-To: <20210503192810.36084-1-jandryuk@gmail.com>
Extend xen_get_cpufreq_para to return hwp parameters. These match the
hardware rather closely.
We need the hw_features bitmask to indicated fields supported by the
actual hardware.
The use of uint8_t parameters matches the hardware size. uint32_t
entries grows the sysctl_t past the build assertion in setup.c. The
uint8_t ranges are supported across multiple generations, so hopefully
they won't change.
Increment XEN_SYSCTL_INTERFACE_VERSION for the new fields.
Signed-off-by: Jason Andryuk <jandryuk@gmail.com>
---
xen/arch/x86/acpi/cpufreq/hwp.c | 24 ++++++++++++++++++++++++
xen/drivers/acpi/pmstat.c | 6 ++++++
xen/include/acpi/cpufreq/cpufreq.h | 3 +++
xen/include/public/sysctl.h | 20 +++++++++++++++++++-
4 files changed, 52 insertions(+), 1 deletion(-)
diff --git a/xen/arch/x86/acpi/cpufreq/hwp.c b/xen/arch/x86/acpi/cpufreq/hwp.c
index f8e6fdbd41..92222d6d85 100644
--- a/xen/arch/x86/acpi/cpufreq/hwp.c
+++ b/xen/arch/x86/acpi/cpufreq/hwp.c
@@ -523,6 +523,30 @@ static const struct cpufreq_driver __initconstrel hwp_cpufreq_driver =
.update = hwp_cpufreq_update,
};
+int get_hwp_para(struct cpufreq_policy *policy, struct xen_hwp_para *hwp_para)
+{
+ unsigned int cpu = policy->cpu;
+ struct hwp_drv_data *data = hwp_drv_data[cpu];
+
+ if ( data == NULL )
+ return -EINVAL;
+
+ hwp_para->hw_feature =
+ feature_hwp_activity_window ? XEN_SYSCTL_HWP_FEAT_ACT_WINDOW : 0 |
+ feature_hwp_energy_perf ? XEN_SYSCTL_HWP_FEAT_ENERGY_PERF : 0;
+ hwp_para->hw_lowest = data->hw_lowest;
+ hwp_para->hw_most_efficient = data->hw_most_efficient;
+ hwp_para->hw_guaranteed = data->hw_guaranteed;
+ hwp_para->hw_highest = data->hw_highest;
+ hwp_para->minimum = data->minimum;
+ hwp_para->maximum = data->maximum;
+ hwp_para->energy_perf = data->energy_perf;
+ hwp_para->activity_window = data->activity_window;
+ hwp_para->desired = data->desired;
+
+ return 0;
+}
+
int hwp_register_driver(void)
{
int ret;
diff --git a/xen/drivers/acpi/pmstat.c b/xen/drivers/acpi/pmstat.c
index 1bae635101..3e35c42949 100644
--- a/xen/drivers/acpi/pmstat.c
+++ b/xen/drivers/acpi/pmstat.c
@@ -290,6 +290,12 @@ static int get_cpufreq_para(struct xen_sysctl_pm_op *op)
&op->u.get_para.u.ondemand.sampling_rate,
&op->u.get_para.u.ondemand.up_threshold);
}
+
+ if ( !strncasecmp(op->u.get_para.scaling_governor,
+ "hwp-internal", CPUFREQ_NAME_LEN) )
+ {
+ ret = get_hwp_para(policy, &op->u.get_para.u.hwp_para);
+ }
op->u.get_para.turbo_enabled = cpufreq_get_turbo_status(op->cpuid);
return ret;
diff --git a/xen/include/acpi/cpufreq/cpufreq.h b/xen/include/acpi/cpufreq/cpufreq.h
index b91859ce5d..42146ca2cf 100644
--- a/xen/include/acpi/cpufreq/cpufreq.h
+++ b/xen/include/acpi/cpufreq/cpufreq.h
@@ -246,4 +246,7 @@ int write_userspace_scaling_setspeed(unsigned int cpu, unsigned int freq);
void cpufreq_dbs_timer_suspend(void);
void cpufreq_dbs_timer_resume(void);
+/********************** hwp hypercall helper *************************/
+int get_hwp_para(struct cpufreq_policy *policy, struct xen_hwp_para *hwp_para);
+
#endif /* __XEN_CPUFREQ_PM_H__ */
diff --git a/xen/include/public/sysctl.h b/xen/include/public/sysctl.h
index 039ccf885c..1a6c6397ea 100644
--- a/xen/include/public/sysctl.h
+++ b/xen/include/public/sysctl.h
@@ -35,7 +35,7 @@
#include "domctl.h"
#include "physdev.h"
-#define XEN_SYSCTL_INTERFACE_VERSION 0x00000013
+#define XEN_SYSCTL_INTERFACE_VERSION 0x00000014
/*
* Read console content from Xen buffer ring.
@@ -301,6 +301,23 @@ struct xen_ondemand {
uint32_t up_threshold;
};
+struct xen_hwp_para {
+ uint16_t activity_window; /* 7bit mantissa and 3bit exponent */
+#define XEN_SYSCTL_HWP_FEAT_ENERGY_PERF (1 << 0) /* energy_perf range 0-255 if
+ 1. Otherwise 0-15 */
+#define XEN_SYSCTL_HWP_FEAT_ACT_WINDOW (1 << 1) /* activity_window supported
+ if 1 */
+ uint8_t hw_feature; /* bit flags for features */
+ uint8_t hw_lowest;
+ uint8_t hw_most_efficient;
+ uint8_t hw_guaranteed;
+ uint8_t hw_highest;
+ uint8_t minimum;
+ uint8_t maximum;
+ uint8_t desired;
+ uint8_t energy_perf;
+};
+
/*
* cpufreq para name of this structure named
* same as sysfs file name of native linux
@@ -332,6 +349,7 @@ struct xen_get_cpufreq_para {
union {
struct xen_userspace userspace;
struct xen_ondemand ondemand;
+ struct xen_hwp_para hwp_para;
} u;
int32_t turbo_enabled;
--
2.30.2
next prev parent reply other threads:[~2021-05-03 19:29 UTC|newest]
Thread overview: 44+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-05-03 19:27 [PATCH 00/13] Intel Hardware P-States (HWP) support Jason Andryuk
2021-05-03 19:27 ` [PATCH 01/13] cpufreq: Allow restricting to internal governors only Jason Andryuk
2021-05-26 13:18 ` Jan Beulich
2021-05-26 14:12 ` Jason Andryuk
2021-05-26 15:09 ` Jan Beulich
2021-05-26 16:44 ` Jason Andryuk
2021-05-03 19:27 ` [PATCH 02/13] cpufreq: Add perf_freq to cpuinfo Jason Andryuk
2021-05-26 13:24 ` Jan Beulich
2021-05-26 14:19 ` Jason Andryuk
2021-05-03 19:28 ` [PATCH 03/13] cpufreq: Export intel_feature_detect Jason Andryuk
2021-05-26 13:27 ` Jan Beulich
2021-05-26 14:44 ` Jason Andryuk
2021-05-26 15:11 ` Jan Beulich
2021-05-03 19:28 ` [PATCH 04/13] cpufreq: Add Hardware P-State (HWP) driver Jason Andryuk
2021-05-26 14:59 ` Jan Beulich
2021-05-27 7:23 ` Jan Beulich
2021-05-27 18:50 ` Jason Andryuk
2021-05-28 6:35 ` Jan Beulich
2021-06-03 11:55 ` Jason Andryuk
2021-06-04 6:39 ` Jan Beulich
2021-05-27 7:45 ` Jan Beulich
2021-05-03 19:28 ` [PATCH 05/13] xenpm: Change get-cpufreq-para output for internal Jason Andryuk
2021-05-26 15:21 ` Jan Beulich
2021-05-27 5:54 ` Jan Beulich
2021-05-03 19:28 ` Jason Andryuk [this message]
2021-05-27 7:55 ` [PATCH 06/13] cpufreq: Export HWP parameters to userspace Jan Beulich
2021-05-28 13:19 ` Jason Andryuk
2021-05-28 13:39 ` Jan Beulich
2021-05-03 19:28 ` [PATCH 07/13] libxc: Include hwp_para in definitions Jason Andryuk
2021-05-03 19:28 ` [PATCH 08/13] xenpm: Print HWP parameters Jason Andryuk
2021-05-27 8:02 ` Jan Beulich
2021-05-03 19:28 ` [PATCH 09/13] xen: Add SET_CPUFREQ_HWP xen_sysctl_pm_op Jason Andryuk
2021-05-27 8:33 ` Jan Beulich
2021-05-03 19:28 ` [PATCH 10/13] libxc: Add xc_set_cpufreq_hwp Jason Andryuk
2021-05-04 8:03 ` Jan Beulich
2021-05-04 11:31 ` Jason Andryuk
2021-05-27 9:45 ` Jan Beulich
2021-05-03 19:28 ` [PATCH 11/13] xenpm: Factor out a non-fatal cpuid_parse variant Jason Andryuk
2021-05-27 8:41 ` Jan Beulich
2021-05-03 19:28 ` [PATCH 12/13] xenpm: Add set-cpufreq-hwp subcommand Jason Andryuk
2021-05-27 9:46 ` Jan Beulich
2021-05-03 19:28 ` [PATCH 13/13] CHANGELOG: Add Intel HWP entry Jason Andryuk
2021-05-27 9:48 ` Jan Beulich
2021-05-20 14:57 ` [PATCH 00/13] Intel Hardware P-States (HWP) support Jan Beulich
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20210503192810.36084-7-jandryuk@gmail.com \
--to=jandryuk@gmail.com \
--cc=andrew.cooper3@citrix.com \
--cc=george.dunlap@citrix.com \
--cc=iwj@xenproject.org \
--cc=jbeulich@suse.com \
--cc=julien@xen.org \
--cc=roger.pau@citrix.com \
--cc=sstabellini@kernel.org \
--cc=wl@xen.org \
--cc=xen-devel@lists.xenproject.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).