[Devel] [PATCH rh7 4/5] proc: fix oom_score output

Vladimir Davydov vdavydov at parallels.com
Mon May 18 07:24:59 PDT 2015


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 12d9ea1eca6d..79ee3c875e76 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 {
-- 
1.7.10.4




More information about the Devel mailing list