|
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [Xen-devel] [PATCH v3 2/3] tools/libxc: Alow controlling the max C-state sub-state
Signed-off-by: Ross Lagerwall <ross.lagerwall@xxxxxxxxxx>
CC: Ian Jackson <ian.jackson@xxxxxxxxxxxxx>
CC: Stefano Stabellini <stefano.stabellini@xxxxxxxxxxxxx>
CC: Ian Campbell <ian.campbell@xxxxxxxxxx>
---
tools/libxc/xc_pm.c | 28 ++++++++++++++++++++++++----
tools/libxc/xenctrl.h | 3 +++
xen/drivers/acpi/pmstat.c | 20 ++++++++++++++++----
xen/include/public/sysctl.h | 5 ++++-
xen/include/xen/acpi.h | 13 +++++++++++++
5 files changed, 60 insertions(+), 9 deletions(-)
diff --git a/tools/libxc/xc_pm.c b/tools/libxc/xc_pm.c
index e4e0fb9..9631d99 100644
--- a/tools/libxc/xc_pm.c
+++ b/tools/libxc/xc_pm.c
@@ -386,7 +386,7 @@ int xc_get_vcpu_migration_delay(xc_interface *xch, uint32_t
*value)
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;
@@ -396,7 +396,7 @@ int xc_get_cpuidle_max_cstate(xc_interface *xch, uint32_t
*value)
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;
@@ -404,7 +404,17 @@ int xc_get_cpuidle_max_cstate(xc_interface *xch, uint32_t
*value)
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;
@@ -413,12 +423,22 @@ int xc_set_cpuidle_max_cstate(xc_interface *xch, uint32_t
value)
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;
diff --git a/tools/libxc/xenctrl.h b/tools/libxc/xenctrl.h
index b55d857..a4856a2 100644
--- a/tools/libxc/xenctrl.h
+++ b/tools/libxc/xenctrl.h
@@ -2159,6 +2159,9 @@ int xc_get_vcpu_migration_delay(xc_interface *xch,
uint32_t *value);
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);
/**
diff --git a/xen/drivers/acpi/pmstat.c b/xen/drivers/acpi/pmstat.c
index daac2da..cd74835 100644
--- a/xen/drivers/acpi/pmstat.c
+++ b/xen/drivers/acpi/pmstat.c
@@ -400,15 +400,17 @@ 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) )
+ if ( !op || (op->cmd != XEN_SYSCTL_pm_op_get_max_cstate &&
+ op->cmd != XEN_SYSCTL_pm_op_set_max_cstate &&
+ (op->cpuid >= nr_cpu_ids || !cpu_online(op->cpuid))) )
return -EINVAL;
- pmpt = processor_pminfo[op->cpuid];
switch ( op->cmd & PM_PARA_CATEGORY_MASK )
{
case CPUFREQ_PARA:
if ( !(xen_processor_pmbits & XEN_PROCESSOR_PM_PX) )
return -ENODEV;
+ pmpt = processor_pminfo[op->cpuid];
if ( !pmpt || !(pmpt->perf.init & XEN_PX_INIT) )
return -EINVAL;
break;
@@ -465,13 +467,23 @@ int do_pm_op(struct xen_sysctl_pm_op *op)
case XEN_SYSCTL_pm_op_get_max_cstate:
{
- op->u.get_max_cstate = acpi_get_cstate_limit();
+ 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;
break;
}
case XEN_SYSCTL_pm_op_set_max_cstate:
{
- acpi_set_cstate_limit(op->u.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;
break;
}
diff --git a/xen/include/public/sysctl.h b/xen/include/public/sysctl.h
index 3588698..77f820b 100644
--- a/xen/include/public/sysctl.h
+++ b/xen/include/public/sysctl.h
@@ -354,7 +354,10 @@ 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_cstate and max_csubstate access command
+ * Set cpuid to 0 for max_cstate.
+ * Set cpuid to 1 for max_csubstate.
+ */
#define XEN_SYSCTL_pm_op_get_max_cstate 0x22
#define XEN_SYSCTL_pm_op_set_max_cstate 0x23
diff --git a/xen/include/xen/acpi.h b/xen/include/xen/acpi.h
index 331dc8d..2724fd0 100644
--- a/xen/include/xen/acpi.h
+++ b/xen/include/xen/acpi.h
@@ -149,9 +149,22 @@ static inline void acpi_set_cstate_limit(unsigned int
new_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
--
1.9.3
_______________________________________________
Xen-devel mailing list
Xen-devel@xxxxxxxxxxxxx
http://lists.xen.org/xen-devel
|
![]() |
Lists.xenproject.org is hosted with RackSpace, monitoring our |