[PATCH] mm, oom: normalize the adj to ensure oom_badness returnone
From: He, Bo
Date: Mon Mar 03 2014 - 03:24:33 EST
if oom_score_adj is a big negative number, such as -941,
adj *= totalpages / 1000 will be a big negative number,
finally the oom_badness will get 0 points, here normalize
the oom_score_adj to ensure oom_badness return the
positive number.
Change-Id: I1c56a948ce48b65a1bb63b56ffef07d5d76d7ec8
Signed-off-by: he, bo <bo.he@xxxxxxxxx>
Signed-off-by: wang, biao <biao.wang@xxxxxxxxx>
Reviewed-by: Yanmin Zhang <yanmin_zhang@xxxxxxxxx>
---
mm/oom_kill.c | 3 +++
1 files changed, 3 insertions(+), 0 deletions(-)
diff --git a/mm/oom_kill.c b/mm/oom_kill.c
index 3291e82..5a93986 100644
--- a/mm/oom_kill.c
+++ b/mm/oom_kill.c
@@ -181,6 +181,9 @@ unsigned long oom_badness(struct task_struct *p, struct mem_cgroup *memcg,
points -= (points * 3) / 100;
/* Normalize to oom_score_adj units */
+ if(OOM_SCORE_ADJ_MIN < 0)
+ adj -= OOM_SCORE_ADJ_MIN;
+
adj *= totalpages / 1000;
points += adj;
--
1.7.6
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/