New command: xm pcpu-list
RFC PATCH 1/1 New command: xm pcpu-list
Hi all,
I would push a new command "xm pcpu-list" that reports physical CPU configuration.
I suppose that Xen works on a machine where a lot of physical CPUs are installed. It is useful for users to know the configuration of physical CPUs so that they can allocate VCPUs efficiently. This command offers the means for it.
I began this patch with ia64 machines. It is just because I have one.
I would like to make this command work on x86 and powerpc machines. Unfortunately, I don't have any with dual-core and multi-thread features. I don't have much information on them either. I would appreciate if you give any help to make the command work on x86 and powerpc.
Best regards,
Kan
cf.
# xm pcpu-list PCPU Node Socket Core Thread State 0 0 0x001802 0 0 online 1 0 0x001803 0 0 online 2 0 0x001800 1 0 online 3 0 0x001801 1 0 online 4 0 0x001802 1 0 online 5 0 0x001803 1 0 online 6 0 0x001800 0 1 online 7 0 0x001801 0 1 online 8 0 0x001802 0 1 online 9 0 0x001803 0 1 online 10 0 0x001800 1 1 online 11 0 0x001801 1 1 online 12 0 0x001802 1 1 online 13 0 0x001803 1 1 online 14 0 0x001800 0 0 online 15 0 0x001801 0 0 online # xm info host : tiger154 release : 2.6.16.13-xen version : #1 SMP Fri Sep 22 11:28:14 JST 2006 machine : ia64 nr_cpus : 16 nr_nodes : 1 sockets_per_node : 4 cores_per_socket : 2 threads_per_core : 2 cpu_mhz : 1595 hw_caps : 00000000:00000000:00000000:00000000:00000000:00000000:00000000:00000000: total_memory : 8166 free_memory : 7586 xen_major : 3 xen_minor : 0 xen_extra : -unstable xen_caps : xen-3.0-ia64 hvm-3.0-ia64 xen_pagesize : 16384 platform_params : virt_start=0xe800000000000000 xen_changeset : Thu Sep 21 15:35:45 2006 -0600 11460: da942e577e5e cc_compiler : gcc version 3.4.4 20050721 (Red Hat 3.4.4-2) cc_compile_by : root cc_compile_domain : cc_compile_date : Fri Sep 22 11:23:42 JST 2006 xend_config_format : 2
tools/libxc/xc_misc.c +18 -0
@@ -44,6 +44,24 @@ int xc_physinfo(int xc_handle,return ret;memcpy (put_info, &sysctl.u.physinfo,sizeof (*put_info)); + +return 0 ; +} + +int xc_pcpuinfo (int xc_handle, +int pcpu_num, +xc_pcpuinfo_t *put_info) +{ +int ret; +DECLARE_SYSCTL ; + + sysctl.cmd = XEN_SYSCTL_pcpuinfo; + sysctl.u.pcpuinfo.pcpu_num = pcpu_num; + +if ( (ret =do_sysctl (xc_handle, &sysctl)) !=0 ) +return ret; + +memcpy (put_info, &sysctl.u.pcpuinfo,sizeof (*put_info));return 0 ; }
tools/libxc/xenctrl.h +5 -0
@@ -390,6 +390,11 @@ int xc_physinfo(int xc_handle,int xc_physinfo (int xc_handle,xc_physinfo_t *info); +typedef xen_sysctl_pcpuinfo_t xc_pcpuinfo_t ; +int xc_pcpuinfo (int xc_handle, +int pcpu_num, +xc_pcpuinfo_t *info); +int xc_sched_id (int xc_handle,int *sched_id);
tools/python/xen/lowlevel/xc/xc.c +27 -0
@@ -549,6 +549,25 @@ static PyObject *pyxc_xeninfo(XcObject * "cc_compile_date", xen_cc.compile_date); } +static PyObject *pyxc_pcpuinfo (XcObject *self,PyObject *args) +{ +uint32_t pcpu_num; +xc_pcpuinfo_t info; + +if (!PyArg_ParseTuple (args,"i" , &pcpu_num)) +return NULL ; + +if (xc_pcpuinfo (self->xc_handle, pcpu_num, &info) !=0 ) +return PyErr_SetFromErrno (xc_error); + +return Py_BuildValue ("{s:i,s:i,s:i,s:i,s:i}" , +"node" , info.node_num, +"socket" , info.socket_num, +"core" , info.core_num, +"thread" , info.thread_num, +"state" , info.state); +} + static PyObject *pyxc_sedf_domain_set(XcObject *self, PyObject *args,
@@ -1056,6 +1075,14 @@ static PyMethodDef pyxc_methods[] = {METH_NOARGS ,"\n" "Get information about the Xen host\n" "Returns [dict]: information about Xen" + " [None]: on failure.\n" }, + + { "pcpuinfo", + (PyCFunction )pyxc_pcpuinfo, +METH_VARARGS ,"\n" +"Get information about the physical CPU\n" +" pcpu_num [int]: physical CPU number to get\n" +"Returns [dict]: information about the physical CPU" " [None]: on failure.\n" }, { "shadow_control",
tools/python/xen/xend/XendNode.py +12 -0
@@ -98,6 +98,18 @@ class XendNode: def xendinfo(self): return [['xend_config_format', 2]] + def cpuinfo(self, pcpu): + info = self.xc.pcpuinfo(pcpu) + + ITEM_ORDER = ['node', + 'socket', + 'core', + 'thread', + 'state', + ] + + return [[k, info[k]] for k in ITEM_ORDER] + def instance(): global inst
tools/python/xen/xend/server/XMLRPCServer.py +1 -1
@@ -110,7 +110,7 @@ class XMLRPCServer: self.server.register_function(fn, "xend.domain.%s" % name[7:]) # Functions in XendNode and XendDmesg - for type, lst, n in [(XendNode, ['info'], 'node'), + for type, lst, n in [(XendNode, ['info', 'cpuinfo'], 'node'), (XendDmesg, ['info', 'clear'], 'node.dmesg')]: inst = type.instance() for name in lst:
tools/python/xen/xm/main.py +31 -0
@@ -85,6 +85,7 @@ vcpu_set_help = """vcpu-set <DomId> <VCP configuration""" vcpu_list_help = "vcpu-list <DomId> List the VCPUs for a domain (or all domains)" vcpu_pin_help = "vcpu-pin <DomId> <VCPU> <CPUs> Set which cpus a VCPU can use" +pcpu_list_help = "pcpu-list List the PCPUs" dmesg_help = "dmesg [-c|--clear] Read or clear Xen's message buffer" info_help = "info Get information about the xen host" rename_help = "rename <DomId> <New Name> Rename a domain"
@@ -184,6 +185,7 @@ host_commands = [ "info", "log", "serve", + "pcpu-list", ] scheduler_commands = [
@@ -921,6 +923,34 @@ def xm_serve(args): else: break s.close() + +def xm_pcpu_list(args): + arg_check(args, "pcpu-list", 0) + + info = server.xend.node.info() + nr_cpus = int(sxp.child_value(info, 'nr_cpus')) + + print 'PCPU Node Socket Core Thread State' + + for pcpu in range(nr_cpus): + def pinfo(n, t): + return t(sxp.child_value(cpuinfo, n)) + + cpuinfo = [pcpu] + server.xend.node.cpuinfo(pcpu) + + node = pinfo('node', int) + socket = pinfo('socket', int) + core = pinfo('core', int) + thread = pinfo('thread', int) + if pinfo('state', int): + state = 'online' + else: + state = 'offline' + + print ( + " %(pcpu)3d %(node)2d 0x%(socket)06x %(core)2d %(thread)2d %(state)-10s" % + locals()) + def parse_dev_info(info): def get_info(n, t, d):
@@ -1190,6 +1220,7 @@ commands = { "info": xm_info, "log": xm_log, "serve": xm_serve, + "pcpu-list": xm_pcpu_list, # scheduler "sched-sedf": xm_sched_sedf, "sched-credit": xm_sched_credit,
xen/arch/ia64/xen/dom0_ops.c +15 -0
@@ -210,6 +210,21 @@ long arch_do_sysctl(xen_sysctl_t *op, XE }break ; +case XEN_SYSCTL_pcpuinfo: + { +xen_sysctl_pcpuinfo_t *pi = &op->u.pcpuinfo; + + pi->node_num =0 ; + pi->socket_num =cpu_data (pi->pcpu_num)->socket_id; + pi->core_num =cpu_data (pi->pcpu_num)->core_id; + pi->thread_num =cpu_data (pi->pcpu_num)->thread_id; + pi->state =cpu_isset (pi->pcpu_num, cpu_online_map); + ret =0 ; +if (copy_to_guest (u_sysctl, op,1 ) ) + ret = -EFAULT ; + } +break ; +default :printf ("arch_do_sysctl: unrecognized sysctl: %d!!!\n" ,op->cmd); ret = -ENOSYS ;
xen/include/public/sysctl.h +18 -0
@@ -122,6 +122,23 @@ typedef struct xen_sysctl_getdomaininfoltypedef struct xen_sysctl_getdomaininfolist xen_sysctl_getdomaininfolist_t ;DEFINE_XEN_GUEST_HANDLE (xen_sysctl_getdomaininfolist_t); +/* +* Get physical CPU information +*/ +#define XEN_SYSCTL_pcpuinfo 7 +struct xen_sysctl_pcpuinfo { +/* IN variables. */ +uint32_t pcpu_num; +/* OUT variables. */ +uint32_t node_num; +uint32_t socket_num; +uint32_t core_num; +uint32_t thread_num; +uint32_t state; +}; +typedef struct xen_sysctl_pcpuinfo xen_sysctl_pcpuinfo_t ; +DEFINE_XEN_GUEST_HANDLE (xen_sysctl_pcpuinfo_t); +struct xen_sysctl {uint32_t cmd;uint32_t interface_version;/* XEN_SYSCTL_INTERFACE_VERSION */
@@ -132,6 +149,7 @@ struct xen_sysctl {struct xen_sysctl_sched_id sched_id;struct xen_sysctl_perfc_op perfc_op;struct xen_sysctl_getdomaininfolist getdomaininfolist; +struct xen_sysctl_pcpuinfo pcpuinfo;uint8_t pad[128 ]; } u; };
_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xensource.com/xen-devel
Quoted 7 lines
I would push a new command "xm pcpu-list" that reports physical CPU configuration.
I suppose that Xen works on a machine where a lot of physical CPUs are installed. It is useful for users to know the configuration of physical CPUs so that they can allocate VCPUs efficiently. This command offers the means for it.
Quoted 8 lines
I began this patch with ia64 machines. It is just because I have one.
I would like to make this command work on x86 and powerpc machines. Unfortunately, I don't have any with dual-core and multi-thread features. I don't have much information on them either. I would appreciate if you give any help to make the command work on x86 and powerpc.
The example you give below is a truly bizarre enumeration of CPUs. X86 does effectively enumerates [nodes][sockets][cores][threads] (in C terminology), hence on a hyperthreaded system PCPU 0 and 1 are in the same core.
I think it would be good if ia64 followed suit.
There was some discussion ages back about making it such that the tools would interpret hierarchical PCPU 'addressing' rather than just the PCPU number, i.e. you could refer to CPU 1.2.1.0 for the first hyperthread on the second core of the third socket of the second node.
For systems that missed levels of the hierarchy e.g. single node, or no hyperthreads, the hierarchy could be collapsed in the obvious way.
I'd still like to see this implemented.
pcpu-list would then be less necessary, but you'd still want something like it to see which CPUs are online once we start to do physical CPU hotplug.
Thanks,
Ian
Quoted 27 lines
Best regards,
Kancf.
# xm pcpu-list PCPU Node Socket Core Thread State 0 0 0x001802 0 0 online 1 0 0x001803 0 0 online 2 0 0x001800 1 0 online 3 0 0x001801 1 0 online 4 0 0x001802 1 0 online 5 0 0x001803 1 0 online 6 0 0x001800 0 1 online 7 0 0x001801 0 1 online 8 0 0x001802 0 1 online 9 0 0x001803 0 1 online 10 0 0x001800 1 1 online 11 0 0x001801 1 1 online 12 0 0x001802 1 1 online 13 0 0x001803 1 1 online 14 0 0x001800 0 0 online 15 0 0x001801 0 0 online # xm info host : tiger154 release : 2.6.16.13-xen version : #1 SMP Fri Sep 22 11:28:14 JST 2006
Quoted 9 lines
machine : ia64 nr_cpus : 16 nr_nodes : 1 sockets_per_node : 4 cores_per_socket : 2 threads_per_core : 2 cpu_mhz : 1595 hw_caps :
00000000:00000000:00000000:00000000:00000000:00000000:00000000:00000000:
Quoted 15 lines
total_memory: 8166free_memory: 7586xen_major: 3xen_minor: 0xen_extra: -unstablexen_caps: xen-3.0-ia64 hvm-3.0-ia64xen_pagesize: 16384platform_params: virt_start=0xe800000000000000xen_changeset: Thu Sep 21 15:35:45 2006 -0600 11460:da942e577e5ecc_compiler: gcc version 3.4.4 20050721 (Red Hat 3.4.4-2)cc_compile_by: rootcc_compile_domain : cc_compile_date : Fri Sep 22 11:23:42 JST 2006 xend_config_format : 2
On Friday 22 September 2006 07:56, Ian Pratt wrote:
<snip>
Quoted 6 lines
The example you give below is a truly bizarre enumeration of CPUs. X86 does effectively enumerates [nodes][sockets][cores][threads] (in C terminology), hence on a hyperthreaded system PCPU 0 and 1 are in the same core.
<snip>
Not all X86 machines work this way. For Linux, it depends on the order in which the processors appear in the SRAT table (or MP table?), as I recall,
and I imagine the same is true for Xen. Most system manufacturers write the
BIOS so that the processor ordering is as you describe. That is logical
processors 0 and 1 are both on socket 0, 2 and 3 are on socket 1, etc. However, we have encountered BIOS's for AMD procesors which this numbering is done with logical 0 and 1 being core 0 on socket 0 and 1, respectively. The numbering continues this way, until all sockets have been enumerated, then (in a 4-socket system), logical processor 4 is core 1 on socket 0, 5 is
core 1 on socket 1, etc. The apparent rationale for this is that IF you
decide to boot the system with only 4 processors, then you get one active core on each socket.
(Here logical processor number is the number that smp_processor_id() returns.)
<snip>
Signature · 3 lines
Ray Bryant AMD Performance Labs Austin, Tx 512-602-0038 (o) 512-507-7807 (c)