[Devel] [PATCH RHEL7 COMMIT] proc/oom: fix oom_score output

Konstantin Khorenko khorenko at virtuozzo.com
Fri May 22 07:41:25 PDT 2015


The commit is pushed to "branch-rh7-3.10.0-123.1.2-ovz" and will appear at https://src.openvz.org/scm/ovz/vzkernel.git
after rh7-3.10.0-123.1.2.vz7.5.5
------>
commit 750e0fe2c75235f88b0f391136a7eb07674ba737
Author: Vladimir Davydov <vdavydov at parallels.com>
Date:   Fri May 22 18:41:25 2015 +0400

    proc/oom: fix oom_score output
    
    oom_badness now returns absolute badness, not per mille. So we have to
    revert the chunk of PCS6 code that doesn't know that. Note, I use the
    global totalpages rather than per ub as it used to be, because ub's oom
    killer doesn't work anyway for now and will be reimplemented in the
    scope of the memory cgroup. Then I'll change it to per-memcg value.
    
    Signed-off-by: Vladimir Davydov <vdavydov at parallels.com>
---
 fs/proc/base.c | 12 ++++++------
 1 file changed, 6 insertions(+), 6 deletions(-)

diff --git a/fs/proc/base.c b/fs/proc/base.c
index 12d9ea1..79ee3c8 100644
--- a/fs/proc/base.c
+++ b/fs/proc/base.c
@@ -449,15 +449,15 @@ static const struct file_operations proc_cpuset_operations = {
 
 static int proc_oom_score(struct task_struct *task, char *buffer)
 {
-	int points = 0;
+	unsigned long totalpages = totalram_pages + total_swap_pages;
+	unsigned long points = 0;
 
 	read_lock(&tasklist_lock);
-	if (pid_alive(task)) {
-		points = oom_badness(task, NULL, NULL, ub_oom_total_pages(get_exec_ub()));
-		points = clamp(points, 0, 1000);
-	}
+	if (pid_alive(task))
+		points = oom_badness(task, NULL, NULL, totalpages) *
+						1000 / totalpages;
 	read_unlock(&tasklist_lock);
-	return sprintf(buffer, "%d\n", points);
+	return sprintf(buffer, "%lu\n", points);
 }
 
 struct limit_names {



More information about the Devel mailing list