Commit 2f450084 authored by Hisham Muhammad's avatar Hisham Muhammad
Browse files

Enable OOM support unconditionally on Linux.

Read OOM data only if column is enabled.
Make sort ordering more consistent. Closes #182.
parent b291fba0
...@@ -188,11 +188,6 @@ then ...@@ -188,11 +188,6 @@ then
AC_CHECK_HEADERS([hwloc.h],[:], [missing_headers="$missing_headers $ac_header"]) AC_CHECK_HEADERS([hwloc.h],[:], [missing_headers="$missing_headers $ac_header"])
fi fi
AC_ARG_ENABLE(oom, [AC_HELP_STRING([--enable-oom], [enable OOM score reporting])], ,enable_oom="no")
if test "x$enable_oom" = xyes; then
AC_DEFINE(HAVE_OOM, 1, [Define if OOM score support enabled.])
fi
# Bail out on errors. # Bail out on errors.
# ---------------------------------------------------------------------- # ----------------------------------------------------------------------
if test ! -z "$missing_libraries"; then if test ! -z "$missing_libraries"; then
......
...@@ -22,6 +22,7 @@ in the source distribution for its full text. ...@@ -22,6 +22,7 @@ in the source distribution for its full text.
#define PROCESS_FLAG_LINUX_OPENVZ 0x0200 #define PROCESS_FLAG_LINUX_OPENVZ 0x0200
#define PROCESS_FLAG_LINUX_VSERVER 0x0400 #define PROCESS_FLAG_LINUX_VSERVER 0x0400
#define PROCESS_FLAG_LINUX_CGROUP 0x0800 #define PROCESS_FLAG_LINUX_CGROUP 0x0800
#define PROCESS_FLAG_LINUX_OOM 0x1000
typedef enum UnsupportedProcessFields { typedef enum UnsupportedProcessFields {
FLAGS = 9, FLAGS = 9,
...@@ -78,9 +79,7 @@ typedef enum LinuxProcessFields { ...@@ -78,9 +79,7 @@ typedef enum LinuxProcessFields {
#ifdef HAVE_CGROUP #ifdef HAVE_CGROUP
CGROUP = 113, CGROUP = 113,
#endif #endif
#ifdef HAVE_OOM
OOM = 114, OOM = 114,
#endif
IO_PRIORITY = 115, IO_PRIORITY = 115,
LAST_PROCESSFIELD = 116, LAST_PROCESSFIELD = 116,
} LinuxProcessField; } LinuxProcessField;
...@@ -124,9 +123,7 @@ typedef struct LinuxProcess_ { ...@@ -124,9 +123,7 @@ typedef struct LinuxProcess_ {
#ifdef HAVE_CGROUP #ifdef HAVE_CGROUP
char* cgroup; char* cgroup;
#endif #endif
#ifdef HAVE_OOM
unsigned int oom; unsigned int oom;
#endif
} LinuxProcess; } LinuxProcess;
#ifndef Process_isKernelThread #ifndef Process_isKernelThread
...@@ -215,9 +212,7 @@ ProcessFieldData Process_fields[] = { ...@@ -215,9 +212,7 @@ ProcessFieldData Process_fields[] = {
#ifdef HAVE_CGROUP #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 #endif
#ifdef HAVE_OOM [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 = 0, },
#endif
[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, },
[LAST_PROCESSFIELD] = { .name = "*** report bug! ***", .title = NULL, .description = NULL, .flags = 0, }, [LAST_PROCESSFIELD] = { .name = "*** report bug! ***", .title = NULL, .description = NULL, .flags = 0, },
}; };
...@@ -238,9 +233,7 @@ void Process_setupColumnWidths() { ...@@ -238,9 +233,7 @@ void Process_setupColumnWidths() {
Process_fields[TGID].title = " TGID "; Process_fields[TGID].title = " TGID ";
Process_fields[PGRP].title = " PGRP "; Process_fields[PGRP].title = " PGRP ";
Process_fields[SESSION].title = " SESN "; Process_fields[SESSION].title = " SESN ";
#ifdef HAVE_OOM
Process_fields[OOM].title = " OOM "; Process_fields[OOM].title = " OOM ";
#endif
Process_pidFormat = "%7u "; Process_pidFormat = "%7u ";
Process_tpgidFormat = "%7d "; Process_tpgidFormat = "%7d ";
} else { } else {
...@@ -253,9 +246,7 @@ void Process_setupColumnWidths() { ...@@ -253,9 +246,7 @@ void Process_setupColumnWidths() {
Process_fields[TGID].title = " TGID "; Process_fields[TGID].title = " TGID ";
Process_fields[PGRP].title = " PGRP "; Process_fields[PGRP].title = " PGRP ";
Process_fields[SESSION].title = " SESN "; Process_fields[SESSION].title = " SESN ";
#ifdef HAVE_OOM
Process_fields[OOM].title = " OOM "; Process_fields[OOM].title = " OOM ";
#endif
Process_pidFormat = "%5u "; Process_pidFormat = "%5u ";
Process_tpgidFormat = "%5d "; Process_tpgidFormat = "%5d ";
} }
...@@ -348,9 +339,7 @@ void LinuxProcess_writeField(Process* this, RichString* str, ProcessField field) ...@@ -348,9 +339,7 @@ void LinuxProcess_writeField(Process* this, RichString* str, ProcessField field)
#ifdef HAVE_CGROUP #ifdef HAVE_CGROUP
case CGROUP: snprintf(buffer, n, "%-10s ", lp->cgroup); break; case CGROUP: snprintf(buffer, n, "%-10s ", lp->cgroup); break;
#endif #endif
#ifdef HAVE_OOM
case OOM: snprintf(buffer, n, Process_pidFormat, lp->oom); break; case OOM: snprintf(buffer, n, Process_pidFormat, lp->oom); break;
#endif
case IO_PRIORITY: { case IO_PRIORITY: {
int klass = IOPriority_class(lp->ioPriority); int klass = IOPriority_class(lp->ioPriority);
if (klass == IOPRIO_CLASS_NONE) { if (klass == IOPRIO_CLASS_NONE) {
...@@ -416,22 +405,20 @@ long LinuxProcess_compare(const void* v1, const void* v2) { ...@@ -416,22 +405,20 @@ long LinuxProcess_compare(const void* v1, const void* v2) {
#endif #endif
#ifdef HAVE_OPENVZ #ifdef HAVE_OPENVZ
case CTID: case CTID:
return (p1->ctid - p2->ctid); return (p2->ctid - p1->ctid);
case VPID: case VPID:
return (p1->vpid - p2->vpid); return (p2->vpid - p1->vpid);
#endif #endif
#ifdef HAVE_VSERVER #ifdef HAVE_VSERVER
case VXID: case VXID:
return (p1->vxid - p2->vxid); return (p2->vxid - p1->vxid);
#endif #endif
#ifdef HAVE_CGROUP #ifdef HAVE_CGROUP
case CGROUP: case CGROUP:
return strcmp(p1->cgroup ? p1->cgroup : "", p2->cgroup ? p2->cgroup : ""); return strcmp(p1->cgroup ? p1->cgroup : "", p2->cgroup ? p2->cgroup : "");
#endif #endif
#ifdef HAVE_OOM
case OOM: case OOM:
return (p1->oom - p2->oom); return (p2->oom - p1->oom);
#endif
case IO_PRIORITY: case IO_PRIORITY:
return LinuxProcess_effectiveIOPriority(p1) - LinuxProcess_effectiveIOPriority(p2); return LinuxProcess_effectiveIOPriority(p1) - LinuxProcess_effectiveIOPriority(p2);
default: default:
......
...@@ -14,6 +14,7 @@ in the source distribution for its full text. ...@@ -14,6 +14,7 @@ in the source distribution for its full text.
#define PROCESS_FLAG_LINUX_OPENVZ 0x0200 #define PROCESS_FLAG_LINUX_OPENVZ 0x0200
#define PROCESS_FLAG_LINUX_VSERVER 0x0400 #define PROCESS_FLAG_LINUX_VSERVER 0x0400
#define PROCESS_FLAG_LINUX_CGROUP 0x0800 #define PROCESS_FLAG_LINUX_CGROUP 0x0800
#define PROCESS_FLAG_LINUX_OOM 0x1000
typedef enum UnsupportedProcessFields { typedef enum UnsupportedProcessFields {
FLAGS = 9, FLAGS = 9,
...@@ -70,9 +71,7 @@ typedef enum LinuxProcessFields { ...@@ -70,9 +71,7 @@ typedef enum LinuxProcessFields {
#ifdef HAVE_CGROUP #ifdef HAVE_CGROUP
CGROUP = 113, CGROUP = 113,
#endif #endif
#ifdef HAVE_OOM
OOM = 114, OOM = 114,
#endif
IO_PRIORITY = 115, IO_PRIORITY = 115,
LAST_PROCESSFIELD = 116, LAST_PROCESSFIELD = 116,
} LinuxProcessField; } LinuxProcessField;
...@@ -116,9 +115,7 @@ typedef struct LinuxProcess_ { ...@@ -116,9 +115,7 @@ typedef struct LinuxProcess_ {
#ifdef HAVE_CGROUP #ifdef HAVE_CGROUP
char* cgroup; char* cgroup;
#endif #endif
#ifdef HAVE_OOM
unsigned int oom; unsigned int oom;
#endif
} LinuxProcess; } LinuxProcess;
#ifndef Process_isKernelThread #ifndef Process_isKernelThread
......
...@@ -422,8 +422,6 @@ static void LinuxProcessList_readVServerData(LinuxProcess* process, const char* ...@@ -422,8 +422,6 @@ static void LinuxProcessList_readVServerData(LinuxProcess* process, const char*
#endif #endif
#ifdef HAVE_OOM
static void LinuxProcessList_readOomData(LinuxProcess* process, const char* dirname, const char* name) { static void LinuxProcessList_readOomData(LinuxProcess* process, const char* dirname, const char* name) {
char filename[MAX_NAME+1]; char filename[MAX_NAME+1];
snprintf(filename, MAX_NAME, "%s/%s/oom_score", dirname, name); snprintf(filename, MAX_NAME, "%s/%s/oom_score", dirname, name);
...@@ -441,8 +439,6 @@ static void LinuxProcessList_readOomData(LinuxProcess* process, const char* dirn ...@@ -441,8 +439,6 @@ static void LinuxProcessList_readOomData(LinuxProcess* process, const char* dirn
fclose(file); fclose(file);
} }
#endif
static bool LinuxProcessList_readCmdlineFile(Process* process, const char* dirname, const char* name) { static bool LinuxProcessList_readCmdlineFile(Process* process, const char* dirname, const char* name) {
if (Process_isKernelThread(process)) if (Process_isKernelThread(process))
return true; return true;
...@@ -579,9 +575,8 @@ static bool LinuxProcessList_recurseProcTree(LinuxProcessList* this, const char* ...@@ -579,9 +575,8 @@ static bool LinuxProcessList_recurseProcTree(LinuxProcessList* this, const char*
LinuxProcessList_readCGroupFile(lp, dirname, name); LinuxProcessList_readCGroupFile(lp, dirname, name);
#endif #endif
#ifdef HAVE_OOM if (settings->flags & PROCESS_FLAG_LINUX_OOM)
LinuxProcessList_readOomData(lp, dirname, name); LinuxProcessList_readOomData(lp, dirname, name);
#endif
if (proc->state == 'Z') { if (proc->state == 'Z') {
free(proc->comm); free(proc->comm);
......
...@@ -81,10 +81,6 @@ void ProcessList_delete(ProcessList* pl); ...@@ -81,10 +81,6 @@ void ProcessList_delete(ProcessList* pl);
#endif #endif
#ifdef HAVE_OOM
#endif
void ProcessList_goThroughEntries(ProcessList* super); void ProcessList_goThroughEntries(ProcessList* super);
#endif #endif
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment