diff options
author | Keir Fraser <keir.fraser@citrix.com> | 2009-03-13 10:09:25 +0000 |
---|---|---|
committer | Keir Fraser <keir.fraser@citrix.com> | 2009-03-13 10:09:25 +0000 |
commit | 550686e4fdd5234b21def5fcbd474e97f3bb4409 (patch) | |
tree | 5f798791b77246d1d713864b057eb4b8200d3b50 /tools/misc/xenpm.c | |
parent | 8eaca58a104bf6a79202373d07d835a40268181e (diff) | |
download | xen-550686e4fdd5234b21def5fcbd474e97f3bb4409.tar.gz xen-550686e4fdd5234b21def5fcbd474e97f3bb4409.tar.bz2 xen-550686e4fdd5234b21def5fcbd474e97f3bb4409.zip |
xenpm: Add CPU topology info (thread/core/socket)
CPU topology info is necessary for power management analysis. For
example, to analysis the effect of Px state coordination, Cx
package/core coordination, the thread/core/socket topology
information is needed.
This patch add new command "get-cpu-topology" in xenpm to print the
CPU topology info:
Signed-off-by: Yu Ke <ke.yu@intel.com>
Diffstat (limited to 'tools/misc/xenpm.c')
-rw-r--r-- | tools/misc/xenpm.c | 36 |
1 files changed, 36 insertions, 0 deletions
diff --git a/tools/misc/xenpm.c b/tools/misc/xenpm.c index 2cc864cff1..08e26695f9 100644 --- a/tools/misc/xenpm.c +++ b/tools/misc/xenpm.c @@ -58,6 +58,7 @@ void show_help(void) " it is used in ondemand governor.\n" " set-up-threshold [cpuid] <num> set up threshold on CPU <cpuid> or all\n" " it is used in ondemand governor.\n" + " get-cpu-topology get thread/core/socket topology info\n" " start start collect Cx/Px statistics,\n" " output after CTRL-C or SIGINT.\n" ); @@ -750,6 +751,40 @@ out: fprintf(stderr, "failed to set governor name\n"); } +#define MAX_NR_CPU 512 + +void cpu_topology_func(int argc, char *argv[]) +{ + uint32_t cpu_to_core[MAX_NR_CPU]; + uint32_t cpu_to_socket[MAX_NR_CPU]; + struct xc_get_cputopo info; + int i, ret; + + info.cpu_to_core = cpu_to_core; + info.cpu_to_socket = cpu_to_socket; + info.max_cpus = MAX_NR_CPU; + ret = xc_get_cputopo(xc_fd, &info); + if (!ret) + { + printf("CPU\tcore\tsocket\n"); + for (i=0; i<info.nr_cpus; i++) + { + if ( info.cpu_to_core[i] != INVALID_TOPOLOGY_ID && + info.cpu_to_socket[i] != INVALID_TOPOLOGY_ID ) + { + printf("CPU%d\t %d\t %d\n", i, info.cpu_to_core[i], + info.cpu_to_socket[i]); + } + } + } + else + { + printf("Can not get Xen CPU topology!\n"); + } + + return ; +} + struct { const char *name; void (*function)(int argc, char *argv[]); @@ -765,6 +800,7 @@ struct { { "set-scaling-speed", scaling_speed_func }, { "set-sampling-rate", scaling_sampling_rate_func }, { "set-up-threshold", scaling_up_threshold_func }, + { "get-cpu-topology", cpu_topology_func}, }; int main(int argc, char *argv[]) |