Hello,
Here's a new patchset that fixes the remaining problems on my side.
01 is basically the same I sent earlier.
02 and 03 export two core functions to plugins
04 is basically the same I sent earlier, without the hacky #include
<private/private.h> that was waiting for 02-03
05 lets me check that topology-xen.c builds when libxen isn't available
(useful for regression testing all backends when changing internals,
used with "make check -C tests/ports")
The Xen component seems to work fine as a plugin. The Xen lib dependency
is only in the plugin:
$ ldd utils/.libs/lstopo | grep xen
$ ldd src/.libs/libhwloc.so | grep xen
$ ldd src/.libs/hwloc_xen.so | grep xen
libxenctrl-4.3.so => /usr/lib/libxenctrl-4.3.so (0x00007f3de693c000)
You can try with
make && make install && HWLOC_XEN=1 utils/lstopo
Add HWLOC_PLUGINS_VERBOSE for details about plugins being loaded. And
HWLOC_COMPONENTS_VERBOSE for details components being enabled or not.
A couple comments below.
Le 01/01/2014 22:47, Andrew Cooper a écrit :
> At the moment, my list of activities is:
> * See about getting plugins working (./configure is still wanting to
> build Xen support in, rather than making it a plugin)
> * Get NUMA memory and distances recorded (as the information is already
> available)
> * Get offline cpus working.
>
> I am in two minds about that patch to libxc.
>
> On the one hand, libxenctrl is a fairly lightweight library (no
> dependencies), whose purpose is to be a thin wrapper to basic Xen
> controls. However, it explicitly has an unstable API which is free to
> change in the future, and I can make no guarentee that the API of those
> functions wont change (especially as I have a plan to remove the
> ambiguity between online/offline cpus and their topology location).
Is there a #define that we check to easily detect which API is available
without having multiple API checks in configure?
> The other option which I discounted initially was to use libxenlight.
> libxl explicitly has a stable API (but unstable ABI). It comes with a
> host of dependencies (libxlutil, libxenstore, libxenguest, libyajl,
> libuuid, libbz2, liblzma, libz off the top of my head, and probably more).
According to you, in reality, how often will libxl be installed on
existing platforms, compared to libxc?
> Furthermore, libxc exported the information in the format I wanted to
> consume it in, rather than libxl which translates it to a less useful
> format as part of retrieving the information.
>
> As the Xen part of hwloc is going to be a plugin, using libxl might not
> be so bad, and having a stable API would certainly be good (even if it
> means doing a reverse transform on the information received from libxl).
We won't release hwloc v1.9 before a couple months. You can take some
time to decide. I don't have a strong feeling about this choice.
Brice
commit 518e8916b38da6dcb2a51f147a30a88021e2c11f
Author: Brice Goglin <[email protected]>
List-Post: [email protected]
Date: Mon Jan 6 13:22:47 2014 +0100
tests/ports: add cross-testing
diff --git a/config/hwloc_internal.m4 b/config/hwloc_internal.m4
index 13bb21d..0fd5d05 100644
--- a/config/hwloc_internal.m4
+++ b/config/hwloc_internal.m4
@@ -1,6 +1,6 @@
dnl -*- Autoconf -*-
dnl
-dnl Copyright (c) 2009-2012 Inria. All rights reserved.
+dnl Copyright (c) 2009-2014 Inria. All rights reserved.
dnl Copyright (c) 2009, 2011 Université Bordeaux 1
dnl Copyright (c) 2004-2005 The Trustees of Indiana University and Indiana
dnl University Research and Technology
@@ -420,6 +420,7 @@ int foo(void) {
hwloc_config_prefix[tests/ports/topology-netbsd.c]:hwloc_config_prefix[src/topology-netbsd.c]
hwloc_config_prefix[tests/ports/topology-hpux.c]:hwloc_config_prefix[src/topology-hpux.c]
hwloc_config_prefix[tests/ports/topology-bgq.c]:hwloc_config_prefix[src/topology-bgq.c]
+ hwloc_config_prefix[tests/ports/topology-xen.c]:hwloc_config_prefix[src/topology-xen.c]
hwloc_config_prefix[tests/ports/topology-opencl.c]:hwloc_config_prefix[src/topology-opencl.c]
hwloc_config_prefix[tests/ports/topology-cuda.c]:hwloc_config_prefix[src/topology-cuda.c]
hwloc_config_prefix[tests/ports/topology-nvml.c]:hwloc_config_prefix[src/topology-nvml.c]
diff --git a/tests/ports/Makefile.am b/tests/ports/Makefile.am
index 7bbdbfe..b6cc5c3 100644
--- a/tests/ports/Makefile.am
+++ b/tests/ports/Makefile.am
@@ -1,4 +1,4 @@
-# Copyright © 2009-2012 Inria. All rights reserved.
+# Copyright © 2009-2014 Inria. All rights reserved.
# Copyright © 2009, 2011-2012 Université Bordeaux 1
# Copyright © 2009-2010 Cisco Systems, Inc. All rights reserved.
# See COPYING in top-level directory.
@@ -20,6 +20,7 @@ check_LTLIBRARIES = \
libhwloc-port-osf.la \
libhwloc-port-solaris.la \
libhwloc-port-windows.la \
+ libhwloc-port-xen.la \
libhwloc-port-opencl.la \
libhwloc-port-cuda.la \
libhwloc-port-nvml.la \
@@ -138,6 +139,13 @@ libhwloc_port_windows_la_CPPFLAGS = $(common_CPPFLAGS) \
-DHWLOC_WIN_SYS \
-DHAVE__SC_LARGE_PAGESIZE -D_SC_LARGE_PAGESIZE=33
+nodist_libhwloc_port_xen_la_SOURCES = topology-xen.c
+libhwloc_port_xen_la_SOURCES = \
+ include/xen/xenctrl.h
+libhwloc_port_xen_la_CPPFLAGS = $(common_CPPFLAGS) \
+ -I$(HWLOC_top_srcdir)/tests/ports/include/xen \
+ -DHWLOC_XEN_SYS
+
nodist_libhwloc_port_opencl_la_SOURCES = topology-opencl.c
libhwloc_port_opencl_la_SOURCES = \
include/opencl/CL/cl_ext.h
diff --git a/tests/ports/include/xen/xenctrl.h b/tests/ports/include/xen/xenctrl.h
new file mode 100644
index 0000000..422801e
--- /dev/null
+++ b/tests/ports/include/xen/xenctrl.h
@@ -0,0 +1,31 @@
+/*
+ * Copyright © 2014 Inria. All rights reserved.
+ * See COPYING in top-level directory.
+ */
+
+#ifndef HWLOC_PORT_XEN_XENCTRL_H
+#define HWLOC_PORT_XEN_XENCTRL_H
+
+typedef struct xc_interface_core xc_interface;
+
+xc_interface *xc_interface_open(void *, void *, unsigned);
+int xc_interface_close(xc_interface *);
+
+struct xen_sysctl_physinfo {
+ uint32_t threads_per_core;
+ uint32_t cores_per_socket;
+ uint32_t nr_cpus;
+ uint32_t max_cpu_id;
+ uint32_t nr_nodes;
+ uint32_t max_node_id;
+};
+typedef struct xen_sysctl_physinfo xen_sysctl_physinfo_t;
+typedef xen_sysctl_physinfo_t xc_physinfo_t;
+
+int xc_physinfo(xc_interface *, xc_physinfo_t *);
+
+int xc_topologyinfo_bounced(xc_interface *, uint32_t *, uint32_t *, uint32_t *, uint32_t *);
+
+int xc_numainfo_bounced(xc_interface *, uint32_t *, uint64_t *, uint64_t *, uint32_t *);
+
+#endif /* HWLOC_PORT_XEN_XENCTRL_H */
commit e114b725e35e08def8ec4a48024548067d388fdd
Author: Brice Goglin <[email protected]>
List-Post: [email protected]
Date: Tue Dec 31 16:52:18 2013 +0100
Make xen plugin-able
diff --git a/config/hwloc.m4 b/config/hwloc.m4
index 600d596..75b0702 100644
--- a/config/hwloc.m4
+++ b/config/hwloc.m4
@@ -1,6 +1,6 @@
dnl -*- Autoconf -*-
dnl
-dnl Copyright © 2009-2013 Inria. All rights reserved.
+dnl Copyright © 2009-2014 Inria. All rights reserved.
dnl Copyright (c) 2009-2012 Université Bordeaux 1
dnl Copyright (c) 2004-2005 The Trustees of Indiana University and Indiana
dnl University Research and Technology
@@ -932,6 +932,7 @@ EOF])
AC_DEFINE([HWLOC_HAVE_XEN], [1], [Define to 1 if you have the `XEN' library.])
AC_SUBST([HWLOC_HAVE_XEN], [1])
hwloc_components="$hwloc_components xen"
+ hwloc_xen_component_maybeplugin=1
hwloc_xen=yes
else
AC_SUBST([HWLOC_HAVE_XEN], [0])
@@ -1151,6 +1152,10 @@ EOF])
[HWLOC_LIBS="$HWLOC_LIBS $HWLOC_GL_LIBS"
HWLOC_CFLAGS="$HWLOC_CFLAGS $HWLOC_GL_CFLAGS"
HWLOC_REQUIRES="$HWLOC_GL_REQUIRES $HWLOC_REQUIRES"])
+ AS_IF([test "$hwloc_xen_component" = "static"],
+ [HWLOC_LIBS="$HWLOC_LIBS $HWLOC_XEN_LIBS"
+ HWLOC_CFLAGS="$HWLOC_CFLAGS $HWLOC_XEN_CFLAGS"
+ HWLOC_REQUIRES="$HWLOC_XEN_REQUIRES $HWLOC_REQUIRES"])
AS_IF([test "$hwloc_xml_libxml_component" = "static"],
[HWLOC_LIBS="$HWLOC_LIBS $HWLOC_LIBXML2_LIBS"
HWLOC_CFLAGS="$HWLOC_CFLAGS $HWLOC_LIBXML2_CFLAGS"
@@ -1274,6 +1279,7 @@ AC_DEFUN([HWLOC_DO_AM_CONDITIONALS],[
AM_CONDITIONAL([HWLOC_CUDA_BUILD_STATIC], [test "x$hwloc_cuda_component" = "xstatic"])
AM_CONDITIONAL([HWLOC_NVML_BUILD_STATIC], [test "x$hwloc_nvml_component" = "xstatic"])
AM_CONDITIONAL([HWLOC_GL_BUILD_STATIC], [test "x$hwloc_gl_component" = "xstatic"])
+ AM_CONDITIONAL([HWLOC_XEN_BUILD_STATIC], [test "x$hwloc_xen_component" = "xstatic"])
AM_CONDITIONAL([HWLOC_XML_LIBXML_BUILD_STATIC], [test "x$hwloc_xml_libxml_component" = "xstatic"])
AM_CONDITIONAL([HWLOC_HAVE_CXX], [test "x$hwloc_have_cxx" = "xyes"])
diff --git a/src/Makefile.am b/src/Makefile.am
index 11dd6a2..69b80a0 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -1,4 +1,4 @@
-# Copyright © 2009-2013 Inria. All rights reserved.
+# Copyright © 2009-2014 Inria. All rights reserved.
# Copyright © 2009-2012 Université Bordeaux 1
# Copyright © 2009-2010 Cisco Systems, Inc. All rights reserved.
# Copyright © 2011-2012 Oracle and/or its affiliates. All rights reserved.
@@ -162,8 +162,14 @@ sources += topology-x86.c
endif HWLOC_HAVE_CPUID
if HWLOC_HAVE_XEN
+if HWLOC_XEN_BUILD_STATIC
sources += topology-xen.c
-ldflags += $(HWLOC_XEN_LIBS)
+else
+plugins_LTLIBRARIES += hwloc_xen.la
+hwloc_xen_la_SOURCES = topology-xen.c
+hwloc_xen_la_CFLAGS = $(AM_CFLAGS) $(HWLOC_XEN_CFLAGS) -DHWLOC_INSIDE_PLUGIN
+hwloc_xen_la_LDFLAGS = $(plugins_ldflags) $(HWLOC_XEN_LIBS)
+endif
endif HWLOC_HAVE_XEN
if HWLOC_HAVE_GCC
diff --git a/src/topology-xen.c b/src/topology-xen.c
index c0b416a..3c7d688 100644
--- a/src/topology-xen.c
+++ b/src/topology-xen.c
@@ -4,8 +4,12 @@
*/
#include <private/autogen/config.h>
-#include <private/private.h>
#include <hwloc.h>
+#include <hwloc/plugins.h>
+
+/* private headers allowed for convenience because this plugin is built within hwloc */
+#include <private/debug.h>
+#include <private/misc.h>
#include <inttypes.h>
#include <assert.h>
@@ -156,7 +160,7 @@ hwloc_xen_discover(struct hwloc_backend *backend)
hwloc_bitmap_t each_socket, each_node, each_core;
uint32_t i, z;
- if (topology->levels[0][0]->cpuset)
+ if (hwloc_get_root_obj(topology)->cpuset)
return 0;
hwloc_debug("Discovering Xen topology\n");
@@ -258,7 +262,7 @@ hwloc_xen_discover(struct hwloc_backend *backend)
hwloc_bitmap_free(each_node);
- hwloc_obj_add_info(topology->levels[0][0], "Backend", "Xen");
+ hwloc_obj_add_info(hwloc_get_root_obj(topology), "Backend", "Xen");
free_xen_info(data);
@@ -336,6 +340,10 @@ static struct hwloc_disc_component hwloc_xen_disc_component = {
NULL
};
+#ifdef HWLOC_INSIDE_PLUGIN
+HWLOC_DECLSPEC extern const struct hwloc_component hwloc_xen_component;
+#endif
+
const struct hwloc_component hwloc_xen_component = {
HWLOC_COMPONENT_ABI,
HWLOC_COMPONENT_TYPE_DISC,
commit d454aeb932a6973ca818ee351e845d540d9d481e
Author: Brice Goglin <[email protected]>
List-Post: [email protected]
Date: Mon Jan 6 13:09:19 2014 +0100
plugins: cleanup hwloc_setup_pu_level() and export it to plugins
Xen needs it.
diff --git a/NEWS b/NEWS
index 5e0d78a..8b136f5 100644
--- a/NEWS
+++ b/NEWS
@@ -29,7 +29,8 @@ Version 1.9.0
or Sockets instead of Caches when possible.
+ Add -e as a synonym to --get-last-cpu-location in hwloc-bind.
* Plugins
- + Add the new hwloc_alloc_root_sets() function for plugins that discover CPUs.
+ + Add hwloc_alloc_root_sets() and hwloc_setup_pu_level() functions for
+ plugins that discover CPUs.
Version 1.8.0
diff --git a/include/hwloc/plugins.h b/include/hwloc/plugins.h
index 964da66..52db2e3 100644
--- a/include/hwloc/plugins.h
+++ b/include/hwloc/plugins.h
@@ -311,6 +311,12 @@ HWLOC_DECLSPEC int hwloc_fill_object_sets(hwloc_obj_t obj);
*/
HWLOC_DECLSPEC int hwloc_alloc_root_sets(struct hwloc_topology *topology);
+/** \brief Create a level of \p nb PU objects starting from index 0.
+ *
+ * Used for creating PU objects when there are no holes in the index list.
+ */
+HWLOC_DECLSPEC int hwloc_setup_pu_level(struct hwloc_topology *topology, unsigned nb);
+
/** \brief Insert a list of PCI devices and bridges in the backend topology.
*
* Insert a list of objects (either PCI device or bridges) starting at first_obj
diff --git a/include/hwloc/rename.h b/include/hwloc/rename.h
index 424a3e9..4f682e5 100644
--- a/include/hwloc/rename.h
+++ b/include/hwloc/rename.h
@@ -486,6 +486,7 @@ extern "C" {
#define hwloc_alloc_setup_object HWLOC_NAME(alloc_setup_object)
#define hwloc_fill_object_sets HWLOC_NAME(fill_object_sets)
#define hwloc_alloc_root_sets HWLOC_NAME(alloc_root_sets)
+#define hwloc_setup_pu_level HWLOC_NAME(setup_pu_level)
#define hwloc_insert_pci_device_list HWLOC_NAME(insert_pci_device_list)
#define hwloc_pci_find_cap HWLOC_NAME(pci_find_cap)
diff --git a/include/private/private.h b/include/private/private.h
index 3c28683..5fb268c 100644
--- a/include/private/private.h
+++ b/include/private/private.h
@@ -128,7 +128,6 @@ struct hwloc_topology {
struct hwloc_backend * backends;
};
-extern void hwloc_setup_pu_level(struct hwloc_topology *topology, unsigned nb_pus);
extern int hwloc_get_sysctlbyname(const char *name, int64_t *n);
extern int hwloc_get_sysctl(int name[], unsigned namelen, int *n);
extern unsigned hwloc_fallback_nbprocessors(struct hwloc_topology *topology);
diff --git a/src/topology.c b/src/topology.c
index 8a45b9b..cee7526 100644
--- a/src/topology.c
+++ b/src/topology.c
@@ -174,29 +174,28 @@ hwloc_fallback_nbprocessors(struct hwloc_topology *topology) {
}
/*
- * Use the given number of processors and the optional online cpuset if given
- * to set a PU level.
+ * Use the given number of processors to set a PU level.
*/
-void
+int
hwloc_setup_pu_level(struct hwloc_topology *topology,
unsigned nb_pus)
{
struct hwloc_obj *obj;
- unsigned oscpu,cpu;
+ unsigned oscpu;
hwloc_debug("%s", "\n\n * CPU cpusets *\n\n");
- for (cpu=0,oscpu=0; cpu<nb_pus; oscpu++)
+ for (oscpu=0; oscpu<nb_pus; oscpu++)
{
obj = hwloc_alloc_setup_object(HWLOC_OBJ_PU, oscpu);
obj->cpuset = hwloc_bitmap_alloc();
hwloc_bitmap_only(obj->cpuset, oscpu);
- hwloc_debug_2args_bitmap("cpu %u (os %u) has cpuset %s\n",
- cpu, oscpu, obj->cpuset);
+ hwloc_debug_1arg_bitmap("OS cpu %u has cpuset %s\n",
+ oscpu, obj->cpuset);
hwloc_insert_object_by_cpuset(topology, obj);
-
- cpu++;
}
+
+ return 0;
}
static void
commit 5957bcd31d18f44a80c2c100eaff472293261f42
Author: Brice Goglin <[email protected]>
List-Post: [email protected]
Date: Mon Jan 6 12:52:14 2014 +0100
plugins: export hwloc_alloc_root_sets()
Renamed from the old hwloc_alloc_obj_cpusets(),
now officially specialized for root objects only,
and now exported to plugins (Xen will need it).
diff --git a/NEWS b/NEWS
index eec10ea..5e0d78a 100644
--- a/NEWS
+++ b/NEWS
@@ -28,6 +28,8 @@ Version 1.9.0
+ hwloc-ps reports locations as likely-more-useful objects such as Cores
or Sockets instead of Caches when possible.
+ Add -e as a synonym to --get-last-cpu-location in hwloc-bind.
+* Plugins
+ + Add the new hwloc_alloc_root_sets() function for plugins that discover CPUs.
Version 1.8.0
diff --git a/include/hwloc/plugins.h b/include/hwloc/plugins.h
index aa5d993..964da66 100644
--- a/include/hwloc/plugins.h
+++ b/include/hwloc/plugins.h
@@ -1,5 +1,5 @@
/*
- * Copyright © 2013 Inria. All rights reserved.
+ * Copyright © 2013-2014 Inria. All rights reserved.
* See COPYING in top-level directory.
*/
@@ -305,6 +305,12 @@ hwloc_alloc_setup_object(hwloc_obj_type_t type, signed os_index)
*/
HWLOC_DECLSPEC int hwloc_fill_object_sets(hwloc_obj_t obj);
+/** \brief Allocate object CPU and node sets of the root object.
+ *
+ * Used for initializing the root object sets prior to discovering CPUs and NUMA nodes.
+ */
+HWLOC_DECLSPEC int hwloc_alloc_root_sets(struct hwloc_topology *topology);
+
/** \brief Insert a list of PCI devices and bridges in the backend topology.
*
* Insert a list of objects (either PCI device or bridges) starting at first_obj
diff --git a/include/hwloc/rename.h b/include/hwloc/rename.h
index 6266264..424a3e9 100644
--- a/include/hwloc/rename.h
+++ b/include/hwloc/rename.h
@@ -1,6 +1,6 @@
/*
* Copyright © 2009-2011 Cisco Systems, Inc. All rights reserved.
- * Copyright © 2010-2013 Inria. All rights reserved.
+ * Copyright © 2010-2014 Inria. All rights reserved.
* See COPYING in top-level directory.
*/
@@ -485,6 +485,7 @@ extern "C" {
#define hwloc_insert_object_by_parent HWLOC_NAME(insert_object_by_parent)
#define hwloc_alloc_setup_object HWLOC_NAME(alloc_setup_object)
#define hwloc_fill_object_sets HWLOC_NAME(fill_object_sets)
+#define hwloc_alloc_root_sets HWLOC_NAME(alloc_root_sets)
#define hwloc_insert_pci_device_list HWLOC_NAME(insert_pci_device_list)
#define hwloc_pci_find_cap HWLOC_NAME(pci_find_cap)
diff --git a/include/private/private.h b/include/private/private.h
index a9009de..3c28683 100644
--- a/include/private/private.h
+++ b/include/private/private.h
@@ -1,6 +1,6 @@
/*
* Copyright © 2009 CNRS
- * Copyright © 2009-2012 Inria. All rights reserved.
+ * Copyright © 2009-2014 Inria. All rights reserved.
* Copyright © 2009-2012 Université Bordeaux 1
* Copyright © 2009-2011 Cisco Systems, Inc. All rights reserved.
*
@@ -128,7 +128,6 @@ struct hwloc_topology {
struct hwloc_backend * backends;
};
-extern void hwloc_alloc_obj_cpusets(hwloc_obj_t obj);
extern void hwloc_setup_pu_level(struct hwloc_topology *topology, unsigned nb_pus);
extern int hwloc_get_sysctlbyname(const char *name, int64_t *n);
extern int hwloc_get_sysctl(int name[], unsigned namelen, int *n);
diff --git a/src/topology-aix.c b/src/topology-aix.c
index e19faeb..977998f 100644
--- a/src/topology-aix.c
+++ b/src/topology-aix.c
@@ -1,6 +1,6 @@
/*
* Copyright © 2009 CNRS
- * Copyright © 2009-2012 Inria. All rights reserved.
+ * Copyright © 2009-2014 Inria. All rights reserved.
* Copyright © 2009-2011, 2013 Université Bordeaux 1
* Copyright © 2011 Cisco Systems, Inc. All rights reserved.
* See COPYING in top-level directory.
@@ -709,7 +709,7 @@ hwloc_look_aix(struct hwloc_backend *backend)
/* somebody discovered things */
return 0;
- hwloc_alloc_obj_cpusets(topology->levels[0][0]);
+ hwloc_alloc_root_sets(topology);
/* TODO: R_LGPGDEF/R_LGPGFREE for large pages */
diff --git a/src/topology-bgq.c b/src/topology-bgq.c
index 5a2e611..df7186e 100644
--- a/src/topology-bgq.c
+++ b/src/topology-bgq.c
@@ -1,5 +1,5 @@
/*
- * Copyright © 2013 Inria. All rights reserved.
+ * Copyright © 2013-2014 Inria. All rights reserved.
* See COPYING in top-level directory.
*/
@@ -29,7 +29,7 @@ hwloc_look_bgq(struct hwloc_backend *backend)
#define HWLOC_BGQ_CORES 17 /* spare core ignored for now */
- hwloc_alloc_obj_cpusets(topology->levels[0][0]);
+ hwloc_alloc_root_sets(topology);
/* mark the 17th core (OS-reserved) as disallowed */
hwloc_bitmap_clr_range(topology->levels[0][0]->allowed_cpuset, (HWLOC_BGQ_CORES-1)*4, HWLOC_BGQ_CORES*4-1);
diff --git a/src/topology-darwin.c b/src/topology-darwin.c
index 39e13a3..70e23ee 100644
--- a/src/topology-darwin.c
+++ b/src/topology-darwin.c
@@ -1,6 +1,6 @@
/*
* Copyright © 2009 CNRS
- * Copyright © 2009-2012 Inria. All rights reserved.
+ * Copyright © 2009-2014 Inria. All rights reserved.
* Copyright © 2009-2013 Université Bordeaux 1
* Copyright © 2009-2011 Cisco Systems, Inc. All rights reserved.
* See COPYING in top-level directory.
@@ -43,7 +43,7 @@ hwloc_look_darwin(struct hwloc_backend *backend)
/* somebody discovered things */
return 0;
- hwloc_alloc_obj_cpusets(topology->levels[0][0]);
+ hwloc_alloc_root_sets(topology);
if (hwloc_get_sysctlbyname("hw.ncpu", &_nprocs) || _nprocs <= 0)
return -1;
diff --git a/src/topology-freebsd.c b/src/topology-freebsd.c
index 7e13ca1..59d5b8b 100644
--- a/src/topology-freebsd.c
+++ b/src/topology-freebsd.c
@@ -1,6 +1,6 @@
/*
* Copyright © 2009 CNRS
- * Copyright © 2009-2013 Inria. All rights reserved.
+ * Copyright © 2009-2014 Inria. All rights reserved.
* Copyright © 2009-2010, 2012 Université Bordeaux 1
* Copyright © 2011 Cisco Systems, Inc. All rights reserved.
* See COPYING in top-level directory.
@@ -182,7 +182,7 @@ hwloc_look_freebsd(struct hwloc_backend *backend)
if (!topology->levels[0][0]->cpuset) {
/* Nobody (even the x86 backend) created objects yet, setup basic objects */
- hwloc_alloc_obj_cpusets(topology->levels[0][0]);
+ hwloc_alloc_root_sets(topology);
hwloc_setup_pu_level(topology, nbprocs);
}
diff --git a/src/topology-hpux.c b/src/topology-hpux.c
index bd84379..91885f3 100644
--- a/src/topology-hpux.c
+++ b/src/topology-hpux.c
@@ -1,6 +1,6 @@
/*
* Copyright © 2009 CNRS
- * Copyright © 2009-2012 Inria. All rights reserved.
+ * Copyright © 2009-2014 Inria. All rights reserved.
* Copyright © 2009-2010, 2013 Université Bordeaux 1
* Copyright © 2011 Cisco Systems, Inc. All rights reserved.
* See COPYING in top-level directory.
@@ -175,7 +175,7 @@ hwloc_look_hpux(struct hwloc_backend *backend)
/* somebody discovered things */
return 0;
- hwloc_alloc_obj_cpusets(topology->levels[0][0]);
+ hwloc_alloc_root_sets(topology);
if (has_numa) {
nbnodes = mpctl(topology->flags & HWLOC_TOPOLOGY_FLAG_WHOLE_SYSTEM ?
diff --git a/src/topology-linux.c b/src/topology-linux.c
index 2841f23..2796ae7 100644
--- a/src/topology-linux.c
+++ b/src/topology-linux.c
@@ -1,6 +1,6 @@
/*
* Copyright © 2009 CNRS
- * Copyright © 2009-2013 Inria. All rights reserved.
+ * Copyright © 2009-2014 Inria. All rights reserved.
* Copyright © 2009-2013 Université Bordeaux 1
* Copyright © 2009-2011 Cisco Systems, Inc. All rights reserved.
* Copyright © 2010 IBM
@@ -3445,7 +3445,7 @@ hwloc_look_linuxfs(struct hwloc_backend *backend)
/* somebody discovered things */
return 0;
- hwloc_alloc_obj_cpusets(topology->levels[0][0]);
+ hwloc_alloc_root_sets(topology);
/* Gather the list of admin-disabled cpus and mems */
hwloc_find_linux_cpuset_mntpnt(&cgroup_mntpnt, &cpuset_mntpnt, data->root_fd);
diff --git a/src/topology-netbsd.c b/src/topology-netbsd.c
index c88ba87..9988b9e 100644
--- a/src/topology-netbsd.c
+++ b/src/topology-netbsd.c
@@ -1,6 +1,6 @@
/*
* Copyright © 2012 Aleksej Saushev, The NetBSD Foundation
- * Copyright © 2009-2012 Inria. All rights reserved.
+ * Copyright © 2009-2014 Inria. All rights reserved.
* Copyright © 2009-2010 Université Bordeaux 1
* Copyright © 2011 Cisco Systems, Inc. All rights reserved.
* See COPYING in top-level directory.
@@ -138,7 +138,7 @@ hwloc_look_netbsd(struct hwloc_backend *backend)
if (!topology->levels[0][0]->cpuset) {
/* Nobody (even the x86 backend) created objects yet, setup basic objects */
- hwloc_alloc_obj_cpusets(topology->levels[0][0]);
+ hwloc_alloc_root_sets(topology);
hwloc_setup_pu_level(topology, nbprocs);
}
diff --git a/src/topology-noos.c b/src/topology-noos.c
index 8c74ded..c26e981 100644
--- a/src/topology-noos.c
+++ b/src/topology-noos.c
@@ -1,6 +1,6 @@
/*
* Copyright © 2009 CNRS
- * Copyright © 2009-2012 Inria. All rights reserved.
+ * Copyright © 2009-2014 Inria. All rights reserved.
* Copyright © 2009-2012 Université Bordeaux 1
* Copyright © 2009-2011 Cisco Systems, Inc. All rights reserved.
* See COPYING in top-level directory.
@@ -19,7 +19,7 @@ hwloc_look_noos(struct hwloc_backend *backend)
/* somebody discovered things */
return 0;
- hwloc_alloc_obj_cpusets(topology->levels[0][0]);
+ hwloc_alloc_root_sets(topology);
hwloc_setup_pu_level(topology, hwloc_fallback_nbprocessors(topology));
if (topology->is_thissystem)
hwloc_add_uname_info(topology);
diff --git a/src/topology-osf.c b/src/topology-osf.c
index 52300fc..0b3c45e 100644
--- a/src/topology-osf.c
+++ b/src/topology-osf.c
@@ -1,6 +1,6 @@
/*
* Copyright © 2009 CNRS
- * Copyright © 2009-2012 Inria. All rights reserved.
+ * Copyright © 2009-2014 Inria. All rights reserved.
* Copyright © 2009-2011 Université Bordeaux 1
* Copyright © 2011 Cisco Systems, Inc. All rights reserved.
* See COPYING in top-level directory.
@@ -254,7 +254,7 @@ hwloc_look_osf(struct hwloc_backend *backend)
/* somebody discovered things */
return 0;
- hwloc_alloc_obj_cpusets(topology->levels[0][0]);
+ hwloc_alloc_root_sets(topology);
nbnodes = rad_get_num();
diff --git a/src/topology-solaris.c b/src/topology-solaris.c
index fec511d..59decca 100644
--- a/src/topology-solaris.c
+++ b/src/topology-solaris.c
@@ -1,6 +1,6 @@
/*
* Copyright © 2009 CNRS
- * Copyright © 2009-2012 Inria. All rights reserved.
+ * Copyright © 2009-2014 Inria. All rights reserved.
* Copyright © 2009-2011 Université Bordeaux 1
* Copyright © 2011 Cisco Systems, Inc. All rights reserved.
* Copyright © 2011 Oracle and/or its affiliates. All rights reserved.
@@ -726,7 +726,7 @@ hwloc_look_solaris(struct hwloc_backend *backend)
/* somebody discovered things */
return 0;
- hwloc_alloc_obj_cpusets(topology->levels[0][0]);
+ hwloc_alloc_root_sets(topology);
#ifdef HAVE_LIBLGRP
hwloc_look_lgrp(topology);
diff --git a/src/topology-synthetic.c b/src/topology-synthetic.c
index 11c8c33..6120696 100644
--- a/src/topology-synthetic.c
+++ b/src/topology-synthetic.c
@@ -1,6 +1,6 @@
/*
* Copyright © 2009 CNRS
- * Copyright © 2009-2012 Inria. All rights reserved.
+ * Copyright © 2009-2014 Inria. All rights reserved.
* Copyright © 2009-2010 Université Bordeaux 1
* Copyright © 2009-2011 Cisco Systems, Inc. All rights reserved.
* See COPYING in top-level directory.
@@ -352,7 +352,7 @@ hwloc_look_synthetic(struct hwloc_backend *backend)
assert(!topology->levels[0][0]->cpuset);
- hwloc_alloc_obj_cpusets(topology->levels[0][0]);
+ hwloc_alloc_root_sets(topology);
topology->support.discovery->pu = 1;
diff --git a/src/topology-windows.c b/src/topology-windows.c
index 8d811c7..f33d4ec 100644
--- a/src/topology-windows.c
+++ b/src/topology-windows.c
@@ -1,6 +1,6 @@
/*
* Copyright © 2009 CNRS
- * Copyright © 2009-2012 Inria. All rights reserved.
+ * Copyright © 2009-2014 Inria. All rights reserved.
* Copyright © 2009-2012 Université Bordeaux 1
* Copyright © 2011 Cisco Systems, Inc. All rights reserved.
* See COPYING in top-level directory.
@@ -490,7 +490,7 @@ hwloc_look_windows(struct hwloc_backend *backend)
/* somebody discovered things */
return 0;
- hwloc_alloc_obj_cpusets(topology->levels[0][0]);
+ hwloc_alloc_root_sets(topology);
GetSystemInfo(&SystemInfo);
diff --git a/src/topology-x86.c b/src/topology-x86.c
index 9fa0f88..4c72dcc 100644
--- a/src/topology-x86.c
+++ b/src/topology-x86.c
@@ -1,5 +1,5 @@
/*
- * Copyright © 2010-2013 Inria. All rights reserved.
+ * Copyright © 2010-2014 Inria. All rights reserved.
* Copyright © 2010-2013 Université Bordeaux 1
* Copyright © 2010-2011 Cisco Systems, Inc. All rights reserved.
* See COPYING in top-level directory.
@@ -885,7 +885,7 @@ hwloc_x86_discover(struct hwloc_backend *backend)
return 0;
} else {
/* topology is empty, initialize it */
- hwloc_alloc_obj_cpusets(topology->levels[0][0]);
+ hwloc_alloc_root_sets(topology);
}
fulldiscovery:
diff --git a/src/topology-xen.c b/src/topology-xen.c
index 28526fe..c0b416a 100644
--- a/src/topology-xen.c
+++ b/src/topology-xen.c
@@ -180,7 +180,7 @@ hwloc_xen_discover(struct hwloc_backend *backend)
hwloc_debug(" node[%3"PRIu32"], size %"PRIu64", free %"PRIu64"\n",
z, data->node_to_memsize[z], data->node_to_memfree[z]);
- hwloc_alloc_obj_cpusets(topology->levels[0][0]);
+ hwloc_alloc_root_sets(topology);
hwloc_setup_pu_level(topology, data->max_cpu_id+1);
/* Socket information */
diff --git a/src/topology.c b/src/topology.c
index 8afe5a4..8a45b9b 100644
--- a/src/topology.c
+++ b/src/topology.c
@@ -1,6 +1,6 @@
/*
* Copyright © 2009 CNRS
- * Copyright © 2009-2013 Inria. All rights reserved.
+ * Copyright © 2009-2014 Inria. All rights reserved.
* Copyright © 2009-2012 Université Bordeaux 1
* Copyright © 2009-2011 Cisco Systems, Inc. All rights reserved.
* See COPYING in top-level directory.
@@ -2282,8 +2282,9 @@ hwloc_connect_levels(hwloc_topology_t topology)
return 0;
}
-void hwloc_alloc_obj_cpusets(hwloc_obj_t obj)
+int hwloc_alloc_root_sets(hwloc_topology_t topology)
{
+ hwloc_obj_t obj = hwloc_get_root_obj(topology);
obj->cpuset = hwloc_bitmap_alloc_full();
obj->complete_cpuset = hwloc_bitmap_alloc();
obj->online_cpuset = hwloc_bitmap_alloc_full();
@@ -2291,6 +2292,7 @@ void hwloc_alloc_obj_cpusets(hwloc_obj_t obj)
obj->nodeset = hwloc_bitmap_alloc();
obj->complete_nodeset = hwloc_bitmap_alloc();
obj->allowed_nodeset = hwloc_bitmap_alloc_full();
+ return 0;
}
/* Main discovery loop */
commit 26e8b2896cec152643701ea8d8636ed5d561788b
Author: Brice Goglin <[email protected]>
List-Post: [email protected]
Date: Tue Dec 31 19:35:59 2013 +0100
properly abort xen component instantiate if not running as root in dom0
diff --git a/src/topology-xen.c b/src/topology-xen.c
index b74f9f5..28526fe 100644
--- a/src/topology-xen.c
+++ b/src/topology-xen.c
@@ -305,7 +305,10 @@ hwloc_xen_component_instantiate(struct hwloc_disc_component *component,
/* This will fail if we are not running as root in dom0. */
priv->xch = xc_interface_open(NULL, NULL, 0);
- assert(priv->xch && "Are you running as root in dom0?");
+ if (!priv->xch) {
+ hwloc_debug("xc_interface_open() failed, are you running as root in dom0? Disabling xen component.");
+ goto err;
+ }
backend->private_data = priv;
backend->discover = hwloc_xen_discover;
@@ -314,7 +317,7 @@ hwloc_xen_component_instantiate(struct hwloc_disc_component *component,
return backend;
err:
- if (priv->xch)
+ if (priv && priv->xch)
xc_interface_close(priv->xch);
free(priv);
free(backend);