]> granicus.if.org Git - procps-ng/commitdiff
library: trade a deprecated oomem field for proper one
authorJim Warner <james.warner@comcast.net>
Fri, 15 Apr 2016 05:00:00 +0000 (00:00 -0500)
committerCraig Small <csmall@enc.com.au>
Sat, 16 Apr 2016 23:12:02 +0000 (09:12 +1000)
Now that the conditional OOMEM_ENABLE has been removed
and, after reviewing current library support, it turns
out we've been using a deprecated /proc/<pid>/oom_adj.

What we should use instead is that more recent tunable
/proc/<pid>/oom_score_adj. This new field will provide
a range of -1000 thru +1000 (former was -17 thru +15).

Reference(s):
. removal of misguided OOMEM_ENABLE
commit 64238730fa45e92bc40b2aa28d107c2469ac29e9
. linux, partial oom_adj revert (Nov, 2012)
commit fa0cbbf145aabbf29c6f28f8a11935c0b0fd86fc
. linux, removal oom_adj (Oct, 2012)
commit 01dc52ebdf472f77cca623ca693ca24cfc0f1bbe

Signed-off-by: Jim Warner <james.warner@comcast.net>
proc/readproc.c

index aaf3466dc66be983d8f36c24af94b820286ac2cc..99f5b9d0cf763e009d4e513862205bd6768d7cf2 100644 (file)
@@ -474,12 +474,12 @@ static void supgrps_from_supgids (proc_t *p) {
 }
 
 ///////////////////////////////////////////////////////////////////////
-static void oomscore2proc(const char* S, proc_t *restrict P)
+static inline void oomscore2proc(const char* S, proc_t *restrict P)
 {
     sscanf(S, "%d", &P->oom_score);
 }
 
-static void oomadj2proc(const char* S, proc_t *restrict P)
+static inline void oomadj2proc(const char* S, proc_t *restrict P)
 {
     sscanf(S, "%d", &P->oom_adj);
 }
@@ -962,7 +962,7 @@ static proc_t* simple_readproc(PROCTAB *restrict const PT, proc_t *restrict cons
     if (unlikely(flags & PROC_FILLOOM)) {
         if (likely(file2str(path, "oom_score", &ub) != -1))
             oomscore2proc(ub.buf, p);
-        if (likely(file2str(path, "oom_adj", &ub) != -1))
+        if (likely(file2str(path, "oom_score_adj", &ub) != -1))
             oomadj2proc(ub.buf, p);
     }
 
@@ -1120,7 +1120,7 @@ static proc_t* simple_readtask(PROCTAB *restrict const PT, const proc_t *restric
     if (unlikely(flags & PROC_FILLOOM)) {
         if (likely(file2str(path, "oom_score", &ub) != -1))
             oomscore2proc(ub.buf, t);
-        if (likely(file2str(path, "oom_adj", &ub) != -1))
+        if (likely(file2str(path, "oom_score_adj", &ub) != -1))
             oomadj2proc(ub.buf, t);
     }