From: Yafang Shao <laoar.shao@gmail.com>
To: hannes@cmpxchg.org, mhocko@kernel.org, vdavydov.dev@gmail.com,
akpm@linux-foundation.org
Cc: linux-mm@kvack.org, Yafang Shao <laoar.shao@gmail.com>
Subject: [PATCH 2/3] mm, memcg: introduce a new helper task_in_memcg_oom_set()
Date: Sat, 18 Apr 2020 11:13:10 -0400 [thread overview]
Message-ID: <20200418151311.7397-3-laoar.shao@gmail.com> (raw)
In-Reply-To: <20200418151311.7397-1-laoar.shao@gmail.com>
A new helper task_in_memcg_oom_set() is introduced for later use. It
will be used to bail out from the charge path if no victim can be found
in memcg oom.
Signed-off-by: Yafang Shao <laoar.shao@gmail.com>
---
include/linux/memcontrol.h | 25 +++++++++++++++++++++++++
mm/memcontrol.c | 12 ++----------
2 files changed, 27 insertions(+), 10 deletions(-)
diff --git a/include/linux/memcontrol.h b/include/linux/memcontrol.h
index 98bd8fb2f5c7..767bac135787 100644
--- a/include/linux/memcontrol.h
+++ b/include/linux/memcontrol.h
@@ -565,6 +565,23 @@ static inline bool task_in_memcg_oom(struct task_struct *p)
return p->memcg_in_oom;
}
+/* Bail out from the charge path if no victim found in memcg oom */
+static inline enum oom_status task_in_memcg_oom_set(struct task_struct *p,
+ struct mem_cgroup *memcg,
+ gfp_t mask,
+ int order)
+{
+ if (!current->in_user_fault)
+ return OOM_SKIPPED;
+
+ css_get(&memcg->css);
+ p->memcg_in_oom = memcg;
+ p->memcg_oom_gfp_mask = mask;
+ p->memcg_oom_order = order;
+
+ return OOM_ASYNC;
+}
+
bool mem_cgroup_oom_synchronize(bool wait);
struct mem_cgroup *mem_cgroup_get_oom_group(struct task_struct *victim,
struct mem_cgroup *oom_domain);
@@ -1031,6 +1048,14 @@ static inline bool task_in_memcg_oom(struct task_struct *p)
return false;
}
+static inline enum oom_status task_in_memcg_oom_set(struct task_struct *p,
+ struct mem_cgroup *memcg,
+ gfp_t mask,
+ int order)
+{
+ return OOM_SUCCESS;
+}
+
static inline bool mem_cgroup_oom_synchronize(bool wait)
{
return false;
diff --git a/mm/memcontrol.c b/mm/memcontrol.c
index 22418b55804f..d6cb1b786045 100644
--- a/mm/memcontrol.c
+++ b/mm/memcontrol.c
@@ -1800,16 +1800,8 @@ static enum oom_status mem_cgroup_oom(struct mem_cgroup *memcg, gfp_t mask, int
* Please note that mem_cgroup_out_of_memory might fail to find a
* victim and then we have to bail out from the charge path.
*/
- if (memcg->oom_kill_disable) {
- if (!current->in_user_fault)
- return OOM_SKIPPED;
- css_get(&memcg->css);
- current->memcg_in_oom = memcg;
- current->memcg_oom_gfp_mask = mask;
- current->memcg_oom_order = order;
-
- return OOM_ASYNC;
- }
+ if (memcg->oom_kill_disable)
+ return task_in_memcg_oom_set(current, memcg, mask, order);
mem_cgroup_mark_under_oom(memcg);
--
2.18.2
next prev parent reply other threads:[~2020-04-18 15:13 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-04-18 15:13 [PATCH 0/3] memcg oom: bail out from the charge path if no victim found Yafang Shao
2020-04-18 15:13 ` [PATCH 1/3] mm: change the return type of out_of_memory() Yafang Shao
2020-04-18 15:13 ` Yafang Shao [this message]
2020-04-18 15:13 ` [PATCH 3/3] memcg oom: bail out from the charge path if no victim found Yafang Shao
2020-04-20 8:13 ` Michal Hocko
2020-04-20 8:52 ` Yafang Shao
2020-04-20 9:14 ` Michal Hocko
2020-04-20 9:58 ` Yafang Shao
2020-04-20 10:31 ` Michal Hocko
2020-04-20 10:51 ` Yafang Shao
2020-04-20 11:10 ` Michal Hocko
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=20200418151311.7397-3-laoar.shao@gmail.com \
--to=laoar.shao@gmail.com \
--cc=akpm@linux-foundation.org \
--cc=hannes@cmpxchg.org \
--cc=linux-mm@kvack.org \
--cc=mhocko@kernel.org \
--cc=vdavydov.dev@gmail.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