Make --enable-hwloc and --enable-linux-affinity mutual exclusive

They can not be supported both at the same time.
Fail configure step instead of silently only use hwloc.
This commit is contained in:
Christian Göttsche 2020-09-08 16:25:22 +02:00
parent f4bb50294a
commit 005c4d1f23
3 changed files with 41 additions and 27 deletions

View File

@ -12,11 +12,11 @@ jobs:
- name: Bootstrap - name: Bootstrap
run: ./autogen.sh run: ./autogen.sh
- name: Configure - name: Configure
run: ./configure --enable-werror run: ./configure --enable-werror --enable-linux-affinity
- name: Build - name: Build
run: make run: make
- name: Distcheck - name: Distcheck
run: make distcheck DISTCHECK_CONFIGURE_FLAGS=--enable-werror run: make distcheck DISTCHECK_CONFIGURE_FLAGS="--enable-werror --enable-linux-affinity"
build-ubuntu-clang-latest: build-ubuntu-clang-latest:
runs-on: ubuntu-latest runs-on: ubuntu-latest
@ -34,11 +34,11 @@ jobs:
- name: Bootstrap - name: Bootstrap
run: ./autogen.sh run: ./autogen.sh
- name: Configure - name: Configure
run: ./configure --enable-werror run: ./configure --enable-werror --enable-linux-affinity
- name: Build - name: Build
run: make run: make
- name: Distcheck - name: Distcheck
run: make distcheck DISTCHECK_CONFIGURE_FLAGS=--enable-werror run: make distcheck DISTCHECK_CONFIGURE_FLAGS="--enable-werror --enable-linux-affinity"
build-ubuntu-latest-full-featured: build-ubuntu-latest-full-featured:
runs-on: ubuntu-latest runs-on: ubuntu-latest
@ -49,11 +49,11 @@ jobs:
- name: Bootstrap - name: Bootstrap
run: ./autogen.sh run: ./autogen.sh
- name: Configure - name: Configure
run: ./configure --enable-werror --enable-openvz --enable-cgroup --enable-vserver --enable-ancient-vserver --enable-taskstats --enable-unicode --enable-linux-affinity --enable-hwloc --enable-setuid --enable-delayacct run: ./configure --enable-werror --enable-openvz --enable-cgroup --enable-vserver --enable-ancient-vserver --enable-taskstats --enable-unicode --enable-hwloc --enable-setuid --enable-delayacct
- name: Build - name: Build
run: make run: make
- name: Distcheck - name: Distcheck
run: make distcheck DISTCHECK_CONFIGURE_FLAGS='--enable-werror --enable-openvz --enable-cgroup --enable-vserver --enable-ancient-vserver --enable-taskstats --enable-unicode --enable-linux-affinity --enable-hwloc --enable-setuid --enable-delayacct' run: make distcheck DISTCHECK_CONFIGURE_FLAGS='--enable-werror --enable-openvz --enable-cgroup --enable-vserver --enable-ancient-vserver --enable-taskstats --enable-unicode --enable-hwloc --enable-setuid --enable-delayacct'
whitespace_check: whitespace_check:
runs-on: ubuntu-latest runs-on: ubuntu-latest

View File

