[Devel] [PATCH rh7 5/6] oom: do not impose grouping rules if process score is adjusted

Vladimir Davydov vdavydov at parallels.com
Wed Jun 3 07:56:52 PDT 2015


This is a sort of port of diff-oom-fixup-automatic-oom-score-adjustment.
A "sort of", because the way it operates isn't quite the same. In RH6
there is a special value for oom_score_adj (OOM_SCORE_ADJ_UNSET=1001),
which means "score has never been adjusted and currently equals to 0". I
find such a design ugly, because there are a lot of places where we read
the score value in order to e.g. dump it to the log. Seeing 1001, which
is greater than the maximal possible value of 1000, would bewilder the
user.

So I change the logic. Now we impose oom grouping rules iff
oom_score_adj doesn't equal 0. Therefore the difference from RH6 is that
by setting the value back to 0, the user will re-enable grouping rules.
This looks quite natural to me, because if the user actually wants to
change OOM killer behavior, he will set oom_score_adj to something
non-zero obviously.

Since systemd allows tweaking oom_score_adj per unit, the whole oom
grouping thing is going to be obsoleted, and minor change in its
behavior is not critical.

Signed-off-by: Vladimir Davydov <vdavydov at parallels.com>
---
 fs/proc/base.c           | 6 ------
 include/bc/beancounter.h | 1 -
 kernel/bc/proc.c         | 3 ---
 mm/oom_group.c           | 9 ++++-----
 4 files changed, 4 insertions(+), 15 deletions(-)

diff --git a/fs/proc/base.c b/fs/proc/base.c
index 25dc5279880c..c8463014f94c 100644
--- a/fs/proc/base.c
+++ b/fs/proc/base.c
@@ -1122,12 +1122,6 @@ static ssize_t oom_score_adj_write(struct file *file, const char __user *buf,
 		task->signal->oom_score_adj_min = (short)oom_score_adj;
 	trace_oom_score_adj_update(task);
 
-	/*
-	 * Container uses modern interface, seems like it know what to do.
-	 * So, we can disable automaic oom-score adjustments.
-	 */
-	set_bit(UB_OOM_MANUAL_SCORE_ADJ, &get_exec_ub()->ub_flags);
-
 err_sighand:
 	unlock_task_sighand(task, &flags);
 err_task_lock:
diff --git a/include/bc/beancounter.h b/include/bc/beancounter.h
index ea05b112570b..3f887cc10fef 100644
--- a/include/bc/beancounter.h
+++ b/include/bc/beancounter.h
@@ -149,7 +149,6 @@ struct user_beancounter {
 
 enum ub_flags {
 	UB_DIRTY_EXCEEDED,
-	UB_OOM_MANUAL_SCORE_ADJ,
 };
 
 extern int ub_count;
diff --git a/kernel/bc/proc.c b/kernel/bc/proc.c
index d333a1a91b78..e0ddbf139a6d 100644
--- a/kernel/bc/proc.c
+++ b/kernel/bc/proc.c
@@ -103,9 +103,6 @@ static int bc_debug_show(struct seq_file *f, void *v)
 	seq_printf(f, "bc: %p\n", ub);
 	seq_printf(f, "sizeof: %lu\n", sizeof(struct user_beancounter));
 
-	seq_printf(f, "oom_score_adj: %s\n", (ub->ub_flags &
-				UB_OOM_MANUAL_SCORE_ADJ) ? "manual" : "auto");
-
 	return 0;
 }
 
diff --git a/mm/oom_group.c b/mm/oom_group.c
index 2401eed28b0e..f2d54e51a91b 100644
--- a/mm/oom_group.c
+++ b/mm/oom_group.c
@@ -58,12 +58,11 @@ int get_task_oom_score_adj(struct task_struct *t)
 	unsigned long flags;
 	const struct cred *cred;
 	uid_t task_uid;
-	int adj = 0;
+	int adj = t->signal->oom_score_adj;
 
-#ifdef CONFIG_BEANCOUNTERS
-	if (test_bit(UB_OOM_MANUAL_SCORE_ADJ, &get_task_ub(t)->ub_flags))
-		return t->signal->oom_score_adj;
-#endif
+	/* Do not impose grouping rules if the score is adjusted by the user */
+	if (adj != 0)
+		return adj;
 
 	rcu_read_lock();
 	cred = __task_cred(t);
-- 
2.1.4




More information about the Devel mailing list