From: "Jan Beulich" <JBeulich@suse.com>
To: "xen-devel" <xen-devel@lists.xenproject.org>
Cc: Andrew Cooper <andrew.cooper3@citrix.com>,
Wei Liu <wei.liu2@citrix.com>,
Ian Jackson <Ian.Jackson@eu.citrix.com>,
Roger Pau Monne <roger.pau@citrix.com>
Subject: [Xen-devel] [PATCH 5/5] tools/libxc: allow controlling the max C-state sub-state
Date: Thu, 23 May 2019 06:19:39 -0600 [thread overview]
Message-ID: <5CE68FDB0200007800231B41@prv1-mh.provo.novell.com> (raw)
Message-ID: <20190523121939.OeCZvSh7FSxJVnshXuFbT0jLCpgdibabmMLdYfzF3hg@z> (raw)
In-Reply-To: <5CE68CD30200007800231B01@prv1-mh.provo.novell.com>
From: Ross Lagerwall <ross.lagerwall@citrix.com>
Signed-off-by: Ross Lagerwall <ross.lagerwall@citrix.com>
Make handling in do_pm_op() more homogeneous: Before interpreting
op->cpuid as such, handle all operations not acting on a particular
CPU. Also expose the setting via xenpm.
Signed-off-by: Jan Beulich <jbeulich@suse.com>
--- a/tools/libxc/xc_pm.c
+++ b/tools/libxc/xc_pm.c
@@ -367,7 +367,7 @@ int xc_set_sched_opt_smt(xc_interface *x
return rc;
}
-int xc_get_cpuidle_max_cstate(xc_interface *xch, uint32_t *value)
+static int get_max_cstate(xc_interface *xch, uint32_t *value, uint32_t type)
{
int rc;
DECLARE_SYSCTL;
@@ -379,7 +379,7 @@ int xc_get_cpuidle_max_cstate(xc_interfa
}
sysctl.cmd = XEN_SYSCTL_pm_op;
sysctl.u.pm_op.cmd = XEN_SYSCTL_pm_op_get_max_cstate;
- sysctl.u.pm_op.cpuid = 0;
+ sysctl.u.pm_op.cpuid = type;
sysctl.u.pm_op.u.get_max_cstate = 0;
rc = do_sysctl(xch, &sysctl);
*value = sysctl.u.pm_op.u.get_max_cstate;
@@ -387,7 +387,17 @@ int xc_get_cpuidle_max_cstate(xc_interfa
return rc;
}
-int xc_set_cpuidle_max_cstate(xc_interface *xch, uint32_t value)
+int xc_get_cpuidle_max_cstate(xc_interface *xch, uint32_t *value)
+{
+ return get_max_cstate(xch, value, 0);
+}
+
+int xc_get_cpuidle_max_csubstate(xc_interface *xch, uint32_t *value)
+{
+ return get_max_cstate(xch, value, 1);
+}
+
+static int set_max_cstate(xc_interface *xch, uint32_t value, uint32_t type)
{
DECLARE_SYSCTL;
@@ -398,12 +408,22 @@ int xc_set_cpuidle_max_cstate(xc_interfa
}
sysctl.cmd = XEN_SYSCTL_pm_op;
sysctl.u.pm_op.cmd = XEN_SYSCTL_pm_op_set_max_cstate;
- sysctl.u.pm_op.cpuid = 0;
+ sysctl.u.pm_op.cpuid = type;
sysctl.u.pm_op.u.set_max_cstate = value;
return do_sysctl(xch, &sysctl);
}
+int xc_set_cpuidle_max_cstate(xc_interface *xch, uint32_t value)
+{
+ return set_max_cstate(xch, value, 0);
+}
+
+int xc_set_cpuidle_max_csubstate(xc_interface *xch, uint32_t value)
+{
+ return set_max_cstate(xch, value, 1);
+}
+
int xc_enable_turbo(xc_interface *xch, int cpuid)
{
DECLARE_SYSCTL;
--- a/tools/libxc/include/xenctrl.h
+++ b/tools/libxc/include/xenctrl.h
@@ -1906,6 +1906,9 @@ int xc_set_sched_opt_smt(xc_interface *x
int xc_get_cpuidle_max_cstate(xc_interface *xch, uint32_t *value);
int xc_set_cpuidle_max_cstate(xc_interface *xch, uint32_t value);
+int xc_get_cpuidle_max_csubstate(xc_interface *xch, uint32_t *value);
+int xc_set_cpuidle_max_csubstate(xc_interface *xch, uint32_t value);
+
int xc_enable_turbo(xc_interface *xch, int cpuid);
int xc_disable_turbo(xc_interface *xch, int cpuid);
--- a/tools/misc/xenpm.c
+++ b/tools/misc/xenpm.c
@@ -195,7 +195,15 @@ static int show_max_cstate(xc_interface
return ret;
if ( value < XEN_SYSCTL_CX_UNLIMITED )
- printf("Max possible C-state: C%"PRIu32"\n\n", value);
+ {
+ printf("Max possible C-state: C%"PRIu32"\n", value);
+ if ( (ret = xc_get_cpuidle_max_csubstate(xc_handle, &value)) )
+ return ret;
+ if ( value < XEN_SYSCTL_CX_UNLIMITED )
+ printf("Max possible substate: %"PRIu32"\n\n", value);
+ else
+ puts("");
+ }
else
printf("All C-states allowed\n\n");
@@ -1120,13 +1128,17 @@ void get_vcpu_migration_delay_func(int a
void set_max_cstate_func(int argc, char *argv[])
{
- int value;
+ int value, subval = XEN_SYSCTL_CX_UNLIMITED;
char buf[12];
- if ( argc != 1 ||
+ if ( argc < 1 || argc > 2 ||
(sscanf(argv[0], "%d", &value) == 1
? value < 0
- : (value = XEN_SYSCTL_CX_UNLIMITED, strcmp(argv[0], "unlimited"))) )
+ : (value = XEN_SYSCTL_CX_UNLIMITED, strcmp(argv[0], "unlimited"))) ||
+ (argc == 2 &&
+ (sscanf(argv[1], "%d", &subval) == 1
+ ? subval < 0
+ : (subval = XEN_SYSCTL_CX_UNLIMITED, strcmp(argv[1], "unlimited")))) )
{
fprintf(stderr, "Missing, excess, or invalid argument(s)\n");
exit(EINVAL);
@@ -1137,8 +1149,23 @@ void set_max_cstate_func(int argc, char
if ( !xc_set_cpuidle_max_cstate(xc_handle, (uint32_t)value) )
printf("set max C-state to %s succeeded\n", value >= 0 ? buf : argv[0]);
else
+ {
fprintf(stderr, "set max C-state to %s failed (%d - %s)\n",
value >= 0 ? buf : argv[0], errno, strerror(errno));
+ return;
+ }
+
+ if ( value != XEN_SYSCTL_CX_UNLIMITED )
+ {
+ snprintf(buf, ARRAY_SIZE(buf), "%d", subval);
+
+ if ( !xc_set_cpuidle_max_csubstate(xc_handle, (uint32_t)subval) )
+ printf("set max C-substate to %s succeeded\n",
+ subval >= 0 ? buf : "unlimited");
+ else
+ fprintf(stderr, "set max C-substate to %s failed (%d - %s)\n",
+ subval >= 0 ? buf : "unlimited", errno, strerror(errno));
+ }
}
void enable_turbo_mode(int argc, char *argv[])
--- a/xen/drivers/acpi/pmstat.c
+++ b/xen/drivers/acpi/pmstat.c
@@ -398,7 +398,40 @@ int do_pm_op(struct xen_sysctl_pm_op *op
int ret = 0;
const struct processor_pminfo *pmpt;
- if ( !op || op->cpuid >= nr_cpu_ids || !cpu_online(op->cpuid) )
+ switch ( op->cmd )
+ {
+ case XEN_SYSCTL_pm_op_set_sched_opt_smt:
+ {
+ uint32_t saved_value = sched_smt_power_savings;
+
+ if ( op->cpuid != 0 )
+ return -EINVAL;
+ sched_smt_power_savings = !!op->u.set_sched_opt_smt;
+ op->u.set_sched_opt_smt = saved_value;
+ return 0;
+ }
+
+ case XEN_SYSCTL_pm_op_get_max_cstate:
+ BUILD_BUG_ON(XEN_SYSCTL_CX_UNLIMITED != UINT_MAX);
+ if ( op->cpuid == 0 )
+ op->u.get_max_cstate = acpi_get_cstate_limit();
+ else if ( op->cpuid == 1 )
+ op->u.get_max_cstate = acpi_get_csubstate_limit();
+ else
+ ret = -EINVAL;
+ return ret;
+
+ case XEN_SYSCTL_pm_op_set_max_cstate:
+ if ( op->cpuid == 0 )
+ acpi_set_cstate_limit(op->u.set_max_cstate);
+ else if ( op->cpuid == 1 )
+ acpi_set_csubstate_limit(op->u.set_max_cstate);
+ else
+ ret = -EINVAL;
+ return ret;
+ }
+
+ if ( op->cpuid >= nr_cpu_ids || !cpu_online(op->cpuid) )
return -EINVAL;
pmpt = processor_pminfo[op->cpuid];
@@ -438,30 +471,6 @@ int do_pm_op(struct xen_sysctl_pm_op *op
break;
}
- case XEN_SYSCTL_pm_op_set_sched_opt_smt:
- {
- uint32_t saved_value;
-
- saved_value = sched_smt_power_savings;
- sched_smt_power_savings = !!op->u.set_sched_opt_smt;
- op->u.set_sched_opt_smt = saved_value;
-
- break;
- }
-
- case XEN_SYSCTL_pm_op_get_max_cstate:
- {
- BUILD_BUG_ON(XEN_SYSCTL_CX_UNLIMITED != UINT_MAX);
- op->u.get_max_cstate = acpi_get_cstate_limit();
- break;
- }
-
- case XEN_SYSCTL_pm_op_set_max_cstate:
- {
- acpi_set_cstate_limit(op->u.set_max_cstate);
- break;
- }
-
case XEN_SYSCTL_pm_op_enable_turbo:
{
ret = cpufreq_update_turbo(op->cpuid, CPUFREQ_TURBO_ENABLED);
--- a/xen/include/public/sysctl.h
+++ b/xen/include/public/sysctl.h
@@ -350,7 +350,11 @@ struct xen_sysctl_pm_op {
/* set/reset scheduler power saving option */
#define XEN_SYSCTL_pm_op_set_sched_opt_smt 0x21
- /* cpuidle max_cstate access command */
+ /*
+ * cpuidle max C-state and max C-sub-state access command:
+ * Set cpuid to 0 for max C-state.
+ * Set cpuid to 1 for max C-sub-state.
+ */
#define XEN_SYSCTL_pm_op_get_max_cstate 0x22
#define XEN_SYSCTL_pm_op_set_max_cstate 0x23
--- a/xen/include/xen/acpi.h
+++ b/xen/include/xen/acpi.h
@@ -166,9 +166,22 @@ static inline void acpi_set_cstate_limit
max_cstate = new_limit;
return;
}
+
+static inline unsigned int acpi_get_csubstate_limit(void)
+{
+ return max_csubstate;
+}
+
+static inline void acpi_set_csubstate_limit(unsigned int new_limit)
+{
+ max_csubstate = new_limit;
+}
+
#else
static inline unsigned int acpi_get_cstate_limit(void) { return 0; }
static inline void acpi_set_cstate_limit(unsigned int new_limit) { return; }
+static inline unsigned int acpi_get_csubstate_limit(void) { return 0; }
+static inline void acpi_set_csubstate_limit(unsigned int new_limit) { return; }
#endif
#ifdef XEN_GUEST_HANDLE_PARAM
_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xenproject.org
https://lists.xenproject.org/mailman/listinfo/xen-devel
next prev parent reply other threads:[~2019-05-23 12:19 UTC|newest]
Thread overview: 30+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-05-23 12:06 [PATCH 0/5] x86: CPU idle management adjustments Jan Beulich
2019-05-23 12:06 ` [Xen-devel] " Jan Beulich
2019-05-23 12:16 ` [PATCH 1/5] x86/cpuidle: switch to uniform meaning of "max_cstate=" Jan Beulich
2019-05-23 12:16 ` [Xen-devel] " Jan Beulich
2019-06-10 15:48 ` Andrew Cooper
2019-06-11 12:13 ` Jan Beulich
2019-05-23 12:17 ` [PATCH 2/5] x86/cpuidle: really use C1 for "urgent" CPUs Jan Beulich
2019-05-23 12:17 ` [Xen-devel] " Jan Beulich
2019-06-10 15:50 ` Andrew Cooper
2019-05-23 12:18 ` [PATCH 3/5] x86/AMD: make C-state handling independent of Dom0 Jan Beulich
2019-05-23 12:18 ` [Xen-devel] " Jan Beulich
2019-06-10 16:28 ` Andrew Cooper
2019-06-11 12:42 ` Jan Beulich
2019-06-18 17:22 ` Woods, Brian
2019-06-19 6:20 ` Jan Beulich
2019-06-19 15:54 ` Woods, Brian
2019-06-21 6:37 ` Jan Beulich
2019-06-21 14:29 ` Woods, Brian
2019-06-21 14:56 ` Jan Beulich
2019-06-21 15:26 ` Woods, Brian
2019-05-23 12:18 ` [PATCH 4/5] x86: allow limiting the max C-state sub-state Jan Beulich
2019-05-23 12:18 ` [Xen-devel] " Jan Beulich
2019-06-10 16:43 ` Andrew Cooper
2019-06-11 12:46 ` Jan Beulich
2019-05-23 12:19 ` Jan Beulich [this message]
2019-05-23 12:19 ` [Xen-devel] [PATCH 5/5] tools/libxc: allow controlling " Jan Beulich
2019-05-24 14:00 ` Wei Liu
2019-05-24 14:00 ` [Xen-devel] " Wei Liu
2019-06-10 16:54 ` Andrew Cooper
2019-06-11 12:50 ` 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=5CE68FDB0200007800231B41@prv1-mh.provo.novell.com \
--to=jbeulich@suse.com \
--cc=Ian.Jackson@eu.citrix.com \
--cc=andrew.cooper3@citrix.com \
--cc=roger.pau@citrix.com \
--cc=wei.liu2@citrix.com \
--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).