Drop cgroup conditional

cgroup is only checked on runtime if the column CGROUP is selected.

cgroup is currently disabled by default, but most distributions do
enable it.

Drop the cgroup configuration switch, to reduce the maintenance cost.
This commit is contained in:
Christian Göttsche 2020-09-21 12:30:25 +02:00 committed by cgzones
parent 267014cbfe
commit c88c80e3bd
6 changed files with 6 additions and 30 deletions

View File

@ -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-hwloc --enable-setuid --enable-delayacct --enable-sensors run: ./configure --enable-werror --enable-openvz --enable-vserver --enable-ancient-vserver --enable-taskstats --enable-unicode --enable-hwloc --enable-setuid --enable-delayacct --enable-sensors
- name: Build - name: Build
run: make -k run: make -k
- 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-hwloc --enable-setuid --enable-delayacct --enable-sensors' run: make distcheck DISTCHECK_CONFIGURE_FLAGS='--enable-werror --enable-openvz --enable-vserver --enable-ancient-vserver --enable-taskstats --enable-unicode --enable-hwloc --enable-setuid --enable-delayacct --enable-sensors'
build-ubuntu-latest-full-featured-clang: build-ubuntu-latest-full-featured-clang:
runs-on: ubuntu-latest runs-on: ubuntu-latest
@ -71,11 +71,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-hwloc --enable-setuid --enable-delayacct --enable-sensors run: ./configure --enable-werror --enable-openvz --enable-vserver --enable-ancient-vserver --enable-taskstats --enable-unicode --enable-hwloc --enable-setuid --enable-delayacct --enable-sensors
- name: Build - name: Build
run: make -k run: make -k
- 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-hwloc --enable-setuid --enable-delayacct --enable-sensors' run: make distcheck DISTCHECK_CONFIGURE_FLAGS='--enable-werror --enable-openvz --enable-vserver --enable-ancient-vserver --enable-taskstats --enable-unicode --enable-hwloc --enable-setuid --enable-delayacct --enable-sensors'
build-ubuntu-latest-clang-analyzer: build-ubuntu-latest-clang-analyzer:
runs-on: ubuntu-latest runs-on: ubuntu-latest
@ -93,7 +93,7 @@ jobs:
- name: Bootstrap - name: Bootstrap
run: ./autogen.sh run: ./autogen.sh
- name: Configure - name: Configure
run: scan-build-11 -analyze-headers --status-bugs ./configure --enable-debug --enable-werror --enable-openvz --enable-cgroup --enable-vserver --enable-ancient-vserver --enable-taskstats --enable-unicode --enable-hwloc --enable-setuid --enable-delayacct --enable-sensors run: scan-build-11 -analyze-headers --status-bugs ./configure --enable-debug --enable-werror --enable-openvz --enable-vserver --enable-ancient-vserver --enable-taskstats --enable-unicode --enable-hwloc --enable-setuid --enable-delayacct --enable-sensors
- name: Build - name: Build
run: scan-build-11 -analyze-headers --status-bugs make -j"$(nproc)" run: scan-build-11 -analyze-headers --status-bugs make -j"$(nproc)"

View File

@ -280,7 +280,7 @@ coverage:
$(MAKE) all AM_CPPFLAGS="-fprofile-arcs -ftest-coverage -DDEBUG" AM_LDFLAGS="-lgcov" $(MAKE) all AM_CPPFLAGS="-fprofile-arcs -ftest-coverage -DDEBUG" AM_LDFLAGS="-lgcov"
cppcheck: cppcheck:
cppcheck -q -v . --enable=all -DHAVE_CGROUP -DHAVE_OPENVZ -DHAVE_TASKSTATS cppcheck -q -v . --enable=all -DHAVE_OPENVZ -DHAVE_TASKSTATS
dist-hook: $(top_distdir)/configure dist-hook: $(top_distdir)/configure
@if grep 'pkg_m4_absent' '$(top_distdir)/configure'; then \ @if grep 'pkg_m4_absent' '$(top_distdir)/configure'; then \

View File

