[PATCH v2] mm: LMK, adjust oom_score_adj when fork a new process

From: hui yang
Date: Wed Aug 12 2020 - 22:54:02 EST


From: YangHui <yanghui.def@xxxxxxxxx>

Also it rely on inheritance,But there are some things you need't inheriting
if all children oom_score_adj is -1000,the oom is meaningless

Signed-off-by: YangHui <yanghui.def@xxxxxxxxx>
---
include/uapi/linux/oom.h | 1 +
kernel/fork.c | 4 ++--
2 files changed, 3 insertions(+), 2 deletions(-)

diff --git a/include/uapi/linux/oom.h b/include/uapi/linux/oom.h
index 750b1c5..0251f23 100644
--- a/include/uapi/linux/oom.h
+++ b/include/uapi/linux/oom.h
@@ -8,6 +8,7 @@
*/
#define OOM_SCORE_ADJ_MIN (-1000)
#define OOM_SCORE_ADJ_MAX 1000
+#define OOM_SCORE_ADJ_DEFAULT 0

/*
* /proc/<pid>/oom_adj set to -17 protects from the oom killer for legacy
diff --git a/kernel/fork.c b/kernel/fork.c
index 4d32190..9dfa388 100644
--- a/kernel/fork.c
+++ b/kernel/fork.c
@@ -1584,8 +1584,8 @@ static int copy_signal(unsigned long clone_flags, struct task_struct *tsk)
tty_audit_fork(sig);
sched_autogroup_fork(sig);

- sig->oom_score_adj = current->signal->oom_score_adj;
- sig->oom_score_adj_min = current->signal->oom_score_adj_min;
+ sig->oom_score_adj = OOM_SCORE_ADJ_DEFAULT;
+ sig->oom_score_adj_min = OOM_SCORE_ADJ_MIN;

mutex_init(&sig->cred_guard_mutex);
mutex_init(&sig->exec_update_mutex);
--
2.7.4