From: Mathieu Desnoyers Date: Sun, 5 Nov 2017 14:01:04 +0000 (-0500) Subject: numa support: allow disabling numa support X-Git-Tag: v2.11.0-rc1~41 X-Git-Url: https://git.lttng.org./?a=commitdiff_plain;h=bfcda6cea270952898ea122c375f2ed19105adef;p=lttng-ust.git numa support: allow disabling numa support Signed-off-by: Mathieu Desnoyers --- diff --git a/configure.ac b/configure.ac index 727e58f3..8a5b6646 100644 --- a/configure.ac +++ b/configure.ac @@ -247,8 +247,21 @@ AC_CHECK_LIB([urcu-bp], [synchronize_rcu_bp], [], [AC_MSG_ERROR([Cannot find lib # urcu - check that URCU lib is at least version 0.6 AC_CHECK_LIB([urcu-bp], [call_rcu_bp], [], [AC_MSG_ERROR([liburcu 0.6 or newer is needed, please update your version or use [LDFLAGS]=-Ldir to specify the right location.])]) -# numa - check that numa lib is available -AC_CHECK_LIB([numa], [numa_available], [], [AC_MSG_ERROR([libnuma is required, please install it (e.g. libnuma-dev) or use [LDFLAGS]=-Ldir to specify the right location.])]) +# numa.h integration +AC_ARG_ENABLE([numa], [ +AS_HELP_STRING([--disable-numa], [disable NUMA support]) +], [ + enable_numa=$enableval +], [ + enable_numa=yes +]) + +AS_IF([test "x$enable_numa" = "xyes"], [ + # numa - check that numa lib is available + AC_CHECK_LIB([numa], [numa_available], [], [AC_MSG_ERROR([libnuma is required, please install it (e.g. libnuma-dev) or use [LDFLAGS]=-Ldir to specify the right location.])]) + have_libnuma=yes +]) +AM_CONDITIONAL([HAVE_LIBNUMA], [test "x$have_libnuma" = "xyes"]) # optional linux/perf_event.h AC_CHECK_HEADERS([linux/perf_event.h], [have_perf_event=yes], []) @@ -570,6 +583,9 @@ PPRINT_PROP_BOOL_CUSTOM([JNI interface (JNI)], $value, [use --enable-jni-interfa test "x$python_agent" = xyes && value=1 || value=0 PPRINT_PROP_BOOL_CUSTOM([Python agent], $value, [use --enable-python-agent]) +test "x$enable_numa" = xyes && value=1 || value=0 +PPRINT_PROP_BOOL([NUMA], $value) + AS_ECHO PPRINT_SET_INDENT(0) diff --git a/libringbuffer/Makefile.am b/libringbuffer/Makefile.am index 34ad6907..c153ea25 100644 --- a/libringbuffer/Makefile.am +++ b/libringbuffer/Makefile.am @@ -15,7 +15,10 @@ libringbuffer_la_SOURCES = \ libringbuffer_la_LIBADD = \ -lpthread \ - -lrt \ - -lnuma + -lrt + +if HAVE_LIBNUMA +libringbuffer_la_LIBADD += -lnuma +endif libringbuffer_la_CFLAGS = -DUST_COMPONENT="libringbuffer" $(AM_CFLAGS) diff --git a/libringbuffer/shm.c b/libringbuffer/shm.c index 135a2007..0153578c 100644 --- a/libringbuffer/shm.c +++ b/libringbuffer/shm.c @@ -19,6 +19,7 @@ */ #define _LGPL_SOURCE +#include #include "shm.h" #include #include @@ -32,7 +33,9 @@ #include #include #include +#ifdef HAVE_LIBNUMA #include +#endif #include #include @@ -247,8 +250,9 @@ struct shm_object *shm_object_table_alloc(struct shm_object_table *table, int stream_fd, int cpu) { - int oldnode, node; struct shm_object *shm_object; +#ifdef HAVE_LIBNUMA + int oldnode, node; oldnode = numa_preferred(); if (cpu >= 0) { @@ -258,6 +262,7 @@ struct shm_object *shm_object_table_alloc(struct shm_object_table *table, } if (cpu < 0 || node < 0) numa_set_localalloc(); +#endif /* HAVE_LIBNUMA */ switch (type) { case SHM_OBJECT_SHM: shm_object = _shm_object_table_alloc_shm(table, memory_map_size, @@ -269,7 +274,9 @@ struct shm_object *shm_object_table_alloc(struct shm_object_table *table, default: assert(0); } +#ifdef HAVE_LIBNUMA numa_set_preferred(oldnode); +#endif /* HAVE_LIBNUMA */ return shm_object; }