@ -123,11 +123,6 @@ if test "x$enable_openvz" = xyes; then
AC_DEFINE(HAVE_OPENVZ, 1, [Define if openvz support enabled.]) AC_DEFINE(HAVE_OPENVZ, 1, [Define if openvz support enabled.])
fi fi
AC_ARG_ENABLE(cgroup, [AS_HELP_STRING([--enable-cgroup], [enable cgroups support])], ,enable_cgroup="no")
if test "x$enable_cgroup" = xyes; then
AC_DEFINE(HAVE_CGROUP, 1, [Define if cgroup support enabled.])
fi
AC_ARG_ENABLE(vserver, [AS_HELP_STRING([--enable-vserver], [enable VServer support])], ,enable_vserver="no") AC_ARG_ENABLE(vserver, [AS_HELP_STRING([--enable-vserver], [enable VServer support])], ,enable_vserver="no")
if test "x$enable_vserver" = xyes; then if test "x$enable_vserver" = xyes; then
AC_DEFINE(HAVE_VSERVER, 1, [Define if vserver support enabled.]) AC_DEFINE(HAVE_VSERVER, 1, [Define if vserver support enabled.])
@ -390,7 +385,6 @@ AC_MSG_RESULT([
platform: $my_htop_platform platform: $my_htop_platform
(Linux) proc directory: $PROCDIR (Linux) proc directory: $PROCDIR
(Linux) openvz: $enable_openvz (Linux) openvz: $enable_openvz
(Linux) cgroup: $enable_cgroup
(Linux) vserver: $enable_vserver (Linux) vserver: $enable_vserver
(Linux) ancient vserver: $enable_ancient_vserver (Linux) ancient vserver: $enable_ancient_vserver
(Linux) taskstats: $enable_taskstats (Linux) taskstats: $enable_taskstats

View File

@ -102,9 +102,7 @@ ProcessFieldData Process_fields[] = {
[IO_WRITE_RATE] = { .name = "IO_WRITE_RATE", .title = " DISK WRITE ", .description = "The I/O rate of write(2) in bytes per second for the process", .flags = PROCESS_FLAG_IO, }, [IO_WRITE_RATE] = { .name = "IO_WRITE_RATE", .title = " DISK WRITE ", .description = "The I/O rate of write(2) in bytes per second for the process", .flags = PROCESS_FLAG_IO, },
[IO_RATE] = { .name = "IO_RATE", .title = " DISK R/W ", .description = "Total I/O rate in bytes per second", .flags = PROCESS_FLAG_IO, }, [IO_RATE] = { .name = "IO_RATE", .title = " DISK R/W ", .description = "Total I/O rate in bytes per second", .flags = PROCESS_FLAG_IO, },
#endif #endif
#ifdef HAVE_CGROUP
[CGROUP] = { .name = "CGROUP", .title = " CGROUP ", .description = "Which cgroup the process is in", .flags = PROCESS_FLAG_LINUX_CGROUP, }, [CGROUP] = { .name = "CGROUP", .title = " CGROUP ", .description = "Which cgroup the process is in", .flags = PROCESS_FLAG_LINUX_CGROUP, },
#endif
[OOM] = { .name = "OOM", .title = " OOM ", .description = "OOM (Out-of-Memory) killer score", .flags = PROCESS_FLAG_LINUX_OOM, }, [OOM] = { .name = "OOM", .title = " OOM ", .description = "OOM (Out-of-Memory) killer score", .flags = PROCESS_FLAG_LINUX_OOM, },
[IO_PRIORITY] = { .name = "IO_PRIORITY", .title = "IO ", .description = "I/O priority", .flags = PROCESS_FLAG_LINUX_IOPRIO, }, [IO_PRIORITY] = { .name = "IO_PRIORITY", .title = "IO ", .description = "I/O priority", .flags = PROCESS_FLAG_LINUX_IOPRIO, },
#ifdef HAVE_DELAYACCT #ifdef HAVE_DELAYACCT
@ -156,9 +154,7 @@ Process* LinuxProcess_new(const Settings* settings) {
void Process_delete(Object* cast) { void Process_delete(Object* cast) {
LinuxProcess* this = (LinuxProcess*) cast; LinuxProcess* this = (LinuxProcess*) cast;
Process_done((Process*)cast); Process_done((Process*)cast);
#ifdef HAVE_CGROUP
free(this->cgroup); free(this->cgroup);
#endif
#ifdef HAVE_OPENVZ #ifdef HAVE_OPENVZ
free(this->ctid); free(this->ctid);
#endif #endif
@ -680,9 +676,7 @@ static void LinuxProcess_writeField(const Process* this, RichString* str, Proces
#ifdef HAVE_VSERVER #ifdef HAVE_VSERVER
case VXID: xSnprintf(buffer, n, "%5u ", lp->vxid); break; case VXID: xSnprintf(buffer, n, "%5u ", lp->vxid); break;
#endif #endif
#ifdef HAVE_CGROUP
case CGROUP: xSnprintf(buffer, n, "%-10s ", lp->cgroup ? lp->cgroup : ""); break; case CGROUP: xSnprintf(buffer, n, "%-10s ", lp->cgroup ? lp->cgroup : ""); break;
#endif
case OOM: xSnprintf(buffer, n, "%4u ", lp->oom); break; case OOM: xSnprintf(buffer, n, "%4u ", lp->oom); break;
case IO_PRIORITY: { case IO_PRIORITY: {
int klass = IOPriority_class(lp->ioPriority); int klass = IOPriority_class(lp->ioPriority);
@ -821,10 +815,8 @@ static long LinuxProcess_compare(const void* v1, const void* v2) {
case VXID: case VXID:
return SPACESHIP_NUMBER(p2->vxid, p1->vxid); return SPACESHIP_NUMBER(p2->vxid, p1->vxid);
#endif #endif
#ifdef HAVE_CGROUP
case CGROUP: case CGROUP:
return SPACESHIP_NULLSTR(p1->cgroup, p2->cgroup); return SPACESHIP_NULLSTR(p1->cgroup, p2->cgroup);
#endif
case OOM: case OOM:
return SPACESHIP_NUMBER(p2->oom, p1->oom); return SPACESHIP_NUMBER(p2->oom, p1->oom);
#ifdef HAVE_DELAYACCT #ifdef HAVE_DELAYACCT

View File

@ -80,9 +80,7 @@ typedef enum LinuxProcessFields {
IO_WRITE_RATE = 111, IO_WRITE_RATE = 111,
IO_RATE = 112, IO_RATE = 112,
#endif #endif
#ifdef HAVE_CGROUP
CGROUP = 113, CGROUP = 113,
#endif
OOM = 114, OOM = 114,
IO_PRIORITY = 115, IO_PRIORITY = 115,
#ifdef HAVE_DELAYACCT #ifdef HAVE_DELAYACCT
@ -170,9 +168,7 @@ typedef struct LinuxProcess_ {
#ifdef HAVE_VSERVER #ifdef HAVE_VSERVER
unsigned int vxid; unsigned int vxid;
#endif #endif
#ifdef HAVE_CGROUP
char* cgroup; char* cgroup;
#endif
unsigned int oom; unsigned int oom;
char* ttyDevice; char* ttyDevice;
#ifdef HAVE_DELAYACCT #ifdef HAVE_DELAYACCT

View File

@ -644,8 +644,6 @@ static void LinuxProcessList_readOpenVZData(LinuxProcess* process, const char* d
#endif #endif
#ifdef HAVE_CGROUP
static void LinuxProcessList_readCGroupFile(LinuxProcess* process, const char* dirname, const char* name) { static void LinuxProcessList_readCGroupFile(LinuxProcess* process, const char* dirname, const char* name) {
char filename[MAX_NAME + 1]; char filename[MAX_NAME + 1];
xSnprintf(filename, MAX_NAME, "%s/%s/cgroup", dirname, name); xSnprintf(filename, MAX_NAME, "%s/%s/cgroup", dirname, name);
@ -684,8 +682,6 @@ static void LinuxProcessList_readCGroupFile(LinuxProcess* process, const char* d
process->cgroup = xStrdup(output); process->cgroup = xStrdup(output);
} }
#endif
#ifdef HAVE_VSERVER #ifdef HAVE_VSERVER
static void LinuxProcessList_readVServerData(LinuxProcess* process, const char* dirname, const char* name) { static void LinuxProcessList_readVServerData(LinuxProcess* process, const char* dirname, const char* name) {
@ -1294,11 +1290,9 @@ static bool LinuxProcessList_recurseProcTree(LinuxProcessList* this, const char*
LinuxProcessList_readDelayAcctData(this, lp); LinuxProcessList_readDelayAcctData(this, lp);
#endif #endif
#ifdef HAVE_CGROUP
if (settings->flags & PROCESS_FLAG_LINUX_CGROUP) { if (settings->flags & PROCESS_FLAG_LINUX_CGROUP) {
LinuxProcessList_readCGroupFile(lp, dirname, name); LinuxProcessList_readCGroupFile(lp, dirname, name);
} }
#endif
if (settings->flags & PROCESS_FLAG_LINUX_OOM) { if (settings->flags & PROCESS_FLAG_LINUX_OOM) {
LinuxProcessList_readOomData(lp, dirname, name); LinuxProcessList_readOomData(lp, dirname, name);