mirror of
https://github.com/xzeldon/htop.git
synced 2024-12-23 22:55:46 +00:00
Enable affinity support for non-Linux
sched_getaffinity() and sched_setaffinity() are also available on BSDs. Remove the Linux restraint.
This commit is contained in:
parent
adcedf87f5
commit
1fb0c720fe
8
.github/workflows/ci.yml
vendored
8
.github/workflows/ci.yml
vendored
@ -17,7 +17,7 @@ jobs:
|
||||
- name: Bootstrap
|
||||
run: ./autogen.sh
|
||||
- name: Configure
|
||||
run: ./configure --enable-werror --enable-linux-affinity --disable-unicode --disable-sensors
|
||||
run: ./configure --enable-werror --enable-affinity --disable-unicode --disable-sensors
|
||||
- name: Enable compatibility modes
|
||||
run: |
|
||||
sed -i 's/#define HAVE_FSTATAT 1/#undef HAVE_FSTATAT/g' config.h
|
||||
@ -26,7 +26,7 @@ jobs:
|
||||
- name: Build
|
||||
run: make -k
|
||||
- name: Distcheck
|
||||
run: make distcheck DISTCHECK_CONFIGURE_FLAGS="--enable-werror --enable-linux-affinity --disable-unicode --disable-sensors"
|
||||
run: make distcheck DISTCHECK_CONFIGURE_FLAGS="--enable-werror --enable-affinity --disable-unicode --disable-sensors"
|
||||
|
||||
build-ubuntu-latest-minimal-clang:
|
||||
runs-on: ubuntu-latest
|
||||
@ -44,11 +44,11 @@ jobs:
|
||||
- name: Bootstrap
|
||||
run: ./autogen.sh
|
||||
- name: Configure
|
||||
run: ./configure --enable-werror --enable-linux-affinity --disable-unicode --disable-sensors
|
||||
run: ./configure --enable-werror --enable-affinity --disable-unicode --disable-sensors
|
||||
- name: Build
|
||||
run: make -k
|
||||
- name: Distcheck
|
||||
run: make distcheck DISTCHECK_CONFIGURE_FLAGS="--enable-werror --enable-linux-affinity --disable-unicode --disable-sensors"
|
||||
run: make distcheck DISTCHECK_CONFIGURE_FLAGS="--enable-werror --enable-affinity --disable-unicode --disable-sensors"
|
||||
|
||||
build-ubuntu-latest-full-featured-gcc:
|
||||
runs-on: ubuntu-latest
|
||||
|
11
Action.c
11
Action.c
@ -34,7 +34,7 @@ in the source distribution for its full text.
|
||||
#include "Vector.h"
|
||||
#include "XUtils.h"
|
||||
|
||||
#if (defined(HAVE_LIBHWLOC) || defined(HAVE_LINUX_AFFINITY))
|
||||
#if (defined(HAVE_LIBHWLOC) || defined(HAVE_AFFINITY))
|
||||
#include "Affinity.h"
|
||||
#include "AffinityPanel.h"
|
||||
#endif
|
||||
@ -305,7 +305,7 @@ static Htop_Reaction actionSetAffinity(State* st) {
|
||||
if (st->pl->activeCPUs == 1)
|
||||
return HTOP_OK;
|
||||
|
||||
#if (defined(HAVE_LIBHWLOC) || defined(HAVE_LINUX_AFFINITY))
|
||||
#if (defined(HAVE_LIBHWLOC) || defined(HAVE_AFFINITY))
|
||||
const Process* p = (const Process*) Panel_getSelected((Panel*)st->mainPanel);
|
||||
if (!p)
|
||||
return HTOP_OK;
|
||||
@ -328,8 +328,11 @@ static Htop_Reaction actionSetAffinity(State* st) {
|
||||
Affinity_delete(affinity2);
|
||||
}
|
||||
Object_delete(affinityPanel);
|
||||
#endif
|
||||
return HTOP_REFRESH | HTOP_REDRAW_BAR | HTOP_UPDATE_PANELHDR;
|
||||
#else
|
||||
return HTOP_OK;
|
||||
#endif
|
||||
|
||||
}
|
||||
|
||||
static Htop_Reaction actionKill(State* st) {
|
||||
@ -484,7 +487,7 @@ static const struct {
|
||||
{ .key = " F9 k: ", .roInactive = true, .info = "kill process/tagged processes" },
|
||||
{ .key = " F7 ]: ", .roInactive = true, .info = "higher priority (root only)" },
|
||||
{ .key = " F8 [: ", .roInactive = false, .info = "lower priority (+ nice)" },
|
||||
#if (defined(HAVE_LIBHWLOC) || defined(HAVE_LINUX_AFFINITY))
|
||||
#if (defined(HAVE_LIBHWLOC) || defined(HAVE_AFFINITY))
|
||||
{ .key = " a: ", .roInactive = true, .info = "set CPU affinity" },
|
||||
#endif
|
||||
{ .key = " e: ", .roInactive = false, .info = "show process environment" },
|
||||
|
@ -22,7 +22,7 @@ in the source distribution for its full text.
|
||||
#else
|
||||
#define HTOP_HWLOC_CPUBIND_FLAG HWLOC_CPUBIND_PROCESS
|
||||
#endif
|
||||
#elif defined(HAVE_LINUX_AFFINITY)
|
||||
#elif defined(HAVE_AFFINITY)
|
||||
#include <sched.h>
|
||||
#endif
|
||||
|
||||
@ -84,7 +84,7 @@ bool Affinity_set(Process* proc, Arg arg) {
|
||||
return ok;
|
||||
}
|
||||
|
||||
#elif defined(HAVE_LINUX_AFFINITY)
|
||||
#elif defined(HAVE_AFFINITY)
|
||||
|
||||
Affinity* Affinity_get(const Process* proc, ProcessList* pl) {
|
||||
cpu_set_t cpuset;
|
||||
|
10
Affinity.h
10
Affinity.h
@ -12,7 +12,7 @@ in the source distribution for its full text.
|
||||
|
||||
#include "ProcessList.h"
|
||||
|
||||
#if defined(HAVE_LIBHWLOC) || defined(HAVE_LINUX_AFFINITY)
|
||||
#if defined(HAVE_LIBHWLOC) || defined(HAVE_AFFINITY)
|
||||
#include <stdbool.h>
|
||||
|
||||
#include "Object.h"
|
||||
@ -20,8 +20,8 @@ in the source distribution for its full text.
|
||||
#endif
|
||||
|
||||
|
||||
#if defined(HAVE_LIBHWLOC) && defined(HAVE_LINUX_AFFINITY)
|
||||
#error hwloc and linux affinity are mutual exclusive.
|
||||
#if defined(HAVE_LIBHWLOC) && defined(HAVE_AFFINITY)
|
||||
#error hwloc and affinity support are mutual exclusive.
|
||||
#endif
|
||||
|
||||
|
||||
@ -38,12 +38,12 @@ void Affinity_delete(Affinity* this);
|
||||
|
||||
void Affinity_add(Affinity* this, unsigned int id);
|
||||
|
||||
#if defined(HAVE_LIBHWLOC) || defined(HAVE_LINUX_AFFINITY)
|
||||
#if defined(HAVE_LIBHWLOC) || defined(HAVE_AFFINITY)
|
||||
|
||||
Affinity* Affinity_get(const Process* proc, ProcessList* pl);
|
||||
|
||||
bool Affinity_set(Process* proc, Arg arg);
|
||||
|
||||
#endif /* HAVE_LIBHWLOC || HAVE_LINUX_AFFINITY */
|
||||
#endif /* HAVE_LIBHWLOC || HAVE_AFFINITY */
|
||||
|
||||
#endif
|
||||
|
8
README
8
README
@ -80,8 +80,11 @@ To install on the local system run `make install`. By default `make install` ins
|
||||
enable Performance Co-Pilot support via a new pcp-htop utility
|
||||
dependency: *libpcp*
|
||||
default: *no*
|
||||
* `--enable-affinity`:
|
||||
enable `sched_setaffinity(2)` and `sched_getaffinity(2)` for affinity support; conflicts with hwloc
|
||||
default: *check*
|
||||
* `--enable-hwloc`:
|
||||
enable hwloc support for CPU affinity; disables Linux affinity
|
||||
enable hwloc support for CPU affinity; disables affinity support
|
||||
dependency: *libhwloc*
|
||||
default: *no*
|
||||
* `--enable-static`:
|
||||
@ -113,9 +116,6 @@ To install on the local system run `make install`. By default `make install` ins
|
||||
* `--enable-ancient-vserver`:
|
||||
enable ancient VServer support (implies `--enable-vserver`)
|
||||
default: *no*
|
||||
* `--enable-linux-affinity`:
|
||||
enable Linux `sched_setaffinity(2)` and `sched_getaffinity(2)` for affinity support; conflicts with hwloc
|
||||
default: *check*
|
||||
* `--enable-delayacct`:
|
||||
enable Linux delay accounting support
|
||||
dependencies: *pkg-config*(build-time), *libnl-3* and *libnl-genl-3*
|
||||
|
74
configure.ac
74
configure.ac
@ -355,9 +355,44 @@ AC_CHECK_FUNCS( [set_escdelay] )
|
||||
AC_CHECK_FUNCS( [getmouse] )
|
||||
|
||||
|
||||
AC_ARG_ENABLE([affinity],
|
||||
[AS_HELP_STRING([--enable-affinity],
|
||||
[enable sched_setaffinity and sched_getaffinity for affinity support, conflicts with hwloc @<:@default=check@:>@])],
|
||||
[],
|
||||
[enable_affinity=check])
|
||||
if test "x$enable_affinity" = xcheck; then
|
||||
if test "x$enable_hwloc" = xyes; then
|
||||
enable_affinity=no
|
||||
else
|
||||
AC_MSG_CHECKING([for usable sched_setaffinity])
|
||||
AC_RUN_IFELSE([
|
||||
AC_LANG_PROGRAM([[
|
||||
#include <sched.h>
|
||||
#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_affinity=yes
|
||||
AC_MSG_RESULT([yes])],
|
||||
[enable_affinity=no
|
||||
AC_MSG_RESULT([no])],
|
||||
[AC_MSG_RESULT([yes (assumed while cross compiling)])])
|
||||
fi
|
||||
fi
|
||||
if test "x$enable_affinity" = xyes; then
|
||||
if test "x$enable_hwloc" = xyes; then
|
||||
AC_MSG_ERROR([--enable-hwloc and --enable-affinity are mutual exclusive. Specify at most one of them.])
|
||||
fi
|
||||
AC_DEFINE([HAVE_AFFINITY], [1], [Define if sched_setaffinity and sched_getaffinity are to be used.])
|
||||
fi
|
||||
|
||||
|
||||
AC_ARG_ENABLE([hwloc],
|
||||
[AS_HELP_STRING([--enable-hwloc],
|
||||
[enable hwloc support for CPU affinity; disables Linux affinity; requires libhwloc @<:@default=no@:>@])],
|
||||
[enable hwloc support for CPU affinity; disables affinity support; requires libhwloc @<:@default=no@:>@])],
|
||||
[],
|
||||
[enable_hwloc=no])
|
||||
case "$enable_hwloc" in
|
||||
@ -433,41 +468,6 @@ if test "x$enable_ancient_vserver" = xyes; then
|
||||
fi
|
||||
|
||||
|
||||
AC_ARG_ENABLE([linux_affinity],
|
||||
[AS_HELP_STRING([--enable-linux-affinity],
|
||||
[enable Linux sched_setaffinity and sched_getaffinity for affinity support, conflicts with hwloc @<:@default=check@:>@])],
|
||||
[],
|
||||
[enable_linux_affinity=check])
|
||||
if test "x$enable_linux_affinity" = xcheck; then
|
||||
if test "x$enable_hwloc" = xyes; then
|
||||
enable_linux_affinity=no
|
||||
else
|
||||
AC_MSG_CHECKING([for usable sched_setaffinity])
|
||||
AC_RUN_IFELSE([
|
||||
AC_LANG_PROGRAM([[
|
||||
#include <sched.h>
|
||||
#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
|
||||
if test "x$enable_linux_affinity" = xyes; then
|
||||
if test "x$enable_hwloc" = xyes; then
|
||||
AC_MSG_ERROR([--enable-hwloc and --enable-linux-affinity are mutual exclusive. Specify at most one of them.])
|
||||
fi
|
||||
AC_DEFINE([HAVE_LINUX_AFFINITY], [1], [Define if Linux sched_setaffinity and sched_getaffinity are to be used.])
|
||||
fi
|
||||
|
||||
|
||||
AC_ARG_ENABLE([capabilities],
|
||||
[AS_HELP_STRING([--enable-capabilities],
|
||||
[enable Linux capabilities support; requires libcap @<:@default=check@:>@])],
|
||||
@ -688,11 +688,11 @@ AC_MSG_RESULT([
|
||||
(Linux) openvz: $enable_openvz
|
||||
(Linux) vserver: $enable_vserver
|
||||
(Linux) ancient vserver: $enable_ancient_vserver
|
||||
(Linux) affinity: $enable_linux_affinity
|
||||
(Linux) delay accounting: $enable_delayacct
|
||||
(Linux) sensors: $enable_sensors
|
||||
(Linux) capabilities: $enable_capabilities
|
||||
unicode: $enable_unicode
|
||||
affinity: $enable_affinity
|
||||
hwloc: $enable_hwloc
|
||||
debug: $enable_debug
|
||||
static: $enable_static
|
||||
|
Loading…
Reference in New Issue
Block a user