From: Peng Zhang <zhangpeng362@huawei.com>
To: <linux-mm@kvack.org>
Cc: <mhocko@suse.com>, <shakeelb@google.com>,
<akpm@linux-foundation.org>, <wangkefeng.wang@huawei.com>,
<sunnanyong@huawei.com>, ZhangPeng <zhangpeng362@huawei.com>
Subject: [PATCH 2/2] mm: oom: terminate the oom_evaluate_task() loop early
Date: Mon, 14 Aug 2023 14:34:28 +0800 [thread overview]
Message-ID: <20230814063428.4111206-3-zhangpeng362@huawei.com> (raw)
In-Reply-To: <20230814063428.4111206-1-zhangpeng362@huawei.com>
From: ZhangPeng <zhangpeng362@huawei.com>
If task is allocating a lot of memory and has been marked to be killed
first, then it gets the highest score (LONG_MAX). Therefore, there is no
need to continue to calculate the points of other tasks. Just terminate
the oom_evaluate_task() loop early, when the task with the highest score
is found. By doing this, we can get some performance gains in
select_bad_process().
To implement it, the return value of oom_evaluate_task() is modified.
When the task with the highest score is found (points == LONG_MAX),
oom_evaluate_task() will return 1 and the loop will terminate early.
Signed-off-by: ZhangPeng <zhangpeng362@huawei.com>
---
mm/oom_kill.c | 2 ++
1 file changed, 2 insertions(+)
diff --git a/mm/oom_kill.c b/mm/oom_kill.c
index 10f7826c4035..02d11ae043aa 100644
--- a/mm/oom_kill.c
+++ b/mm/oom_kill.c
@@ -346,6 +346,8 @@ static int oom_evaluate_task(struct task_struct *task, void *arg)
get_task_struct(task);
oc->chosen = task;
oc->chosen_points = points;
+ if (points == LONG_MAX)
+ return 1;
next:
return 0;
abort:
--
2.25.1
next prev parent reply other threads:[~2023-08-14 6:34 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-08-14 6:34 [PATCH 0/2] mm: oom: terminate the oom_evaluate_task() loop early Peng Zhang
2023-08-14 6:34 ` [PATCH 1/2] mm: oom: remove unnecessary goto in oom_evaluate_task() Peng Zhang
2023-08-16 6:46 ` Michal Hocko
2023-08-16 8:56 ` zhangpeng (AS)
2023-08-14 6:34 ` Peng Zhang [this message]
2023-08-16 6:48 ` [PATCH 2/2] mm: oom: terminate the oom_evaluate_task() loop early Michal Hocko
2023-08-16 8:57 ` zhangpeng (AS)
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=20230814063428.4111206-3-zhangpeng362@huawei.com \
--to=zhangpeng362@huawei.com \
--cc=akpm@linux-foundation.org \
--cc=linux-mm@kvack.org \
--cc=mhocko@suse.com \
--cc=shakeelb@google.com \
--cc=sunnanyong@huawei.com \
--cc=wangkefeng.wang@huawei.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;
as well as URLs for NNTP newsgroup(s).