[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Xen-devel] [PATCH 2/2] xenpm: add cmd set-max-cstate


  • To: xen-devel <xen-devel@xxxxxxxxxxxxxxxxxxx>
  • From: "Wei, Gang" <gang.wei@xxxxxxxxx>
  • Date: Tue, 24 Mar 2009 17:51:30 +0800
  • Accept-language: en-US
  • Acceptlanguage: en-US
  • Delivery-date: Tue, 24 Mar 2009 02:52:14 -0700
  • List-id: Xen developer discussion <xen-devel.lists.xensource.com>
  • Thread-index: AcmsZhu538olEH8sSimt/oQR+86K8A==
  • Thread-topic: [PATCH 2/2] xenpm: add cmd set-max-cstate

xenpm: add cmd set-max-cstate

signed-off-by: Wei Gang <gang.wei@xxxxxxxxx>

diff -r 09648ca5525e tools/misc/xenpm.c
--- a/tools/misc/xenpm.c        Tue Mar 24 16:16:04 2009 +0800
+++ b/tools/misc/xenpm.c        Tue Mar 24 16:38:51 2009 +0800
@@ -57,6 +57,7 @@ void show_help(void)
             "                                     it is used in ondemand 
governor.\n"
             " get-cpu-topology                    get thread/core/socket 
topology info\n"
             " set-sched-smt           enable|disable enable/disable scheduler 
smt power saving\n"
+            " set-max-cstate        <num>         set the C-State limitation 
(<num> >= 0)\n"
             " start [seconds]                     start collect Cx/Px 
statistics,\n"
             "                                     output after CTRL-C or 
SIGINT or several seconds.\n"
             );
@@ -122,6 +123,18 @@ static int get_cxstat_by_cpuid(int xc_fd
     return 0;
 }
 
+static int show_max_cstate(int xc_fd)
+{
+    int ret = 0;
+    uint32_t value;
+
+    if ( (ret = xc_get_cpuidle_max_cstate(xc_fd, &value)) )
+        return ret;
+
+    printf("Max C-state: C%d\n\n", value);
+    return 0;
+}
+
 static int show_cxstat_by_cpuid(int xc_fd, int cpuid)
 {
     int ret = 0;
@@ -147,6 +160,8 @@ void cxstat_func(int argc, char *argv[])
 
     if ( cpuid >= max_cpu_nr )
         cpuid = -1;
+
+    show_max_cstate(xc_fd);
 
     if ( cpuid < 0 )
     {
@@ -864,7 +879,24 @@ void set_sched_smt_func(int argc, char *
 
     rc = xc_set_sched_opt_smt(xc_fd, value);
     printf("%s sched_smt_power_savings %s\n", argv[0],
-                    rc? "failed":"successeed" );
+                    rc? "failed":"succeeded" );
+
+    return;
+}
+
+void set_max_cstate_func(int argc, char *argv[])
+{
+    int value, rc;
+
+    if ( argc != 1 || sscanf(argv[0], "%d", &value) != 1 || value < 0 )
+    {
+        show_help();
+        exit(-1);
+    }
+
+    rc = xc_set_cpuidle_max_cstate(xc_fd, (uint32_t)value);
+    printf("set max_cstate to C%d %s\n", value,
+                    rc? "failed":"succeeded" );
 
     return;
 }
@@ -886,6 +918,7 @@ struct {
     { "set-up-threshold", scaling_up_threshold_func },
     { "get-cpu-topology", cpu_topology_func},
     { "set-sched-smt", set_sched_smt_func},
+    { "set-max-cstate", set_max_cstate_func},
 };
 
 int main(int argc, char *argv[])

Attachment: xenpm-set-max_cstate.patch
Description: xenpm-set-max_cstate.patch

_______________________________________________
Xen-devel mailing list
Xen-devel@xxxxxxxxxxxxxxxxxxx
http://lists.xensource.com/xen-devel

 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.