mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: hui yang <yanghui.def@gmail.com>
To: christian.brauner@ubuntu.com
Cc: christian@brauner.io, peterz@infradead.org, christian@kellner.me,
	tglx@linutronix.de, linux-kernel@vger.kernel.org,
	wad@chromium.org, YangHui <yanghui.def@gmail.com>
Subject: [PATCH v2] mm: LMK, adjust oom_score_adj when fork a new process
Date: Thu, 13 Aug 2020 10:53:31 +0800	[thread overview]
Message-ID: <1597287211-4291-1-git-send-email-yanghui.def@gmail.com> (raw)

From: YangHui <yanghui.def@gmail.com>

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@gmail.com>
---
 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


             reply	other threads:[~2020-08-13  2:53 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-08-13  2:53 hui yang [this message]
2020-08-13  7:46 ` Christian Brauner

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1597287211-4291-1-git-send-email-yanghui.def@gmail.com \
    --to=yanghui.def@gmail.com \
    --cc=christian.brauner@ubuntu.com \
    --cc=christian@brauner.io \
    --cc=christian@kellner.me \
    --cc=linux-kernel@vger.kernel.org \
    --cc=peterz@infradead.org \
    --cc=tglx@linutronix.de \
    --cc=wad@chromium.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®