linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] mm, memcg: clear page protection when memcg oom group happens
@ 2019-11-25 10:14 Yafang Shao
  2019-11-25 11:08 ` Michal Hocko
  0 siblings, 1 reply; 20+ messages in thread
From: Yafang Shao @ 2019-11-25 10:14 UTC (permalink / raw)
  To: mhocko, hannes, vdavydov.dev, akpm; +Cc: linux-mm, Yafang Shao

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



^ permalink raw reply related	[flat|nested] 20+ messages in thread

end of thread, other threads:[~2019-11-26 10:56 UTC | newest]

Thread overview: 20+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-11-25 10:14 [PATCH] mm, memcg: clear page protection when memcg oom group happens Yafang Shao
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

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).