ia64/xen-unstable
changeset 19442:687376c92188
xenpm: add cmd set-max-cstate
Signed-off-by: Wei Gang <gang.wei@intel.com>
Signed-off-by: Wei Gang <gang.wei@intel.com>
author | Keir Fraser <keir.fraser@citrix.com> |
---|---|
date | Tue Mar 31 11:19:56 2009 +0100 (2009-03-31) |
parents | fa8dc6e43ec8 |
children | b8d2f08f98d0 |
files | tools/misc/xenpm.c |
line diff
1.1 --- a/tools/misc/xenpm.c Tue Mar 31 11:19:26 2009 +0100 1.2 +++ b/tools/misc/xenpm.c Tue Mar 31 11:19:56 2009 +0100 1.3 @@ -57,6 +57,7 @@ void show_help(void) 1.4 " it is used in ondemand governor.\n" 1.5 " get-cpu-topology get thread/core/socket topology info\n" 1.6 " set-sched-smt enable|disable enable/disable scheduler smt power saving\n" 1.7 + " set-max-cstate <num> set the C-State limitation (<num> >= 0)\n" 1.8 " start [seconds] start collect Cx/Px statistics,\n" 1.9 " output after CTRL-C or SIGINT or several seconds.\n" 1.10 ); 1.11 @@ -122,6 +123,18 @@ static int get_cxstat_by_cpuid(int xc_fd 1.12 return 0; 1.13 } 1.14 1.15 +static int show_max_cstate(int xc_fd) 1.16 +{ 1.17 + int ret = 0; 1.18 + uint32_t value; 1.19 + 1.20 + if ( (ret = xc_get_cpuidle_max_cstate(xc_fd, &value)) ) 1.21 + return ret; 1.22 + 1.23 + printf("Max C-state: C%d\n\n", value); 1.24 + return 0; 1.25 +} 1.26 + 1.27 static int show_cxstat_by_cpuid(int xc_fd, int cpuid) 1.28 { 1.29 int ret = 0; 1.30 @@ -148,6 +161,8 @@ void cxstat_func(int argc, char *argv[]) 1.31 if ( cpuid >= max_cpu_nr ) 1.32 cpuid = -1; 1.33 1.34 + show_max_cstate(xc_fd); 1.35 + 1.36 if ( cpuid < 0 ) 1.37 { 1.38 /* show cxstates on all cpus */ 1.39 @@ -864,7 +879,24 @@ void set_sched_smt_func(int argc, char * 1.40 1.41 rc = xc_set_sched_opt_smt(xc_fd, value); 1.42 printf("%s sched_smt_power_savings %s\n", argv[0], 1.43 - rc? "failed":"successeed" ); 1.44 + rc? "failed":"succeeded" ); 1.45 + 1.46 + return; 1.47 +} 1.48 + 1.49 +void set_max_cstate_func(int argc, char *argv[]) 1.50 +{ 1.51 + int value, rc; 1.52 + 1.53 + if ( argc != 1 || sscanf(argv[0], "%d", &value) != 1 || value < 0 ) 1.54 + { 1.55 + show_help(); 1.56 + exit(-1); 1.57 + } 1.58 + 1.59 + rc = xc_set_cpuidle_max_cstate(xc_fd, (uint32_t)value); 1.60 + printf("set max_cstate to C%d %s\n", value, 1.61 + rc? "failed":"succeeded" ); 1.62 1.63 return; 1.64 } 1.65 @@ -886,6 +918,7 @@ struct { 1.66 { "set-up-threshold", scaling_up_threshold_func }, 1.67 { "get-cpu-topology", cpu_topology_func}, 1.68 { "set-sched-smt", set_sched_smt_func}, 1.69 + { "set-max-cstate", set_max_cstate_func}, 1.70 }; 1.71 1.72 int main(int argc, char *argv[])