diff options
author | Keir Fraser <keir.fraser@citrix.com> | 2010-04-13 09:38:54 +0100 |
---|---|---|
committer | Keir Fraser <keir.fraser@citrix.com> | 2010-04-13 09:38:54 +0100 |
commit | 645f5ea7cb3dcc23c00f9ed603055af25bc5257b (patch) | |
tree | 4e132619f627bb6462308d995b74c7c4e3db495f /tools/misc | |
parent | 81f77532b58c0601b81d823ecef11172ff9b968f (diff) | |
download | xen-645f5ea7cb3dcc23c00f9ed603055af25bc5257b.tar.gz xen-645f5ea7cb3dcc23c00f9ed603055af25bc5257b.tar.bz2 xen-645f5ea7cb3dcc23c00f9ed603055af25bc5257b.zip |
Topology-info sysctl cleanups.
Signed-off-by: Keir Fraser <keir.fraser@citrix.com>
Diffstat (limited to 'tools/misc')
-rw-r--r-- | tools/misc/xenpm.c | 44 |
1 files changed, 22 insertions, 22 deletions
diff --git a/tools/misc/xenpm.c b/tools/misc/xenpm.c index e168659200..19a6e2f2ba 100644 --- a/tools/misc/xenpm.c +++ b/tools/misc/xenpm.c @@ -842,32 +842,32 @@ 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) + uint32_t cpu_to_node[MAX_NR_CPU]; + xc_topologyinfo_t info = { 0 }; + int i; + + set_xen_guest_handle(info.cpu_to_core, cpu_to_core); + set_xen_guest_handle(info.cpu_to_socket, cpu_to_socket); + set_xen_guest_handle(info.cpu_to_node, cpu_to_node); + info.max_cpu_index = MAX_NR_CPU-1; + + if ( xc_topologyinfo(xc_fd, &info) ) { - 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]); - } - } + printf("Can not get Xen CPU topology: %d\n", errno); + return; } - else + + if ( info.max_cpu_index > (MAX_NR_CPU-1) ) + info.max_cpu_index = MAX_NR_CPU-1; + + printf("CPU\tcore\tsocket\tnode\n"); + for ( i = 0; i < info.max_cpu_index; i++ ) { - printf("Can not get Xen CPU topology!\n"); + if ( cpu_to_core[i] == INVALID_TOPOLOGY_ID ) + continue; + printf("CPU%d\t %d\t %d\t %d\n", + i, cpu_to_core[i], cpu_to_socket[i], cpu_to_node[i]); } - - return ; } void set_sched_smt_func(int argc, char *argv[]) |