@ -11,6 +11,10 @@ in the source distribution for its full text.
#include "Process.h" #include "Process.h"
#include "ProcessList.h" #include "ProcessList.h"
#if defined(HAVE_LIBHWLOC) && defined(HAVE_LINUX_AFFINITY)
#error hwlock and linux affinity are mutual exclusive.
#endif
typedef struct Affinity_ { typedef struct Affinity_ {
ProcessList* pl; ProcessList* pl;
int size; int size;

View File

@ -214,33 +214,43 @@ if test "$my_htop_platform" = "solaris"; then
AC_CHECK_LIB([malloc], [free], [], [missing_libraries="$missing_libraries libmalloc"]) AC_CHECK_LIB([malloc], [free], [], [missing_libraries="$missing_libraries libmalloc"])
fi fi
AC_ARG_ENABLE(linux_affinity, [AS_HELP_STRING([--enable-linux-affinity], [enable Linux sched_setaffinity and sched_getaffinity for affinity support, disables hwloc])], ,enable_linux_affinity="yes") AC_ARG_ENABLE(hwloc, [AS_HELP_STRING([--enable-hwloc], [enable hwloc support for CPU affinity, disables Linux affinity])],, enable_hwloc="no")
if test "x$enable_linux_affinity" = xyes; then if test "x$enable_hwloc" = xyes
AC_MSG_CHECKING([for usable sched_setaffinity]) then
AC_RUN_IFELSE([ AC_CHECK_LIB([hwloc], [hwloc_get_proc_cpubind], [], [missing_libraries="$missing_libraries libhwloc"])
AC_LANG_PROGRAM([[ AC_CHECK_HEADERS([hwloc.h],[:], [missing_headers="$missing_headers $ac_header"])
#include <sched.h> fi
#include <errno.h>
static cpu_set_t cpuset; AC_ARG_ENABLE(linux_affinity, [AS_HELP_STRING([--enable-linux-affinity], [enable Linux sched_setaffinity and sched_getaffinity for affinity support, conflicts with hwloc])], ,enable_linux_affinity="check")
]], [[ if test "x$enable_linux_affinity" = xcheck; then
CPU_ZERO(&cpuset); if test "x$enable_hwloc" = xyes; then
sched_setaffinity(0, sizeof(cpu_set_t), &cpuset); enable_linux_affinity=no
if (errno == ENOSYS) return 1; else
]])], AC_MSG_CHECKING([for usable sched_setaffinity])
[AC_MSG_RESULT([yes])], AC_RUN_IFELSE([
[enable_linux_affinity=no AC_LANG_PROGRAM([[
AC_MSG_RESULT([no])], #include <sched.h>
[AC_MSG_RESULT([yes (assumed while cross compiling)])]) #include <errno.h>
static cpu_set_t cpuset;
]], [[
CPU_ZERO(&cpuset);
sched_setaffinity(0, sizeof(cpu_set_t), &cpuset);
if (errno == ENOSYS) return 1;
]])],
[enable_linux_affinity=yes
AC_MSG_RESULT([yes])],
[enable_linux_affinity=no
AC_MSG_RESULT([no])],
[AC_MSG_RESULT([yes (assumed while cross compiling)])])
fi
fi fi
if test "x$enable_linux_affinity" = xyes; then if test "x$enable_linux_affinity" = xyes; then
AC_DEFINE(HAVE_LINUX_AFFINITY, 1, [Define if Linux sched_setaffinity and sched_getaffinity are to be used.]) AC_DEFINE(HAVE_LINUX_AFFINITY, 1, [Define if Linux sched_setaffinity and sched_getaffinity are to be used.])
fi fi
AC_ARG_ENABLE(hwloc, [AS_HELP_STRING([--enable-hwloc], [enable hwloc support for CPU affinity])],, enable_hwloc="no") if test "x$enable_linux_affinity" = xyes -a "x$enable_hwloc" = xyes
if test "x$enable_hwloc" = xyes
then then
AC_CHECK_LIB([hwloc], [hwloc_get_proc_cpubind], [], [missing_libraries="$missing_libraries libhwloc"]) AC_MSG_ERROR([--enable-hwloc and --enable-linux-affinity are mutual exclusive. Specify at most one of them.])
AC_CHECK_HEADERS([hwloc.h],[:], [missing_headers="$missing_headers $ac_header"])
fi fi
AC_ARG_ENABLE(setuid, [AS_HELP_STRING([--enable-setuid], [enable setuid support for platforms that need it])],, enable_setuid="no") AC_ARG_ENABLE(setuid, [AS_HELP_STRING([--enable-setuid], [enable setuid support for platforms that need it])],, enable_setuid="no")