diff options
author | kfraser@localhost.localdomain <kfraser@localhost.localdomain> | 2007-07-06 16:12:07 +0100 |
---|---|---|
committer | kfraser@localhost.localdomain <kfraser@localhost.localdomain> | 2007-07-06 16:12:07 +0100 |
commit | be259653f3f1713426ddea9436bffe998b54ae78 (patch) | |
tree | b5b6c1867d9e9b04d0ecb13655ea41dcb6ecf68f /xen/arch/x86/sysctl.c | |
parent | 8d374ca1d1c9c2c454503d70bbc66fd8f219f71f (diff) | |
download | xen-be259653f3f1713426ddea9436bffe998b54ae78.tar.gz xen-be259653f3f1713426ddea9436bffe998b54ae78.tar.bz2 xen-be259653f3f1713426ddea9436bffe998b54ae78.zip |
Extended the physinfo sysctl to export NUMA cpu_to_node topology info.
Print this in 'xm info'.
Signed-off-by: Ryan Harper <ryanh@us.ibm.com>
Signed-off-by: Keir Fraser <keir@xensource.com>
Diffstat (limited to 'xen/arch/x86/sysctl.c')
-rw-r--r-- | xen/arch/x86/sysctl.c | 32 |
1 files changed, 26 insertions, 6 deletions
diff --git a/xen/arch/x86/sysctl.c b/xen/arch/x86/sysctl.c index fe4c049908..ff7018a930 100644 --- a/xen/arch/x86/sysctl.c +++ b/xen/arch/x86/sysctl.c @@ -23,6 +23,10 @@ #include <asm/hvm/hvm.h> #include <asm/hvm/support.h> #include <asm/processor.h> +#include <asm/numa.h> +#include <xen/nodemask.h> + +#define get_xen_guest_handle(val, hnd) do { val = (hnd).p; } while (0) long arch_do_sysctl( struct xen_sysctl *sysctl, XEN_GUEST_HANDLE(xen_sysctl_t) u_sysctl) @@ -34,25 +38,41 @@ long arch_do_sysctl( case XEN_SYSCTL_physinfo: { + uint32_t i, max_array_ent; + xen_sysctl_physinfo_t *pi = &sysctl->u.physinfo; pi->threads_per_core = cpus_weight(cpu_sibling_map[0]); pi->cores_per_socket = cpus_weight(cpu_core_map[0]) / pi->threads_per_core; - pi->sockets_per_node = - num_online_cpus() / cpus_weight(cpu_core_map[0]); + pi->nr_nodes = num_online_nodes(); + pi->sockets_per_node = num_online_cpus() / + (pi->nr_nodes * pi->cores_per_socket * pi->threads_per_core); - pi->nr_nodes = 1; pi->total_pages = total_pages; pi->free_pages = avail_domheap_pages(); pi->scrub_pages = avail_scrub_pages(); pi->cpu_khz = cpu_khz; memset(pi->hw_cap, 0, sizeof(pi->hw_cap)); memcpy(pi->hw_cap, boot_cpu_data.x86_capability, NCAPINTS*4); - ret = 0; - if ( copy_to_guest(u_sysctl, sysctl, 1) ) - ret = -EFAULT; + + max_array_ent = pi->max_cpu_id; + pi->max_cpu_id = last_cpu(cpu_online_map); + max_array_ent = min_t(uint32_t, max_array_ent, pi->max_cpu_id); + + ret = -EFAULT; + if ( !guest_handle_is_null(pi->cpu_to_node) ) + { + for ( i = 0; i <= max_array_ent; i++ ) + { + uint32_t node = cpu_online(i) ? cpu_to_node(i) : ~0u; + if ( copy_to_guest_offset(pi->cpu_to_node, i, &node, 1) ) + break; + } + } + + ret = copy_to_guest(u_sysctl, sysctl, 1) ? -EFAULT : 0; } break; |