From: Yafang Shao <laoar.shao@gmail.com>
To: mhocko@kernel.org, hannes@cmpxchg.org, vdavydov.dev@gmail.com,
akpm@linux-foundation.org
Cc: linux-mm@kvack.org, Yafang Shao <laoar.shao@gmail.com>
Subject: [PATCH] mm, memcg: clear page protection when memcg oom group happens
Date: Mon, 25 Nov 2019 05:14:53 -0500 [thread overview]
Message-ID: <1574676893-1571-1-git-send-email-laoar.shao@gmail.com> (raw)
We set memory.oom.group to make all processes in this memcg are killed by
OOM killer to free more pages. In this case, it doesn't make sense to
protect the pages with memroy.{min, low} again if they are set.
Signed-off-by: Yafang Shao <laoar.shao@gmail.com>
---
include/linux/memcontrol.h | 11 +++++++++++
mm/memcontrol.c | 4 +---
mm/oom_kill.c | 1 +
3 files changed, 13 insertions(+), 3 deletions(-)
diff --git a/include/linux/memcontrol.h b/include/linux/memcontrol.h
index 0c762e8..f68a1a5 100644
--- a/include/linux/memcontrol.h
+++ b/include/linux/memcontrol.h
@@ -369,6 +369,13 @@ static inline unsigned long mem_cgroup_protection(struct mem_cgroup *memcg,
READ_ONCE(memcg->memory.elow));
}
+static inline void mem_cgroup_clear_protection(struct mem_cgroup *memcg)
+{
+
+ page_counter_set_min(&memcg->memory, 0);
+ page_counter_set_low(&memcg->memory, 0);
+}
+
enum mem_cgroup_protection mem_cgroup_protected(struct mem_cgroup *root,
struct mem_cgroup *memcg);
@@ -850,6 +857,10 @@ static inline unsigned long mem_cgroup_protection(struct mem_cgroup *memcg,
return 0;
}
+static inline void mem_cgroup_clear_protection(struct mem_cgroup *memcg)
+{
+}
+
static inline enum mem_cgroup_protection mem_cgroup_protected(
struct mem_cgroup *root, struct mem_cgroup *memcg)
{
diff --git a/mm/memcontrol.c b/mm/memcontrol.c
index 1c4c08b..e5ab119 100644
--- a/mm/memcontrol.c
+++ b/mm/memcontrol.c
@@ -5190,9 +5190,7 @@ static void mem_cgroup_css_offline(struct cgroup_subsys_state *css)
}
spin_unlock(&memcg->event_list_lock);
- page_counter_set_min(&memcg->memory, 0);
- page_counter_set_low(&memcg->memory, 0);
-
+ mem_cgroup_clear_protection(memcg);
memcg_offline_kmem(memcg);
wb_memcg_offline(memcg);
diff --git a/mm/oom_kill.c b/mm/oom_kill.c
index 93eae76..550f830 100644
--- a/mm/oom_kill.c
+++ b/mm/oom_kill.c
@@ -988,6 +988,7 @@ static void oom_kill_process(struct oom_control *oc, const char *message)
mem_cgroup_print_oom_group(oom_group);
mem_cgroup_scan_tasks(oom_group, oom_kill_memcg_member,
(void*)message);
+ mem_cgroup_clear_protection(oom_group);
mem_cgroup_put(oom_group);
}
}
--
1.8.3.1
next reply other threads:[~2019-11-25 10:15 UTC|newest]
Thread overview: 20+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-11-25 10:14 Yafang Shao [this message]
2019-11-25 11:08 ` Michal Hocko
2019-11-25 11:37 ` Yafang Shao
2019-11-25 11:54 ` Michal Hocko
2019-11-25 12:17 ` Yafang Shao
2019-11-25 12:31 ` Michal Hocko
2019-11-25 12:37 ` Yafang Shao
2019-11-25 12:45 ` Michal Hocko
2019-11-25 14:11 ` Yafang Shao
2019-11-25 14:21 ` Michal Hocko
2019-11-25 14:42 ` Johannes Weiner
2019-11-25 14:45 ` Yafang Shao
2019-11-26 3:52 ` Yafang Shao
2019-11-26 7:31 ` Michal Hocko
2019-11-26 9:35 ` Yafang Shao
2019-11-26 9:50 ` Michal Hocko
2019-11-26 10:02 ` Yafang Shao
2019-11-26 10:22 ` Michal Hocko
2019-11-26 10:56 ` Yafang Shao
2019-11-25 14:44 ` Yafang Shao
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=1574676893-1571-1-git-send-email-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