From: Stephen Rothwell <sfr@canb.auug.org.au>
To: Yafang Shao <laoar.shao@gmail.com>
Cc: mhocko@kernel.org, cai@lca.pw, rientjes@google.com,
akpm@linux-foundation.org, linux-mm@kvack.org,
linux-next@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH v3] mm, oom: make the calculation of oom badness more accurate
Date: Mon, 13 Jul 2020 12:39:39 +1000 [thread overview]
Message-ID: <20200713123939.6ea87a93@canb.auug.org.au> (raw)
In-Reply-To: <1594396651-9931-1-git-send-email-laoar.shao@gmail.com>
[-- Attachment #1: Type: text/plain, Size: 3541 bytes --]
Hi all,
On Fri, 10 Jul 2020 11:57:31 -0400 Yafang Shao <laoar.shao@gmail.com> wrote:
>
> ---
> v2 -> v3:
> - fix the type of variable 'point' in oom_evaluate_task()
> - initialize oom_control->chosen_points in select_bad_process() per Michal
> - update the comment in proc_oom_score() per Michal
I have applied the following incremental patch to linux-next today.
From: Stephen Rothwell <sfr@canb.auug.org.au>
Date: Mon, 13 Jul 2020 12:34:46 +1000
Subject: [PATCH] mm-oom-make-the-calculation-of-oom-badness-more-accurate-fix
Signed-off-by: Stephen Rothwell <sfr@canb.auug.org.au>
---
drivers/tty/sysrq.c | 1 -
fs/proc/base.c | 10 +++++++---
mm/memcontrol.c | 1 -
mm/oom_kill.c | 5 +++--
mm/page_alloc.c | 1 -
5 files changed, 10 insertions(+), 8 deletions(-)
diff --git a/drivers/tty/sysrq.c b/drivers/tty/sysrq.c
index e83fd46f632c..7c95afa905a0 100644
--- a/drivers/tty/sysrq.c
+++ b/drivers/tty/sysrq.c
@@ -382,7 +382,6 @@ static void moom_callback(struct work_struct *ignored)
.memcg = NULL,
.gfp_mask = gfp_mask,
.order = -1,
- .chosen_points = LONG_MIN,
};
mutex_lock(&oom_lock);
diff --git a/fs/proc/base.c b/fs/proc/base.c
index bf164064b901..10c2a26c0e20 100644
--- a/fs/proc/base.c
+++ b/fs/proc/base.c
@@ -554,10 +554,14 @@ static int proc_oom_score(struct seq_file *m, struct pid_namespace *ns,
long badness;
badness = oom_badness(task, totalpages);
- if (badness != LONG_MIN) {
- /* Let's keep the range of points as [0, 2000]. */
+ /*
+ * Special case OOM_SCORE_ADJ_MIN for all others scale the
+ * badness value into [0, 2000] range which we have been
+ * exporting for a long time so userspace might depend on it.
+ */
+ if (badness != LONG_MIN)
points = (1000 + badness * 1000 / (long)totalpages) * 2 / 3;
- }
+
seq_printf(m, "%lu\n", points);
return 0;
diff --git a/mm/memcontrol.c b/mm/memcontrol.c
index 4ae64726f863..430d4c659669 100644
--- a/mm/memcontrol.c
+++ b/mm/memcontrol.c
@@ -1666,7 +1666,6 @@ static bool mem_cgroup_out_of_memory(struct mem_cgroup *memcg, gfp_t gfp_mask,
.memcg = memcg,
.gfp_mask = gfp_mask,
.order = order,
- .chosen_points = LONG_MIN,
};
bool ret;
diff --git a/mm/oom_kill.c b/mm/oom_kill.c
index 8fdb8b03f5cd..48e0db54d838 100644
--- a/mm/oom_kill.c
+++ b/mm/oom_kill.c
@@ -306,7 +306,7 @@ static enum oom_constraint constrained_alloc(struct oom_control *oc)
static int oom_evaluate_task(struct task_struct *task, void *arg)
{
struct oom_control *oc = arg;
- unsigned long points;
+ long points;
if (oom_unkillable_task(task))
goto next;
@@ -361,6 +361,8 @@ static int oom_evaluate_task(struct task_struct *task, void *arg)
*/
static void select_bad_process(struct oom_control *oc)
{
+ oc->chosen_points = LONG_MIN;
+
if (is_memcg_oom(oc))
mem_cgroup_scan_tasks(oc->memcg, oom_evaluate_task, oc);
else {
@@ -1124,7 +1126,6 @@ void pagefault_out_of_memory(void)
.memcg = NULL,
.gfp_mask = 0,
.order = 0,
- .chosen_points = LONG_MIN,
};
if (mem_cgroup_oom_synchronize(true))
diff --git a/mm/page_alloc.c b/mm/page_alloc.c
index 0832b21a7728..65fc0ed784d2 100644
--- a/mm/page_alloc.c
+++ b/mm/page_alloc.c
@@ -3915,7 +3915,6 @@ __alloc_pages_may_oom(gfp_t gfp_mask, unsigned int order,
.memcg = NULL,
.gfp_mask = gfp_mask,
.order = order,
- .chosen_points = LONG_MIN,
};
struct page *page;
--
2.27.0
--
Cheers,
Stephen Rothwell
[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 488 bytes --]
prev parent reply other threads:[~2020-07-13 2:39 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-07-10 15:57 Yafang Shao
2020-07-12 18:34 ` Naresh Kamboju
2020-07-13 1:49 ` Yafang Shao
2020-07-13 2:39 ` Stephen Rothwell [this message]
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=20200713123939.6ea87a93@canb.auug.org.au \
--to=sfr@canb.auug.org.au \
--cc=akpm@linux-foundation.org \
--cc=cai@lca.pw \
--cc=laoar.shao@gmail.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=linux-next@vger.kernel.org \
--cc=mhocko@kernel.org \
--cc=rientjes@google.com \
/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