Display IO topology when PXM data is available
cover Display IO topology when PXM data is available
4 patches that add interface for querying hypervisor about device topology and allow 'xl info -n' display this information if PXM object is provided by ACPI.
The patches are:
* Store PXM data (nodeID) in pci_dev during PHYSDEVOP_pci_device_add hypercall
* Modify XEN_SYSCTL_topologyinfo so that it can return both CPU and device topology data. Add corresponding libxl interface
* Use new interface to query the hypervisor about topology and print it with 'xl info -n'
* Replace all users of old cpu topology interface with the new call. This patch is optional.
Boris Ostrovsky (4):
pci: Do not ignore device's PXM information sysctl/libxl: Add interface for returning IO topology data sysctl/libxl: Provide information about IO topology
libxl: Switch to using new topology interface
tools/libxl/libxl.c | 130 +++++++++++++++++++++++++------------- tools/libxl/libxl.h | 4 ++ tools/libxl/libxl_freebsd.c | 12 ++++ tools/libxl/libxl_internal.h | 5 ++ tools/libxl/libxl_linux.c | 74 ++++++++++++++++++++++ tools/libxl/libxl_netbsd.c | 12 ++++ tools/libxl/libxl_numa.c | 14 ++-- tools/libxl/libxl_types.idl | 12 ++++ tools/libxl/libxl_utils.c | 30 +++++---- tools/libxl/xl_cmdimpl.c | 75 +++++++++++++--------- tools/misc/xenpm.c | 64 ++++++++----------- tools/python/xen/lowlevel/xc/xc.c | 38 ++++------- xen/arch/x86/physdev.c | 20 +++++- xen/common/sysctl.c | 69 +++++++++++++++----- xen/drivers/passthrough/pci.c | 13 ++-- xen/include/public/sysctl.h | 36 ++++++++--- xen/include/xen/pci.h | 5 +- 17 files changed, 424 insertions(+), 189 deletions(-)
Signature · 1 line
1.8.4.2
PATCH 1/4 pci: Do not ignore device's PXM information
If ACPI provides PXM data for IO devices then dom0 will pass it to hypervisor during PHYSDEVOP_pci_device_add call. This information, however, is currently ignored.
We should remember it (in the form of nodeID). We will also print it when user requests device information dump.
--- xen/arch/x86/physdev.c | 20 +++++++++++++++++--- xen/drivers/passthrough/pci.c | 13 +++++++++---- xen/include/xen/pci.h | 5 ++++- 3 files changed, 30 insertions(+), 8 deletions(-)
xen/arch/x86/physdev.c +17 -3
@@ -565,7 +565,8 @@ ret_t do_physdev_op(int cmd, XEN_GUEST_HANDLE_PARAM(void) arg)if (copy_from_guest (&manage_pci, arg,1 ) !=0 )break ; - ret =pci_add_device (0 , manage_pci.bus, manage_pci.devfn,NULL ); + ret =pci_add_device (0 , manage_pci.bus, manage_pci.devfn, +NULL ,NUMA_NO_NODE );break ; }
@@ -597,13 +598,14 @@ ret_t do_physdev_op(int cmd, XEN_GUEST_HANDLE_PARAM(void) arg) pdev_info.physfn.devfn = manage_pci_ext.physfn.devfn; ret =pci_add_device (0 , manage_pci_ext.bus, manage_pci_ext.devfn, - &pdev_info); + &pdev_info,NUMA_NO_NODE );break ; }case PHYSDEVOP_pci_device_add: {struct physdev_pci_device_add add;struct pci_dev_info pdev_info; +int node; ret = -EFAULT ;if (copy_from_guest (&add, arg,1 ) !=0 )
@@ -618,7 +620,19 @@ ret_t do_physdev_op(int cmd, XEN_GUEST_HANDLE_PARAM(void) arg) }else pdev_info.is_virtfn =0 ; - ret =pci_add_device (add.seg, add.bus, add.devfn, &pdev_info); + +if ( add.flags &XEN_PCI_DEV_PXM ) { +int optarr_off = offsetof(struct physdev_pci_device_add , optarr) / +sizeof (add.optarr[0 ]); + +if (copy_from_guest_offset (&add.optarr[0 ], arg, optarr_off,1 ) ) +break ; + + node =pxm_to_node (add.optarr[0 ]); + }else + node =NUMA_NO_NODE ; + + ret =pci_add_device (add.seg, add.bus, add.devfn, &pdev_info, node);break ; }
xen/drivers/passthrough/pci.c +9 -4
@@ -568,7 +568,8 @@ static void pci_enable_acs(struct pci_dev *pdev)pci_conf_write16 (seg, bus, dev, func, pos +PCI_ACS_CTRL , ctrl); } -int pci_add_device (u16 seg,u8 bus,u8 devfn,const struct pci_dev_info *info) +int pci_add_device (u16 seg,u8 bus,u8 devfn, +const struct pci_dev_info *info,const int node) {struct pci_seg *pseg;struct pci_dev *pdev;
@@ -586,7 +587,8 @@ int pci_add_device(u16 seg, u8 bus, u8 devfn, const struct pci_dev_info *info) pdev =pci_get_pdev (seg, info->physfn.bus, info->physfn.devfn);spin_unlock (&pcidevs_lock);if ( !pdev ) -pci_add_device (seg, info->physfn.bus, info->physfn.devfn,NULL ); +pci_add_device (seg, info->physfn.bus, info->physfn.devfn, +NULL , node); pdev_type ="virtual function" ; }else
@@ -609,6 +611,8 @@ int pci_add_device(u16 seg, u8 bus, u8 devfn, const struct pci_dev_info *info)if ( !pdev ) goto out; + pdev->node = node; +if ( info ) pdev->info = *info;else if ( !pdev->vf_rlen[0 ] )
@@ -1191,10 +1195,11 @@ static int _dump_pci_devices(struct pci_seg *pseg, void *arg) list_for_each_entry ( pdev, &pseg->alldevs_list, alldevs_list ) { -printk ("%04x:%02x:%02x.%u - dom %-3d - MSIs < " , +printk ("%04x:%02x:%02x.%u - dom %-3d - node %-3d - MSIs < " , pseg->nr, pdev->bus,PCI_SLOT (pdev->devfn),PCI_FUNC (pdev->devfn), - pdev->domain ? pdev->domain->domain_id :-1 ); + pdev->domain ? pdev->domain->domain_id :-1 , + (pdev->node !=NUMA_NO_NODE ) ? pdev->node :-1 ); list_for_each_entry ( msi, &pdev->msi_list, list )printk ("%d " , msi->irq);printk (">\n" );
xen/include/xen/pci.h +4 -1
@@ -56,6 +56,8 @@ struct pci_dev {u8 phantom_stride; +int node;/* NUMA node */ +enum pdev_type {DEV_TYPE_PCI_UNKNOWN , DEV_TYPE_PCIe_ENDPOINT,
@@ -102,7 +104,8 @@ void setup_hwdom_pci_devices(struct domain *,int pci_release_devices (struct domain *d);int pci_add_segment (u16 seg);const unsigned long *pci_get_ro_map (u16 seg); -int pci_add_device (u16 seg,u8 bus,u8 devfn,const struct pci_dev_info *); +int pci_add_device (u16 seg,u8 bus,u8 devfn, +const struct pci_dev_info *,const int );int pci_remove_device (u16 seg,u8 bus,u8 devfn);int pci_ro_device (int seg,int bus,int devfn);void arch_pci_ro_device (int seg,int bdf);
Signature · 1 line
1.8.4.2
Re: [PATCH 1/4] pci: Do not ignore device's PXM information
Quoted 46 lines · Boris Ostrovsky
If ACPI provides PXM data for IO devices then dom0 will pass it to hypervisor during
PHYSDEVOP_pci_device_addcall. This information, however, is currently ignored.We should remember it (in the form of nodeID). We will also print it when user requests device information dump.
Signed-off-by Boris Ostrovsky <[email protected]>--- xen/arch/x86/physdev.c | 20 +++++++++++++++++--- xen/drivers/passthrough/pci.c | 13 +++++++++---- xen/include/xen/pci.h | 5 ++++- 3 files changed, 30 insertions(+), 8 deletions(-)xen/arch/x86/physdev.c +4
-2@@ -565,7 +565,8 @@ ret_t do_physdev_op(int cmd, XEN_GUEST_HANDLE_PARAM(void) arg)if (copy_from_guest (&manage_pci, arg,1 ) !=0 )break ; - ret =pci_add_device (0 , manage_pci.bus, manage_pci.devfn,NULL ); + ret =pci_add_device (0 , manage_pci.bus, manage_pci.devfn, +NULL ,NUMA_NO_NODE );break ; }@@ -597,13 +598,14 @@ ret_t do_physdev_op(int cmd, XEN_GUEST_HANDLE_PARAM(void) arg) pdev_info.physfn.devfn = manage_pci_ext.physfn.devfn; ret =pci_add_device (0 , manage_pci_ext.bus, manage_pci_ext.devfn, - &pdev_info); + &pdev_info,NUMA_NO_NODE );break ; }case PHYSDEVOP_pci_device_add: {struct physdev_pci_device_add add;struct pci_dev_info pdev_info; +int node; ret = -EFAULT ;if (copy_from_guest (&add, arg,1 ) !=0 )@@ -618,7 +620,19 @@ ret_t do_physdev_op(int cmd, XEN_GUEST_HANDLE_PARAM(void) arg) }
xen/arch/x86/physdev.c ret_t do_physdev_op(int cmd, XEN_GUEST_HANDLE_PARAM(void) arg) · line 629
Quoted 10 lines
xen/arch/x86/physdev.c +7
-1else pdev_info.is_virtfn =0 ; - ret =pci_add_device (add.seg, add.bus, add.devfn, &pdev_info); + +if ( add.flags &XEN_PCI_DEV_PXM ) { +int optarr_off = offsetof(struct physdev_pci_device_add , optarr) / +sizeof (add.optarr[0 ]); + +if (copy_from_guest_offset (&add.optarr[0 ], arg, optarr_off,1 ) ) +break ;
This will clobber the hypervisor stack, attempting to put the PXM information into what is probably pdev_info.
How is one expected to use XEN_PCI_DEV_PXM ? There is currently no specification of how to use the variable length structure.
~Andrew
Re: [PATCH 1/4] pci: Do not ignore device's PXM information
Quoted 43 lines · Andrew Cooper
Quoted 42 lines · Boris Ostrovsky
If ACPI provides PXM data for IO devices then dom0 will pass it to hypervisor during
PHYSDEVOP_pci_device_addcall. This information, however, is currently ignored.We should remember it (in the form of nodeID). We will also print it when user requests device information dump.
Signed-off-by Boris Ostrovsky <[email protected]>--- xen/arch/x86/physdev.c | 20 +++++++++++++++++--- xen/drivers/passthrough/pci.c | 13 +++++++++---- xen/include/xen/pci.h | 5 ++++- 3 files changed, 30 insertions(+), 8 deletions(-)xen/arch/x86/physdev.c +4
-2@@ -565,7 +565,8 @@ ret_t do_physdev_op(int cmd, XEN_GUEST_HANDLE_PARAM(void) arg)if (copy_from_guest (&manage_pci, arg,1 ) !=0 )break ; - ret =pci_add_device (0 , manage_pci.bus, manage_pci.devfn,NULL ); + ret =pci_add_device (0 , manage_pci.bus, manage_pci.devfn, +NULL ,NUMA_NO_NODE );break ; }@@ -597,13 +598,14 @@ ret_t do_physdev_op(int cmd, XEN_GUEST_HANDLE_PARAM(void) arg) pdev_info.physfn.devfn = manage_pci_ext.physfn.devfn; ret =pci_add_device (0 , manage_pci_ext.bus, manage_pci_ext.devfn, - &pdev_info); + &pdev_info,NUMA_NO_NODE );break ; }case PHYSDEVOP_pci_device_add: {struct physdev_pci_device_add add;struct pci_dev_info pdev_info; +int node;
Quoted 16 lines
Quoted 4 lines
xen/arch/x86/physdev.c +0
-0ret = -EFAULT ;if (copy_from_guest (&add, arg,1 ) !=0 )@@ -618,7 +620,19 @@ ret_t do_physdev_op(int cmd, XEN_GUEST_HANDLE_PARAM(void) arg) }xen/arch/x86/physdev.c ret_t do_physdev_op(int cmd, XEN_GUEST_HANDLE_PARAM(void) arg) · line 629
Quoted 10 lines
xen/arch/x86/physdev.c +7
-1else pdev_info.is_virtfn =0 ; - ret =pci_add_device (add.seg, add.bus, add.devfn, &pdev_info); + +if ( add.flags &XEN_PCI_DEV_PXM ) { +int optarr_off = offsetof(struct physdev_pci_device_add , optarr) / +sizeof (add.optarr[0 ]); + +if (copy_from_guest_offset (&add.optarr[0 ], arg, optarr_off,1 ) ) +break ;This will clobber the hypervisor stack, attempting to put the PXM information into what is probably
pdev_info.
Sigh... I actually fixed this on Linux side and now introduced this same bug here. (I guess I was lucky here that compiler must have inserted a word between add and pdev_info for alignment).
Quoted 3 lines
How is one expected to use
XEN_PCI_DEV_PXM? There is currently no specification of how to use the variable length structure.
I don't think this is explicitly specified anywhere but if this flag is set then optarr[0] is supposed to store uint32_t pxm. I will add a comment to this effect to physdev.h
Thanks.
-boris
Re: [PATCH 1/4] pci: Do not ignore device's PXM information
In reply to Boris OstrovskyQuoted 7 lines
Quoted 1 line
Quoted 1 line · On 02.12.14 at 22:34, <[email protected]> wrote:
If ACPI provides PXM data for IO devices then dom0 will pass it to hypervisor during
PHYSDEVOP_pci_device_addcall. This information, however, is currently ignored.We should remember it (in the form of nodeID). We will also print it when user requests device information dump.
This on its own seems pretty little reason for changing the code; considering that subsequent patches will at least convey the information to the tool stack, maybe that should be mentioned here as the primary reason for the change?
xen/arch/x86/physdev.c ret_t do_physdev_op(int cmd, XEN_GUEST_HANDLE_PARAM(void) arg) · line 608
Quoted 13 lines
xen/arch/x86/physdev.c +2
-1@@ -597,13 +598,14 @@ ret_t do_physdev_op(int cmd, XEN_GUEST_HANDLE_PARAM(void) arg) pdev_info.physfn.devfn = manage_pci_ext.physfn.devfn; ret =pci_add_device (0 , manage_pci_ext.bus, manage_pci_ext.devfn, - &pdev_info); + &pdev_info,NUMA_NO_NODE );break ; }case PHYSDEVOP_pci_device_add: {struct physdev_pci_device_add add;struct pci_dev_info pdev_info; +int node;
Here and everywhere else as applicable: unsigned int unless a negative value is possible.
xen/arch/x86/physdev.c ret_t do_physdev_op(int cmd, XEN_GUEST_HANDLE_PARAM(void) arg) · line 624
Quoted 7 lines
xen/arch/x86/physdev.c +2
-1@@ -618,7 +620,19 @@ ret_t do_physdev_op(int cmd, XEN_GUEST_HANDLE_PARAM(void) arg) }else pdev_info.is_virtfn =0 ; - ret =pci_add_device (add.seg, add.bus, add.devfn, &pdev_info); + +if ( add.flags &XEN_PCI_DEV_PXM ) {
Coding style.
xen/drivers/passthrough/pci.c static void pci_enable_acs(struct pci_dev *pdev) · line 572
Quoted 9 lines
xen/drivers/passthrough/pci.c +2
-1@@ -568,7 +568,8 @@ static void pci_enable_acs(struct pci_dev *pdev)pci_conf_write16 (seg, bus, dev, func, pos +PCI_ACS_CTRL , ctrl); } -int pci_add_device (u16 seg,u8 bus,u8 devfn,const struct pci_dev_info *info) +int pci_add_device (u16 seg,u8 bus,u8 devfn, +const struct pci_dev_info *info,const int node)
I don't see the need for the const.
xen/include/xen/pci.h struct pci_dev { · line 59
Quoted 7 lines
xen/include/xen/pci.h +1
-0@@ -56,6 +56,8 @@ struct pci_dev {u8 phantom_stride; +int node;/* NUMA node */
I don't think we currently support node IDs wider than 8 bits.
Jan
Re: [PATCH 1/4] pci: Do not ignore device's PXM information
Quoted 10 lines · Jan Beulich
xen/include/xen/pci.h struct pci_dev { · line 59
Quoted 8 lines
xen/include/xen/pci.h +1
-0@@ -56,6 +56,8 @@ struct pci_dev {u8 phantom_stride; +int node;/* NUMA node */ I don't think we currently support node IDs wider than 8 bits.
I used an int because pxm_to_node() returns an int. OTOH, pxm2node[], for which pxm_to_node() is essentially a wrapper, is a u8.
-boris
PATCH 2/4 sysctl/libxl: Add interface for returning IO topology data
In reply to Boris OstrovskyMake XEN_SYSCTL_topologyinfo more generic so that it can return both CPU and IO topology (support for returning the latter is added in the subsequent patch)
To do so move (and rename) previously used cpu_to_core/cpu_to_socket/ cpu_to_node into struct xen_sysctl_cputopo and move it, together with newly added struct xen_sysctl_iotopo, to xen_sysctl_topologyinfo.
Add libxl_get_topology() to handle new interface and modify libxl_get_cpu_topology() to be a wrapper around it.
Adjust xenpm and python's low-level C libraries for new interface.
This change requires bumping XEN_SYSCTL_INTERFACE_VERSION
--- tools/libxl/libxl.c | 79 ++++++++++++++++++++++++--------------- tools/libxl/libxl.h | 4 ++ tools/libxl/libxl_types.idl | 12 ++++++ tools/libxl/libxl_utils.c | 6 +++ tools/misc/xenpm.c | 64 +++++++++++++------------------ tools/python/xen/lowlevel/xc/xc.c | 38 +++++++------------ xen/common/sysctl.c | 43 ++++++++++++--------- xen/include/public/sysctl.h | 36 +++++++++++++----- 8 files changed, 162 insertions(+), 120 deletions(-)
tools/libxl/libxl.c +48 -31
@@ -5056,11 +5056,37 @@ int libxl_get_physinfo(libxl_ctx *ctx, libxl_physinfo *physinfo)libxl_cputopology *libxl_get_cpu_topology (libxl_ctx *ctx,int *nb_cpu_out) {GC_INIT (ctx); +libxl_cputopology *cputopology =NULL ; +libxl_topology *topo; +int i; + + topo =libxl_get_topology (ctx); +if (topo ==NULL ) { + *nb_cpu_out =0 ; + goto out; + } + + cputopology =libxl__zalloc (NOGC ,sizeof (libxl_cputopology) * topo->cpu_num); +for (i =0 ; i < topo->cpu_num; i++) { + cputopology[i].core = topo->cpu[i].core; + cputopology[i].socket = topo->cpu[i].socket; + cputopology[i].node = topo->cpu[i].node; + } + *nb_cpu_out = topo->cpu_num; + +libxl_topology_free (topo); + + out: +GC_FREE ; +return cputopology; +} + +libxl_topology *libxl_get_topology (libxl_ctx *ctx) +{ +GC_INIT (ctx);xc_topologyinfo_t tinfo; -DECLARE_HYPERCALL_BUFFER (xc_cpu_to_core_t, coremap); -DECLARE_HYPERCALL_BUFFER (xc_cpu_to_socket_t, socketmap); -DECLARE_HYPERCALL_BUFFER (xc_cpu_to_node_t, nodemap); -libxl_cputopology *ret =NULL ; +DECLARE_HYPERCALL_BUFFER (xen_sysctl_cputopo_t, cputopo); +libxl_topology *ret =NULL ;int i;int max_cpus;
@@ -5072,48 +5098,39 @@ libxl_cputopology *libxl_get_cpu_topology(libxl_ctx *ctx, int *nb_cpu_out) goto out; } - coremap =xc_hypercall_buffer_alloc - (ctx->xch, coremap,sizeof (*coremap) * max_cpus); - socketmap =xc_hypercall_buffer_alloc - (ctx->xch, socketmap,sizeof (*socketmap) * max_cpus); - nodemap =xc_hypercall_buffer_alloc - (ctx->xch, nodemap,sizeof (*nodemap) * max_cpus); -if ((coremap ==NULL ) || (socketmap ==NULL ) || (nodemap ==NULL )) { + cputopo =xc_hypercall_buffer_alloc (ctx->xch, cputopo, +sizeof (*cputopo) * max_cpus); +if (cputopo ==NULL ) {LIBXL__LOG_ERRNOVAL (ctx,XTL_ERROR ,ENOMEM ,"Unable to allocate hypercall arguments" ); goto fail; } - -set_xen_guest_handle (tinfo.cpu_to_core, coremap); -set_xen_guest_handle (tinfo.cpu_to_socket, socketmap); -set_xen_guest_handle (tinfo.cpu_to_node, nodemap); +set_xen_guest_handle (tinfo.cputopo, cputopo); tinfo.max_cpu_index = max_cpus -1 ; + +set_xen_guest_handle (tinfo.iotopo,HYPERCALL_BUFFER_NULL ); +if (xc_topologyinfo (ctx->xch, &tinfo) !=0 ) {LIBXL__LOG_ERRNO (ctx,XTL_ERROR ,"Topology info hypercall failed" ); goto fail; } -if (tinfo.max_cpu_index < max_cpus -1 ) - max_cpus = tinfo.max_cpu_index +1 ; + ret =libxl__zalloc (NOGC ,sizeof (*ret)); + ret->cpu_num = tinfo.max_cpu_index +1 ; + ret->cpu =libxl__zalloc (NOGC ,sizeof (*(ret->cpu)) * ret->cpu_num); - ret =libxl__zalloc (NOGC ,sizeof (libxl_cputopology) * max_cpus); - -for (i =0 ; i < max_cpus; i++) { -#define V (map, i) (map[i] == INVALID_TOPOLOGY_ID) ? \ - LIBXL_CPUTOPOLOGY_INVALID_ENTRY : map[i] - ret[i].core =V (coremap, i); - ret[i].socket =V (socketmap, i); - ret[i].node =V (nodemap, i); +for (i =0 ; i < ret->cpu_num; i++) { +#define V (map, i) ( cputopo[i].map == INVALID_TOPOLOGY_ID) ? \ + LIBXL_CPUTOPOLOGY_INVALID_ENTRY : cputopo[i].map + ret->cpu[i].core =V (core, i); + ret->cpu[i].socket =V (socket, i); + ret->cpu[i].node =V (node, i);#undef V } -fail: -xc_hypercall_buffer_free (ctx->xch, coremap); -xc_hypercall_buffer_free (ctx->xch, socketmap); -xc_hypercall_buffer_free (ctx->xch, nodemap); + fail: +xc_hypercall_buffer_free (ctx->xch, cputopo); -if (ret) - *nb_cpu_out = max_cpus; out:GC_FREE ;return ret;
tools/libxl/libxl.h +4 -0
@@ -1060,6 +1060,10 @@ void libxl_vminfo_list_free(libxl_vminfo *list, int nb_vm);libxl_cputopology *libxl_get_cpu_topology (libxl_ctx *ctx,int *nb_cpu_out);void libxl_cputopology_list_free (libxl_cputopology *,int nb_cpu); +#define LIBXL_TOPOLOGY_INVALID_ENTRY (~(uint32_t)0) +libxl_topology *libxl_get_topology (libxl_ctx *ctx); +void libxl_topology_free (libxl_topology *); +#define LIBXL_NUMAINFO_INVALID_ENTRY (~(uint32_t)0)libxl_numainfo *libxl_get_numainfo (libxl_ctx *ctx,int *nr);void libxl_numainfo_list_free (libxl_numainfo *,int nr);
tools/libxl/libxl_types.idl +12 -0
@@ -642,6 +642,18 @@ libxl_cputopology = Struct("cputopology", [ ("node", uint32), ], dir=DIR_OUT) +libxl_iotopology = Struct("iotopology", [ + ("seg", uint16), + ("bus", uint8), + ("devfn", uint8), + ("node", uint32), + ], dir=DIR_OUT) + +libxl_topology = Struct("topology", [ + ("cpu", Array(libxl_cputopology, "cpu_num")), + ("dev", Array(libxl_iotopology, "dev_num")), + ], dir=DIR_OUT) + libxl_sched_credit_params = Struct("sched_credit_params", [ ("tslice_ms", integer), ("ratelimit_us", integer),
tools/libxl/libxl_utils.c +6 -0
@@ -859,6 +859,12 @@ void libxl_cputopology_list_free(libxl_cputopology *list, int nr)free (list); } +void libxl_topology_free (libxl_topology *tinfo) +{ +libxl_topology_dispose (tinfo); +free (tinfo); +} +void libxl_numainfo_list_free (libxl_numainfo *list,int nr) {int i;
tools/misc/xenpm.c +25 -39
147 lines not on this page · raw message
tools/python/xen/lowlevel/xc/xc.c +14 -24
@@ -1226,25 +1226,17 @@ static PyObject *pyxc_topologyinfo(XcObject *self)int i, max_cpu_index;PyObject *ret_obj =NULL ;PyObject *cpu_to_core_obj, *cpu_to_socket_obj, *cpu_to_node_obj; -DECLARE_HYPERCALL_BUFFER (xc_cpu_to_core_t, coremap); -DECLARE_HYPERCALL_BUFFER (xc_cpu_to_socket_t, socketmap); -DECLARE_HYPERCALL_BUFFER (xc_cpu_to_node_t, nodemap); - coremap =xc_hypercall_buffer_alloc (self->xc_handle, coremap,sizeof (*coremap) * (MAX_CPU_INDEX +1 )); -if ( coremap ==NULL ) - goto out; - socketmap =xc_hypercall_buffer_alloc (self->xc_handle, socketmap,sizeof (*socketmap) * (MAX_CPU_INDEX +1 )); -if ( socketmap ==NULL ) - goto out; - nodemap =xc_hypercall_buffer_alloc (self->xc_handle, nodemap,sizeof (*nodemap) * (MAX_CPU_INDEX +1 )); -if ( nodemap ==NULL ) - goto out; +DECLARE_HYPERCALL_BUFFER (xen_sysctl_cputopo_t, cputopo); -set_xen_guest_handle (tinfo.cpu_to_core, coremap); -set_xen_guest_handle (tinfo.cpu_to_socket, socketmap); -set_xen_guest_handle (tinfo.cpu_to_node, nodemap); + cputopo =xc_hypercall_buffer_alloc (self->xc_handle, cputopo,sizeof (*cputopo) * (MAX_CPU_INDEX +1 )); +if ( cputopo ==NULL ) + goto out; +set_xen_guest_handle (tinfo.cputopo, cputopo); tinfo.max_cpu_index =MAX_CPU_INDEX ; +set_xen_guest_handle (tinfo.iotopo,HYPERCALL_BUFFER_NULL ); +if (xc_topologyinfo (self->xc_handle, &tinfo) !=0 ) goto out;
@@ -1258,35 +1250,35 @@ static PyObject *pyxc_topologyinfo(XcObject *self) cpu_to_node_obj =PyList_New (0 );for ( i =0 ; i <= max_cpu_index; i++ ) { -if ( coremap[i] ==INVALID_TOPOLOGY_ID ) +if ( cputopo[i].core ==INVALID_TOPOLOGY_ID ) {PyList_Append (cpu_to_core_obj, Py_None); }else { -PyObject *pyint =PyInt_FromLong (coremap[i]); +PyObject *pyint =PyInt_FromLong (cputopo[i].core);PyList_Append (cpu_to_core_obj, pyint);Py_DECREF (pyint); } -if ( socketmap[i] ==INVALID_TOPOLOGY_ID ) +if ( cputopo[i].socket ==INVALID_TOPOLOGY_ID ) {PyList_Append (cpu_to_socket_obj, Py_None); }else { -PyObject *pyint =PyInt_FromLong (socketmap[i]); +PyObject *pyint =PyInt_FromLong (cputopo[i].socket);PyList_Append (cpu_to_socket_obj, pyint);Py_DECREF (pyint); } -if ( nodemap[i] ==INVALID_TOPOLOGY_ID ) +if ( cputopo[i].node ==INVALID_TOPOLOGY_ID ) {PyList_Append (cpu_to_node_obj, Py_None); }else { -PyObject *pyint =PyInt_FromLong (nodemap[i]); +PyObject *pyint =PyInt_FromLong (cputopo[i].node);PyList_Append (cpu_to_node_obj, pyint);Py_DECREF (pyint); }
@@ -1304,9 +1296,7 @@ static PyObject *pyxc_topologyinfo(XcObject *self)Py_DECREF (cpu_to_node_obj); out: -xc_hypercall_buffer_free (self->xc_handle, coremap); -xc_hypercall_buffer_free (self->xc_handle, socketmap); -xc_hypercall_buffer_free (self->xc_handle, nodemap); +xc_hypercall_buffer_free (self->xc_handle, cputopo);return ret_obj ? ret_obj :pyxc_error_to_exception (self->xc_handle);#undef MAX_CPU_INDEX }
xen/common/sysctl.c +26 -17
58 lines not on this page · raw message
xen/include/public/sysctl.h +27 -9
@@ -34,7 +34,7 @@#include "xen.h" #include "domctl.h" -#define XEN_SYSCTL_INTERFACE_VERSION 0x0000000B +#define XEN_SYSCTL_INTERFACE_VERSION 0x0000000C/* * Read console content from Xen buffer ring.
@@ -464,26 +464,44 @@ DEFINE_XEN_GUEST_HANDLE(xen_sysctl_lockprof_op_t);/* XEN_SYSCTL_topologyinfo */ #define INVALID_TOPOLOGY_ID (~0U) + +struct xen_sysctl_cputopo { +uint32_t core; +uint32_t socket; +uint32_t node; +}; +typedef struct xen_sysctl_cputopo xen_sysctl_cputopo_t ; +DEFINE_XEN_GUEST_HANDLE (xen_sysctl_cputopo_t); + +struct xen_sysctl_iotopo { +uint16_t seg; +uint8_t bus; +uint8_t devfn; +uint32_t node; +}; +typedef struct xen_sysctl_iotopo xen_sysctl_iotopo_t ; +DEFINE_XEN_GUEST_HANDLE (xen_sysctl_iotopo_t); +struct xen_sysctl_topologyinfo {/* * IN: maximum addressable entry in the caller-provided arrays. -* OUT: largest cpu identifier in the system. +* OUT: largest cpu identifier or max number of devices in the system. * If OUT is greater than IN then the arrays are truncated! * If OUT is leass than IN then the array tails are not written by sysctl. */ uint32_t max_cpu_index; +uint32_t max_devs;/* * If not NULL, these arrays are filled with core/socket/node identifier -* for each cpu. -* If a cpu has no core/socket/node information (e.g., cpu not present) -* then the sentinel value ~0u is written to each array. -* The number of array elements written by the sysctl is: +* for each cpu and/or node for each PCI device. +* If information for a particular entry is not avalable it is set to +* INVALID_TOPOLOGY_ID. +* The number of array elements for CPU topology written by the sysctl is: * min(@max_cpu_index_IN,@max_cpu_index_OUT)+1 */ -XEN_GUEST_HANDLE_64 (uint32) cpu_to_core; -XEN_GUEST_HANDLE_64 (uint32) cpu_to_socket; -XEN_GUEST_HANDLE_64 (uint32) cpu_to_node; +XEN_GUEST_HANDLE_64 (xen_sysctl_cputopo_t) cputopo; +XEN_GUEST_HANDLE_64 (xen_sysctl_iotopo_t) iotopo; };typedef struct xen_sysctl_topologyinfo xen_sysctl_topologyinfo_t ;DEFINE_XEN_GUEST_HANDLE (xen_sysctl_topologyinfo_t);
Signature · 1 line
1.8.4.2
Re: [PATCH 2/4] sysctl/libxl: Add interface for returning IO topology data
Quoted 38 lines · Boris Ostrovsky
/*
XEN_SYSCTL_topologyinfo*/
#defineINVALID_TOPOLOGY_ID(~0U)xen/include/public/sysctl.h +21
-5+ +struct xen_sysctl_cputopo { +uint32_t core; +uint32_t socket; +uint32_t node; +}; +typedef struct xen_sysctl_cputopo xen_sysctl_cputopo_t ; +DEFINE_XEN_GUEST_HANDLE (xen_sysctl_cputopo_t); + +struct xen_sysctl_iotopo { +uint16_t seg; +uint8_t bus; +uint8_t devfn; +uint32_t node; +}; +typedef struct xen_sysctl_iotopo xen_sysctl_iotopo_t ; +DEFINE_XEN_GUEST_HANDLE (xen_sysctl_iotopo_t); +struct xen_sysctl_topologyinfo {/* * IN: maximum addressable entry in the caller-provided arrays. -* OUT: largest cpu identifier in the system. +* OUT: largest cpu identifier or max number of devices in the system. * If OUT is greater than IN then the arrays are truncated! * If OUT is leass than IN then the array tails are not written by sysctl. */ uint32_t max_cpu_index; +uint32_t max_devs;/* * If not NULL, these arrays are filled with core/socket/node identifier -* for each cpu. -* If a cpu has no core/socket/node information (e.g., cpu not present) -* then the sentinel value ~0u is written to each array. -* The number of array elements written by the sysctl is: +* for each cpu and/or node for each PCI device.
xen/include/public/sysctl.h DEFINE_XEN_GUEST_HANDLE(xen_sysctl_lockprof_op_t); · line 504
Quoted 10 lines
xen/include/public/sysctl.h +5
-3+* If information for a particular entry is not avalable it is set to +* INVALID_TOPOLOGY_ID. +* The number of array elements for CPU topology written by the sysctl is: * min(@max_cpu_index_IN,@max_cpu_index_OUT)+1 */ -XEN_GUEST_HANDLE_64 (uint32) cpu_to_core; -XEN_GUEST_HANDLE_64 (uint32) cpu_to_socket; -XEN_GUEST_HANDLE_64 (uint32) cpu_to_node; +XEN_GUEST_HANDLE_64 (xen_sysctl_cputopo_t) cputopo; +XEN_GUEST_HANDLE_64 (xen_sysctl_iotopo_t) iotopo;
These are inherently lists with different indicies. They should not conglomerated like this.
I would suggest introducing a new hypercall (xen_sysctl_iotopologyinfo ?) and leave this one alone.
~Andrew
Re: [PATCH 2/4] sysctl/libxl: Add interface for returning IO topology data
Quoted 43 lines · Andrew Cooper
Quoted 42 lines · Boris Ostrovsky
/* XEN_SYSCTL_topologyinfo */ #define INVALID_TOPOLOGY_ID (~0U)xen/include/public/sysctl.h +24
-5+ +struct xen_sysctl_cputopo { +uint32_t core; +uint32_t socket; +uint32_t node; +}; +typedef struct xen_sysctl_cputopo xen_sysctl_cputopo_t ; +DEFINE_XEN_GUEST_HANDLE (xen_sysctl_cputopo_t); + +struct xen_sysctl_iotopo { +uint16_t seg; +uint8_t bus; +uint8_t devfn; +uint32_t node; +}; +typedef struct xen_sysctl_iotopo xen_sysctl_iotopo_t ; +DEFINE_XEN_GUEST_HANDLE (xen_sysctl_iotopo_t); +struct xen_sysctl_topologyinfo {/* * IN: maximum addressable entry in the caller-provided arrays. -* OUT: largest cpu identifier in the system. +* OUT: largest cpu identifier or max number of devices in the system. * If OUT is greater than IN then the arrays are truncated! * If OUT is leass than IN then the array tails are not written by sysctl. */ uint32_t max_cpu_index; +uint32_t max_devs;/* * If not NULL, these arrays are filled with core/socket/node identifier -* for each cpu. -* If a cpu has no core/socket/node information (e.g., cpu not present) -* then the sentinel value ~0u is written to each array. -* The number of array elements written by the sysctl is: +* for each cpu and/or node for each PCI device. +* If information for a particular entry is not avalable it is set to +* INVALID_TOPOLOGY_ID. +* The number of array elements for CPU topology written by the sysctl is: * min(@max_cpu_index_IN,@max_cpu_index_OUT)+1
Quoted 8 lines
xen/include/public/sysctl.h DEFINE_XEN_GUEST_HANDLE(xen_sysctl_lockprof_op_t); · line 504
Quoted 6 lines
*/xen/include/public/sysctl.h +2
-3-XEN_GUEST_HANDLE_64 (uint32) cpu_to_core; -XEN_GUEST_HANDLE_64 (uint32) cpu_to_socket; -XEN_GUEST_HANDLE_64 (uint32) cpu_to_node; +XEN_GUEST_HANDLE_64 (xen_sysctl_cputopo_t) cputopo; +XEN_GUEST_HANDLE_64 (xen_sysctl_iotopo_t) iotopo;These are inherently lists with different indicies. They should not conglomerated like this.
I don't follow this. These are indeed lists with different indicies but why can't they both be part of this struct?
-boris
Quoted 5 lines
I would suggest introducing a new hypercall (
xen_sysctl_iotopologyinfo?) and leave this one alone.~Andrew
Re: [PATCH 2/4] sysctl/libxl: Add interface for returning IO topology data
In reply to Boris OstrovskyOn Tue, Dec 02, 2014 at 04:34:08PM -0500, Boris Ostrovsky wrote:
[...]
Quoted 18 lines
void
libxl_cputopology_list_free(libxl_cputopology *, int nb_cpu);tools/libxl/libxl.h +4
-0+#define LIBXL_TOPOLOGY_INVALID_ENTRY (~(uint32_t)0) +libxl_topology *libxl_get_topology (libxl_ctx *ctx); +void libxl_topology_free (libxl_topology *); +#define LIBXL_NUMAINFO_INVALID_ENTRY (~(uint32_t)0)libxl_numainfo *libxl_get_numainfo (libxl_ctx *ctx,int *nr);void libxl_numainfo_list_free (libxl_numainfo *,int nr);tools/libxl/libxl_types.idl +1
-0@@ -642,6 +642,18 @@ libxl_cputopology = Struct("cputopology", [ ("node", uint32), ], dir=DIR_OUT) +libxl_iotopology = Struct("iotopology", [
tools/libxl/libxl_types.idl libxl_cputopology = Struct("cputopology", [ · line 655
Quoted 10 lines
tools/libxl/libxl_types.idl +10
-0+ ("seg", uint16), + ("bus", uint8), + ("devfn", uint8), + ("node", uint32), + ], dir=DIR_OUT) + +libxl_topology = Struct("topology", [ + ("cpu", Array(libxl_cputopology, "cpu_num")), + ("dev", Array(libxl_iotopology, "dev_num")), + ], dir=DIR_OUT)
Use "num_cpu" and "num_dev" please.
I think you also need to add a LIBXL_HAVE_$FOO in libxl.h.
Wei.
Re: [PATCH 2/4] sysctl/libxl: Add interface for returning IO topology data
In reply to Boris OstrovskyQuoted 4 lines · Boris Ostrovsky
Make
XEN_SYSCTL_topologyinfomore generic so that it can return both CPU and IO topology (support for returning the latter is added in the subsequent patch)
Is it always the case that we need the full information (i.e., both CPU and IO topology), at all levels above Xen?
I appreciate the performance implications (one hcall instead of two) in cases where we do, but I still think, as Andrew suggested, that having a new XEN_SYSCTL_iotopology (or something like that) and leaving *_topologyinfo alone would make a better low-level interface.
All IMHO, of course.
Quoted 7 lines
To do so move (and rename) previously used cpu_to_core/cpu_to_socket/
cpu_to_nodeinto structxen_sysctl_cputopoand move it, together with newly added structxen_sysctl_iotopo, toxen_sysctl_topologyinfo.Add
libxl_get_topology()to handle new interface and modifylibxl_get_cpu_topology()to be a wrapper around it.
This is, I think, useful, and I'd go for it, even if we adding a new hypercall at the Xen and xc level.
Of course, it would work the other way round: the new libxl function would wrap the existing libxl_get_cpu_topology() and a new libxl call (something like libxl_get_io_topology() ?).
Quoted 2 lines
Adjust xenpm and python's low-level C libraries for new interface.
All in one patch? Wouldn't splitting it at least in two (hypervisor and tools parts) be better? If it were me, I'd probably split even more...
Quoted 2 lines
This change requires bumping
XEN_SYSCTL_INTERFACE_VERSION
Which would not be the case if we take the approach of adding a new, iotopology specific, hcall, would it?
Regards,
Dario
Signature · 4 lines
<<This happens because I choose it to happen!>> (Raistlin Majere) ----------------------------------------------------------------- Dario Faggioli, Ph.D, http://about.me/dario.faggioli Senior Software Engineer, Citrix Systems R&D Ltd., Cambridge (UK)
_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel
Re: [PATCH 2/4] sysctl/libxl: Add interface for returning IO topology data
Quoted 8 lines · Dario Faggioli
Quoted 4 lines · Boris Ostrovsky
Make
XEN_SYSCTL_topologyinfomore generic so that it can return both CPU and IO topology (support for returning the latter is added in the subsequent patch)Is it always the case that we need the full information (i.e., both CPU and IO topology), at all levels above Xen?
Quoted 6 lines
I appreciate the performance implications (one hcall instead of two) in cases where we do, but I still think, as Andrew suggested, that having a new
XEN_SYSCTL_iotopology(or something like that) and leaving*_topologyinfoalone would make a better low-level interface.All IMHO, of course.
I don't feel strongly either way so I can go that route (and it will make patch 4 completely unnecessary).
(I am not sure though I understood Andrew's reasoning for splitting into two sysctls.
Quoted 10 lines
Quoted 7 lines
To do so move (and rename) previously used cpu_to_core/cpu_to_socket/
cpu_to_nodeinto structxen_sysctl_cputopoand move it, together with newly added structxen_sysctl_iotopo, toxen_sysctl_topologyinfo.Add
libxl_get_topology()to handle new interface and modifylibxl_get_cpu_topology()to be a wrapper around it.This is, I think, useful, and I'd go for it, even if we adding a new hypercall at the Xen and xc level.
Quoted 8 lines
Of course, it would work the other way round: the new libxl function would wrap the existing
libxl_get_cpu_topology()and a new libxl call (something likelibxl_get_io_topology()?).Quoted 2 lines
Adjust xenpm and python's low-level C libraries for new interface.
All in one patch? Wouldn't splitting it at least in two (hypervisor and tools parts) be better? If it were me, I'd probably split even more...
I could not split it because this patch changes sysctl interface (more specifically, xen_sysctl_topologyinfo_t/xc_topologyinfo_t) so anyone who uses this struct needed to be updated at the same time.
Of course, if I were to leave current interface intact and add another sysctl for IO topology then this will not be necessary
Quoted 5 lines
Quoted 3 lines
This change requires bumping
XEN_SYSCTL_INTERFACE_VERSIONWhich would not be the case if we take the approach of adding a new, iotopology specific, hcall, would it?
I would think that any changes to a public interface, including adding a new function, require new version.
(And if we get a new version, even if we split topology into CPU and IO sysctls, I'd still like to put cpu_to_[core|socket||node] into a single structure).
Thanks.
-boris
Re: [PATCH 2/4] sysctl/libxl: Add interface for returning IO topology data
Quoted 14 lines · Boris Ostrovsky
Quoted 13 lines · Dario Faggioli
Quoted 4 lines · Boris Ostrovsky
Make
XEN_SYSCTL_topologyinfomore generic so that it can return both CPU and IO topology (support for returning the latter is added in the subsequent patch)Is it always the case that we need the full information (i.e., both CPU and IO topology), at all levels above Xen?
I appreciate the performance implications (one hcall instead of two) in cases where we do, but I still think, as Andrew suggested, that having a new
XEN_SYSCTL_iotopology(or something like that) and leaving*_topologyinfoalone would make a better low-level interface.
Quoted 7 lines
Quoted 1 line
All IMHO, of course.
I don't feel strongly either way so I can go that route (and it will make patch 4 completely unnecessary).
(I am not sure though I understood Andrew's reasoning for splitting into two sysctls.
The two bits of information are different, and it is perfectly reasonable to want the cpu information at one point, but the io information at another.
As it stands, you appear to mandate that the caller wants the cpu information, which is not true.
Quoted 1 line
From a separate point of view, while the sysctl abi version does allow
us to make changes like this, it makes a mess for valgrind and strace to have radically different hypercalls with the same name, separated by only the interface version.
Quoted 20 lines
Quoted 11 lines
Quoted 8 lines
To do so move (and rename) previously used cpu_to_core/cpu_to_socket/
cpu_to_nodeinto structxen_sysctl_cputopoand move it, together with newly added structxen_sysctl_iotopo, toxen_sysctl_topologyinfo.Add
libxl_get_topology()to handle new interface and modifylibxl_get_cpu_topology()to be a wrapper around it.This is, I think, useful, and I'd go for it, even if we adding a new hypercall at the Xen and xc level.
Quoted 8 lines
Of course, it would work the other way round: the new libxl function would wrap the existing
libxl_get_cpu_topology()and a new libxl call (something likelibxl_get_io_topology()?).Quoted 2 lines
Adjust xenpm and python's low-level C libraries for new interface.
All in one patch? Wouldn't splitting it at least in two (hypervisor and tools parts) be better? If it were me, I'd probably split even more...
Quoted 6 lines
I could not split it because this patch changes sysctl interface (more specifically, xen_sysctl_topologyinfo_t/xc_topologyinfo_t) so anyone who uses this struct needed to be updated at the same time.
Of course, if I were to leave current interface intact and add another sysctl for IO topology then this will not be necessary
This is the other reason why change simply for changes sake in the interface is best avoided. The unstable API goes very deep into the toolstack.
Quoted 7 lines
Quoted 6 lines
Quoted 4 lines
This change requires bumping
XEN_SYSCTL_INTERFACE_VERSIONWhich would not be the case if we take the approach of adding a new, iotopology specific, hcall, would it?
Quoted 6 lines
I would think that any changes to a public interface, including adding a new function, require new version.
(And if we get a new version, even if we split topology into CPU and IO sysctls, I'd still like to put cpu_to_[core|socket||node] into a single structure).
This would certainly decrease the faff both the toostack and hypervisor have to go to when passing the parameters, and I think it would be a good improvement.
~Andrew
Re: [PATCH 2/4] sysctl/libxl: Add interface for returning IO topology data
In reply to Boris OstrovskyQuoted 10 lines
Quoted 1 line
Quoted 1 line · On 04.12.14 at 17:26, <[email protected]> wrote:
Quoted 5 lines · Dario Faggioli
Quoted 2 lines · Boris Ostrovsky
This change requires bumping
XEN_SYSCTL_INTERFACE_VERSIONWhich would not be the case if we take the approach of adding a new, iotopology specific, hcall, would it?
I would think that any changes to a public interface, including adding a new function, require new version.
No, additions of new sub-ops don't require the version to be bumped.
Jan
Re: [PATCH 2/4] sysctl/libxl: Add interface for returning IO topology data
In reply to Boris Ostrovskyxen/include/public/sysctl.h DEFINE_XEN_GUEST_HANDLE(xen_sysctl_lockprof_op_t); · line 481
Quoted 7 lines
Quoted 1 line
Quoted 1 line · On 02.12.14 at 22:34, <[email protected]> wrote:
xen/include/public/sysctl.h +6
-0+struct xen_sysctl_iotopo { +uint16_t seg; +uint8_t bus; +uint8_t devfn; +uint32_t node; +};
This is PCI-centric without expressing in the name or layout. Perhaps the first part should be a union from the very beginning?
Jan
Re: [PATCH 2/4] sysctl/libxl: Add interface for returning IO topology data
Quoted 11 lines
xen/include/public/sysctl.h DEFINE_XEN_GUEST_HANDLE(xen_sysctl_lockprof_op_t); · line 481
Quoted 8 lines
Quoted 2 lines · On 05.12.14 at 16:55, <[email protected]> wrote:
Quoted 1 line · On 02.12.14 at 22:34, <[email protected]> wrote:
xen/include/public/sysctl.h +6
-0+struct xen_sysctl_iotopo { +uint16_t seg; +uint8_t bus; +uint8_t devfn; +uint32_t node; +};This is PCI-centric without expressing in the name or layout. Perhaps the first part should be a union from the very beginning?
And I wonder whether that supposed union part wouldn't be nicely done using struct physdev_pci_device.
Additionally please add IN and OUT annotations. When I first saw this I assumed they would all be OUT (in which case the long running loop problem mentioned in the reply to one of the other patches wouldn't have been there), matching their CPU counterpart...
Jan
Re: [PATCH 2/4] sysctl/libxl: Add interface for returning IO topology data
Quoted 9 lines · Jan Beulich
Quoted 9 lines
xen/include/public/sysctl.h DEFINE_XEN_GUEST_HANDLE(xen_sysctl_lockprof_op_t); · line 481
Quoted 8 lines
Quoted 2 lines · On 05.12.14 at 16:55, <[email protected]> wrote:
Quoted 1 line · On 02.12.14 at 22:34, <[email protected]> wrote:
xen/include/public/sysctl.h +6
-0+struct xen_sysctl_iotopo { +uint16_t seg; +uint8_t bus; +uint8_t devfn; +uint32_t node; +};This is PCI-centric without expressing in the name or layout.
xen_sysctl_pcitopo would be a better name.
Quoted 4 lines
Quoted 2 lines
Perhaps
the first part should be a union from the very beginning?And I wonder whether that supposed union part wouldn't be nicely done using struct
physdev_pci_device.
The do look strikingly similar ;-)
How would a union be useful here?
Quoted 5 lines
Additionally please add IN and OUT annotations. When I first saw this I assumed they would all be OUT (in which case the long running loop problem mentioned in the reply to one of the other patches wouldn't have been there), matching their CPU counterpart...
I don't follow this. Are you saying that if ti->max_devs in patch 3/4 is an IN (which it is) then we don't have to guard for long-running loops?
-boris
Re: [PATCH 2/4] sysctl/libxl: Add interface for returning IO topology data
Quoted 14 lines
Quoted 1 line
Quoted 1 line · On 05.12.14 at 18:10, <[email protected]> wrote:
Quoted 9 lines · Jan Beulich
Quoted 9 lines
xen/include/public/sysctl.h DEFINE_XEN_GUEST_HANDLE(xen_sysctl_lockprof_op_t); · line 481
Quoted 8 lines
Quoted 2 lines · On 05.12.14 at 16:55, <[email protected]> wrote:
Quoted 1 line · On 02.12.14 at 22:34, <[email protected]> wrote:
xen/include/public/sysctl.h +6
-0+struct xen_sysctl_iotopo { +uint16_t seg; +uint8_t bus; +uint8_t devfn; +uint32_t node; +};This is PCI-centric without expressing in the name or layout.
xen_sysctl_pcitopowould be a better name.
Quoted 8 lines
Quoted 4 lines
Quoted 2 lines
Perhaps
the first part should be a union from the very beginning?And I wonder whether that supposed union part wouldn't be nicely done using struct
physdev_pci_device.The do look strikingly similar ;-)
How would a union be useful here?
If this was left as iotopo, PCI would be one of potentially many I/O variants, and hence a union would seem warranted. If you want to rename it to pcitopo that of course would be pointless.
Quoted 7 lines
Quoted 4 lines
Additionally please add IN and OUT annotations. When I first saw this I assumed they would all be OUT (in which case the long running loop problem mentioned in the reply to one of the other patches wouldn't have been there), matching their CPU counterpart...
I don't follow this. Are you saying that if
ti->max_devsin patch 3/4 is an IN (which it is) then we don't have to guard for long-running loops?
If they were all OUT then there wouldn't be a way for the entire operation to be fooled into going over more devices than there are in the system.
Jan
Re: [PATCH 2/4] sysctl/libxl: Add interface for returning IO topology data
Quoted 10 lines
Quoted 7 lines
Quoted 5 lines
Additionally please add IN and OUT annotations. When I first saw this I assumed they would all be OUT (in which case the long running loop problem mentioned in the reply to one of the other patches wouldn't have been there), matching their CPU counterpart...
I don't follow this. Are you saying that if
ti->max_devsin patch 3/4 is an IN (which it is) then we don't have to guard for long-running loops?If they were all OUT then there wouldn't be a way for the entire operation to be fooled into going over more devices than there are in the system.
Assuming I add continuations to the loop, too many devices wouldn't be a problem for the hypervisor, would it? If an unreasonable number is provided then eventually copy_from_guest() will fault.
-boris
Re: [PATCH 2/4] sysctl/libxl: Add interface for returning IO topology data
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines · On 08.12.14 at 15:56, <[email protected]> wrote:
Quoted 5 lines
Additionally please add IN and OUT annotations. When I first saw this I assumed they would all be OUT (in which case the long running loop problem mentioned in the reply to one of the other patches wouldn't have been there), matching their CPU counterpart...
I don't follow this. Are you saying that if
ti->max_devsin patch 3/4 is an IN (which it is) then we don't have to guard for long-running loops?
Quoted 7 lines
Quoted 3 lines
If they were all OUT then there wouldn't be a way for the entire operation to be fooled into going over more devices than there are in the system.
Assuming I add continuations to the loop, too many devices wouldn't be a problem for the hypervisor, would it? If an unreasonable number is provided then eventually
copy_from_guest()will fault.
Continuations would address the concern, but it doesn't seem like their use is really warranted here.
Jan
Re: [PATCH 2/4] sysctl/libxl: Add interface for returning IO topology data
Quoted 7 lines · Jan Beulich
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines · On 08.12.14 at 15:56, <[email protected]> wrote:
Quoted 4 lines
Additionally please add IN and OUT annotations. When I first saw this I assumed they would all be OUT (in which case the long running loop problem mentioned in the reply to one of the other patches wouldn't have been there), matching their CPU counterpart...
I don't follow this. Are you saying that if
ti->max_devsin patch 3/4 is an IN (which it is) then we don't have to guard for long-running loops?
Quoted 8 lines
Quoted 6 lines
Quoted 3 lines
If they were all OUT then there wouldn't be a way for the entire operation to be fooled into going over more devices than there are in the system.
Assuming I add continuations to the loop, too many devices wouldn't be a problem for the hypervisor, would it? If an unreasonable number is provided then eventually
copy_from_guest()will fault.Continuations would address the concern, but it doesn't seem like their use is really warranted here.
It depends. I have one server I have to hand looks like:
[root@mpx1 ~]# lspci | wc -l
1759
(And I believe this one isn't fully populated with devices.)
A continuation is possibly warranted in a case like this, particularly if an HVM domain is making this hypercall.
~Andrew
PATCH 3/4 sysctl/libxl: Provide information about IO topology
In reply to Boris OstrovskyAdd support to XEN_SYSCTL_topologyinfo to return IO topology data.
Modify libxl_get_topology() to request this data, provide OS-dependent helper functions that determine which devices we are inquiring about (Linux only).
--- tools/libxl/libxl.c | 28 ++++++++++++++++- tools/libxl/libxl_freebsd.c | 12 +++++++ tools/libxl/libxl_internal.h | 5 +++ tools/libxl/libxl_linux.c | 74 ++++++++++++++++++++++++++++++++++++++++++++ tools/libxl/libxl_netbsd.c | 12 +++++++ tools/libxl/xl_cmdimpl.c | 31 ++++++++++++++----- xen/common/sysctl.c | 30 ++++++++++++++++++ 7 files changed, 183 insertions(+), 9 deletions(-)
tools/libxl/libxl.c +27 -1
@@ -5086,6 +5086,7 @@ libxl_topology *libxl_get_topology(libxl_ctx *ctx)GC_INIT (ctx);xc_topologyinfo_t tinfo;DECLARE_HYPERCALL_BUFFER (xen_sysctl_cputopo_t, cputopo); +DECLARE_HYPERCALL_BUFFER (xen_sysctl_iotopo_t, iotopo);libxl_topology *ret =NULL ;int i;int max_cpus;
@@ -5108,7 +5109,20 @@ libxl_topology *libxl_get_topology(libxl_ctx *ctx)set_xen_guest_handle (tinfo.cputopo, cputopo); tinfo.max_cpu_index = max_cpus -1 ; -set_xen_guest_handle (tinfo.iotopo,HYPERCALL_BUFFER_NULL ); + tinfo.max_devs =libxl_pci_numdevs (ctx); +if (tinfo.max_devs >0 ) { + iotopo =xc_hypercall_buffer_alloc (ctx->xch, iotopo, +sizeof (*iotopo) * tinfo.max_devs); +if (iotopo !=NULL ) { +if (libxl_pci_topology_init (ctx, iotopo, tinfo.max_devs)) + tinfo.max_devs =0 ; + }else + tinfo.max_devs =0 ; + } +if (tinfo.max_devs >0 ) +set_xen_guest_handle (tinfo.iotopo, iotopo); +else +set_xen_guest_handle (tinfo.iotopo,HYPERCALL_BUFFER_NULL );if (xc_topologyinfo (ctx->xch, &tinfo) !=0 ) {LIBXL__LOG_ERRNO (ctx,XTL_ERROR ,"Topology info hypercall failed" );
@@ -5128,8 +5142,20 @@ libxl_topology *libxl_get_topology(libxl_ctx *ctx)#undef V } + ret->dev_num = tinfo.max_devs; + ret->dev =libxl__zalloc (NOGC ,sizeof (libxl_iotopology) * ret->dev_num); + +for (i =0 ; i < tinfo.max_devs; i++) { + ret->dev[i].seg = iotopo[i].seg; + ret->dev[i].bus = iotopo[i].bus; + ret->dev[i].devfn = iotopo[i].devfn; + ret->dev[i].node = (iotopo[i].node ==INVALID_TOPOLOGY_ID ) ? +LIBXL_TOPOLOGY_INVALID_ENTRY : iotopo[i].node; + } + fail:xc_hypercall_buffer_free (ctx->xch, cputopo); +xc_hypercall_buffer_free (ctx->xch, iotopo); out:GC_FREE ;
tools/libxl/libxl_freebsd.c +12 -0
@@ -131,3 +131,15 @@ libxl_device_model_version libxl__default_device_model(libxl__gc *gc) {return LIBXL_DEVICE_MODEL_VERSION_QEMU_XEN ; } + +int libxl_pci_numdevs (libxl_ctx *ctx) +{ +return ERROR_NI ; +} + +int libxl_pci_topology_init (libxl_ctx *ctx, +xen_sysctl_iotopo_t *iotopo, +int numdev) +{ +return ERROR_NI ; +}
tools/libxl/libxl_internal.h +5 -0
@@ -1168,6 +1168,11 @@ _hidden int libxl__try_phy_backend(mode_t st_mode); _hidden char *libxl__devid_to_localdev(libxl__gc *gc, int devid); +_hidden int libxl_pci_numdevs(libxl_ctx *ctx); +_hidden int libxl_pci_topology_init(libxl_ctx *ctx, +xen_sysctl_iotopo_t *iotopo, +int numdev); +/* from libxl_pci */ _hidden int libxl__device_pci_add(libxl__gc *gc, uint32_t domid, libxl_device_pci *pcidev, int starting);
tools/libxl/libxl_linux.c +74 -0
77 lines not on this page · raw message
tools/libxl/libxl_netbsd.c +12 -0
@@ -95,3 +95,15 @@ libxl_device_model_version libxl__default_device_model(libxl__gc *gc) {return LIBXL_DEVICE_MODEL_VERSION_QEMU_XEN_TRADITIONAL ; } + +int libxl_pci_numdevs (libxl_ctx *ctx) +{ +return ERROR_NI ; +} + +int libxl_pci_topology_init (libxl_ctx *ctx, +xen_sysctl_iotopo_t *iotopo, +int numdev) +{ +return ERROR_NI ; +}
tools/libxl/xl_cmdimpl.c +23 -8
@@ -5186,25 +5186,40 @@ static void output_numainfo(void)static void output_topologyinfo (void ) { -libxl_cputopology *info; -int i, nr; +libxl_topology *info; +int i, valid_devs =0 ; - info =libxl_get_cpu_topology (ctx, &nr); + info =libxl_get_topology (ctx);if (info ==NULL ) { -fprintf (stderr,"libxl_get_topologyinfo failed.\n" ); +fprintf (stderr,"libxl_get_topology failed.\n" );return ; }printf ("cpu_topology :\n" );printf ("cpu: core socket node\n" ); -for (i =0 ; i < nr; i++) { -if (info[i].core !=LIBXL_CPUTOPOLOGY_INVALID_ENTRY ) +for (i =0 ; i < info->cpu_num; i++) { +if (info->cpu[i].core !=LIBXL_CPUTOPOLOGY_INVALID_ENTRY )printf ("%3d: %4d %4d %4d\n" , i, - info[i].core, info[i].socket, info[i].node); + info->cpu[i].core, info->cpu[i].socket, info->cpu[i].node); } -libxl_cputopology_list_free (info, nr); +printf ("device topology :\n" ); +printf ("device node\n" ); +for (i =0 ; i < info->dev_num; i++) { +libxl_iotopology *dev = &info->dev[i]; + +if (dev->node !=LIBXL_TOPOLOGY_INVALID_ENTRY ) { +printf ("%04x:%02x:%02x.%01x %d\n" , dev->seg, dev->bus, + ((dev->devfn >>3 ) &0x1f ), (dev->devfn &7 ), dev->node); + valid_devs++; + } + } + +if (valid_devs ==0 ) +printf (" No device topology data available\n" ); + +libxl_topology_free (info);return ; }
xen/common/sysctl.c +30 -0
@@ -328,6 +328,7 @@ long do_sysctl(XEN_GUEST_HANDLE_PARAM(xen_sysctl_t) u_sysctl) last_online_cpu =cpumask_last (&cpu_online_map); max_cpu_index =min_t (uint32_t, ti->max_cpu_index, last_online_cpu); +/* CPU topology buffers should always be provided */ if (guest_handle_is_null (ti->cputopo) ) { ret = -EINVAL ;
@@ -362,6 +363,35 @@ long do_sysctl(XEN_GUEST_HANDLE_PARAM(xen_sysctl_t) u_sysctl) u.topologyinfo.max_cpu_index) ) ret = -EFAULT ; } + +if ( !ret && !guest_handle_is_null (ti->iotopo) ) + { +for ( i =0 ; i < ti->max_devs; i++ ) + { +xen_sysctl_iotopo_t iotopo; +struct pci_dev *pdev; + +if (copy_from_guest_offset (&iotopo, ti->iotopo, i,1 ) ) + { + ret = -EFAULT ; +break ; + } + +spin_lock (&pcidevs_lock); + pdev =pci_get_pdev (iotopo.seg, iotopo.bus, iotopo.devfn); +if ( !pdev || (pdev->node ==NUMA_NO_NODE ) ) + iotopo.node =INVALID_TOPOLOGY_ID ; +else + iotopo.node = pdev->node; +spin_unlock (&pcidevs_lock); + +if (copy_to_guest_offset (ti->iotopo, i, &iotopo,1 ) ) + { + ret = -EFAULT ; +break ; + } + } + } }break ;
Signature · 1 line
1.8.4.2
Re: [PATCH 3/4] sysctl/libxl: Provide information about IO topology
tools/libxl/libxl_internal.h _hidden int libxl__try_phy_backend(mode_t st_mode); · line 1175
Quoted 11 lines · Boris Ostrovsky
tools/libxl/libxl_internal.h +5
-0@@ -1168,6 +1168,11 @@ _hidden int libxl__try_phy_backend(mode_t st_mode); _hidden char *libxl__devid_to_localdev(libxl__gc *gc, int devid); +_hidden int libxl_pci_numdevs(libxl_ctx *ctx); +_hidden int libxl_pci_topology_init(libxl_ctx *ctx, +xen_sysctl_iotopo_t *iotopo, +int numdev); +
IIRC, internal/hidden function should have libxl__* as prefix.
Regards,
Dario
Signature · 4 lines
<<This happens because I choose it to happen!>> (Raistlin Majere) ----------------------------------------------------------------- Dario Faggioli, Ph.D, http://about.me/dario.faggioli Senior Software Engineer, Citrix Systems R&D Ltd., Cambridge (UK)
_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel
Re: [PATCH 3/4] sysctl/libxl: Provide information about IO topology
Quoted 6 lines · Dario Faggioli
Quoted 4 lines · Boris Ostrovsky
tools/libxl/libxl_internal.h +0
-0@@ -1168,6 +1168,11 @@ _hidden int libxl__try_phy_backend(mode_t st_mode);
Quoted 8 lines
tools/libxl/libxl_internal.h _hidden int libxl__try_phy_backend(mode_t st_mode); · line 1175
Quoted 7 lines
tools/libxl/libxl_internal.h +5
-0_hidden char *libxl__devid_to_localdev(libxl__gc *gc, int devid); +_hidden int libxl_pci_numdevs(libxl_ctx *ctx); +_hidden int libxl_pci_topology_init(libxl_ctx *ctx, +xen_sysctl_iotopo_t *iotopo, +int numdev); +IIRC, internal/hidden function should have libxl__* as prefix.
And, generally, take a gc instead of a ctx.
Re: [PATCH 3/4] sysctl/libxl: Provide information about IO topology
In reply to Boris Ostrovskyxen/common/sysctl.c long do_sysctl(XEN_GUEST_HANDLE_PARAM(xen_sysctl_t) u_sysctl) · line 369
Quoted 9 lines
Quoted 1 line
Quoted 1 line · On 02.12.14 at 22:34, <[email protected]> wrote:
xen/common/sysctl.c +4
-0@@ -362,6 +363,35 @@ long do_sysctl(XEN_GUEST_HANDLE_PARAM(xen_sysctl_t) u_sysctl) u.topologyinfo.max_cpu_index) ) ret = -EFAULT ; } + +if ( !ret && !guest_handle_is_null (ti->iotopo) ) + { +for ( i =0 ; i < ti->max_devs; i++ )
Careful about long running loops here please.
Jan
Quoted 30 lines
xen/common/sysctl.c +25
-0+ { +xen_sysctl_iotopo_t iotopo; +struct pci_dev *pdev; + +if (copy_from_guest_offset (&iotopo, ti->iotopo, i,1 ) ) + { + ret = -EFAULT ; +break ; + } + +spin_lock (&pcidevs_lock); + pdev =pci_get_pdev (iotopo.seg, iotopo.bus, iotopo.devfn); +if ( !pdev || (pdev->node ==NUMA_NO_NODE ) ) + iotopo.node =INVALID_TOPOLOGY_ID ; +else + iotopo.node = pdev->node; +spin_unlock (&pcidevs_lock); + +if (copy_to_guest_offset (ti->iotopo, i, &iotopo,1 ) ) + { + ret = -EFAULT ; +break ; + } + } + } }break ;Signature · 1 line
1.8.4.2
PATCH 4/4 libxl: Switch to using new topology interface
In reply to Boris OstrovskyMake current users of libxl_get_cpu_topology() call libxl_get_topology() instead.
--- tools/libxl/libxl.c | 25 ++++++++++++------------- tools/libxl/libxl_numa.c | 14 +++++++------- tools/libxl/libxl_utils.c | 24 ++++++++++++------------ tools/libxl/xl_cmdimpl.c | 44 +++++++++++++++++++++----------------------- 4 files changed, 52 insertions(+), 55 deletions(-)
tools/libxl/libxl.c +12 -13
@@ -6410,30 +6410,29 @@ int libxl_cpupool_cpuadd(libxl_ctx *ctx, uint32_t poolid, int cpu)int libxl_cpupool_cpuadd_node (libxl_ctx *ctx,uint32_t poolid,int node,int *cpus) {int rc =0 ; -int cpu, nr; +int cpu;libxl_bitmap freemap; -libxl_cputopology *topology; +libxl_topology *topology;if (libxl_get_freecpus (ctx, &freemap)) {return ERROR_FAIL ; } - topology =libxl_get_cpu_topology (ctx, &nr); + topology =libxl_get_topology (ctx);if (!topology) { rc =ERROR_FAIL ; goto out; } *cpus =0 ; -for (cpu =0 ; cpu < nr; cpu++) { -if (libxl_bitmap_test (&freemap, cpu) && (topology[cpu].node == node) && +for (cpu =0 ; cpu < topology->cpu_num; cpu++) { +if (libxl_bitmap_test (&freemap, cpu) && (topology->cpu[cpu].node == node) && !libxl_cpupool_cpuadd (ctx, poolid, cpu)) { (*cpus)++; } -libxl_cputopology_dispose (&topology[cpu]); } -free (topology); +libxl_topology_free (topology); out:libxl_bitmap_dispose (&freemap);return rc;
@@ -6457,8 +6456,8 @@ int libxl_cpupool_cpuremove_node(libxl_ctx *ctx, uint32_t poolid, int node, intint ret =0 ;int n_pools;int p; -int cpu, nr_cpus; -libxl_cputopology *topology; +int cpu; +libxl_topology *topology;libxl_cpupoolinfo *poolinfo; poolinfo =libxl_list_cpupool (ctx, &n_pools);
@@ -6466,7 +6465,7 @@ int libxl_cpupool_cpuremove_node(libxl_ctx *ctx, uint32_t poolid, int node, intreturn ERROR_NOMEM ; } - topology =libxl_get_cpu_topology (ctx, &nr_cpus); + topology =libxl_get_topology (ctx);if (!topology) { ret =ERROR_FAIL ; goto out;
@@ -6475,8 +6474,8 @@ int libxl_cpupool_cpuremove_node(libxl_ctx *ctx, uint32_t poolid, int node, int *cpus =0 ;for (p =0 ; p < n_pools; p++) {if (poolinfo[p].poolid == poolid) { -for (cpu =0 ; cpu < nr_cpus; cpu++) { -if ((topology[cpu].node == node) && +for (cpu =0 ; cpu < topology->cpu_num; cpu++) { +if ((topology->cpu[cpu].node == node) &&libxl_bitmap_test (&poolinfo[p].cpumap, cpu) && !libxl_cpupool_cpuremove (ctx, poolid, cpu)) { (*cpus)++;
@@ -6485,7 +6484,7 @@ int libxl_cpupool_cpuremove_node(libxl_ctx *ctx, uint32_t poolid, int node, int } } -libxl_cputopology_list_free (topology, nr_cpus); +libxl_topology_free (topology); out:libxl_cpupoolinfo_list_free (poolinfo, n_pools);
tools/libxl/libxl_numa.c +7 -7
@@ -293,9 +293,9 @@ int libxl__get_numa_candidate(libxl__gc *gc, int *cndt_found) {libxl__numa_candidate new_cndt; -libxl_cputopology *tinfo =NULL ; +libxl_topology *tinfo =NULL ;libxl_numainfo *ninfo =NULL ; -int nr_nodes =0 , nr_suit_nodes, nr_cpus =0 ; +int nr_nodes =0 , nr_suit_nodes;libxl_bitmap suitable_nodemap, nodemap;int *vcpus_on_node, rc =0 ;
@@ -341,7 +341,7 @@ int libxl__get_numa_candidate(libxl__gc *gc, goto out; } - tinfo =libxl_get_cpu_topology (CTX , &nr_cpus); + tinfo =libxl_get_topology (CTX );if (tinfo ==NULL ) { rc =ERROR_FAIL ; goto out;
@@ -372,7 +372,7 @@ int libxl__get_numa_candidate(libxl__gc *gc,* all we have to do later is summing up the right elements of the * vcpus_on_node array. */ - rc =nr_vcpus_on_nodes (gc, tinfo, nr_cpus, suitable_cpumap, vcpus_on_node); + rc =nr_vcpus_on_nodes (gc, tinfo->cpu, tinfo->cpu_num, suitable_cpumap, vcpus_on_node);if (rc) goto out;
@@ -387,7 +387,7 @@ int libxl__get_numa_candidate(libxl__gc *gc,if (!min_nodes) {int cpus_per_node; - cpus_per_node =count_cpus_per_node (tinfo, nr_cpus, nr_nodes); + cpus_per_node =count_cpus_per_node (tinfo->cpu, tinfo->cpu_num, nr_nodes);if (cpus_per_node ==0 ) min_nodes =1 ;else
@@ -451,7 +451,7 @@ int libxl__get_numa_candidate(libxl__gc *gc,continue ;/* And the same applies if this combination is short in cpus */ - nodes_cpus =nodemap_to_nr_cpus (tinfo, nr_cpus, suitable_cpumap, + nodes_cpus =nodemap_to_nr_cpus (tinfo->cpu, tinfo->cpu_num, suitable_cpumap, &nodemap);if (min_cpus && nodes_cpus < min_cpus)continue ;
@@ -503,7 +503,7 @@ int libxl__get_numa_candidate(libxl__gc *gc,libxl_bitmap_dispose (&suitable_nodemap);libxl__numa_candidate_dispose (&new_cndt);libxl_numainfo_list_free (ninfo, nr_nodes); -libxl_cputopology_list_free (tinfo, nr_cpus); +libxl_topology_free (tinfo);return rc; }
tools/libxl/libxl_utils.c +12 -12
@@ -751,22 +751,22 @@ int libxl_nodemap_to_cpumap(libxl_ctx *ctx,const libxl_bitmap *nodemap, libxl_bitmap *cpumap) { - libxl_cputopology *tinfo = NULL; -int nr_cpus =0 , i, rc =0 ; + libxl_topology *tinfo = NULL; +int i, rc =0 ; - tinfo =libxl_get_cpu_topology (ctx, &nr_cpus); + tinfo =libxl_get_topology (ctx);if (tinfo ==NULL ) { rc =ERROR_FAIL ; goto out; }libxl_bitmap_set_none (cpumap); -for (i =0 ; i < nr_cpus; i++) { -if (libxl_bitmap_test (nodemap, tinfo[i].node)) +for (i =0 ; i < tinfo->cpu_num; i++) { +if (libxl_bitmap_test (nodemap, tinfo->cpu[i].node))libxl_bitmap_set (cpumap, i); } out: -libxl_cputopology_list_free (tinfo, nr_cpus); +libxl_topology_free (tinfo);return rc; }
@@ -796,10 +796,10 @@ int libxl_cpumap_to_nodemap(libxl_ctx *ctx,const libxl_bitmap *cpumap, libxl_bitmap *nodemap) { - libxl_cputopology *tinfo = NULL; -int nr_cpus =0 , i, rc =0 ; + libxl_topology *tinfo = NULL; +int i, rc =0 ; - tinfo =libxl_get_cpu_topology (ctx, &nr_cpus); + tinfo =libxl_get_topology (ctx);if (tinfo ==NULL ) { rc =ERROR_FAIL ; goto out;
@@ -807,12 +807,12 @@ int libxl_cpumap_to_nodemap(libxl_ctx *ctx,libxl_bitmap_set_none (nodemap);libxl_for_each_set_bit (i, *cpumap) { -if (i >= nr_cpus) +if (i >= tinfo->cpu_num)break ; -libxl_bitmap_set (nodemap, tinfo[i].node); +libxl_bitmap_set (nodemap, tinfo->cpu[i].node); } out: -libxl_cputopology_list_free (tinfo, nr_cpus); +libxl_topology_free (tinfo);return rc; }
tools/libxl/xl_cmdimpl.c +21 -23
123 lines not on this page · raw message
Signature · 1 line
1.8.4.2