Skip to contentSkip to conversation

mm: memcontrol: drain stocks on resize limit

PATCH In review Shakeel Butt 3 participants 3 messages May 4, 2018 – May 9, 2018

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 mm: memcontrol: drain stocks on resize limit

Resizing the memcg limit for cgroup-v2 drains the stocks before triggering the memcg reclaim. Do the same for cgroup-v1 to make the behavior consistent.

---
 mm/memcontrol.c | 7 +++++++
 1 file changed, 7 insertions(+)
mm/memcontrol.c +7 -0
index 25b148c2d222..e2d33a37f971 100644
@@ -2463,6 +2463,7 @@ static int mem_cgroup_resize_max(struct mem_cgroup *memcg,
 				 unsigned long max, bool memsw)
 {
 	bool enlarge = false;
+	bool drained = false;
 	int ret;
 	bool limits_invariant;
 	struct page_counter *counter = memsw ? &memcg->memsw : &memcg->memory;
@@ -2493,6 +2494,12 @@ static int mem_cgroup_resize_max(struct mem_cgroup *memcg,
 		if (!ret)
 			break;
 
+		if (!drained) {
+			drain_all_stock(memcg);
+			drained = true;
+			continue;
+		}
+
 		if (!try_to_free_mem_cgroup_pages(memcg, 1,
 					GFP_KERNEL, !memsw)) {
 			ret = -EBUSY;
Signature · 1 line
2.17.0.441.gb46fe60e1d-goog
maintainer Acked-by on v1 1/1
#2 lore raw
In reply to Shakeel Butt
Quoted 5 lines · Shakeel Butt

Resizing the memcg limit for cgroup-v2 drains the stocks before triggering the memcg reclaim. Do the same for cgroup-v1 to make the behavior consistent.

Quoted 31 lines
---
 mm/memcontrol.c | 7 +++++++
 1 file changed, 7 insertions(+)
mm/memcontrol.c +7 -0
index 25b148c2d222..e2d33a37f971 100644
@@ -2463,6 +2463,7 @@ static int mem_cgroup_resize_max(struct mem_cgroup *memcg,
 				 unsigned long max, bool memsw)
 {
 	bool enlarge = false;
+	bool drained = false;
 	int ret;
 	bool limits_invariant;
 	struct page_counter *counter = memsw ? &memcg->memsw : &memcg->memory;
@@ -2493,6 +2494,12 @@ static int mem_cgroup_resize_max(struct mem_cgroup *memcg,
 		if (!ret)
 			break;
 
+		if (!drained) {
+			drain_all_stock(memcg);
+			drained = true;
+			continue;
+		}
+
 		if (!try_to_free_mem_cgroup_pages(memcg, 1,
 					GFP_KERNEL, !memsw)) {
 			ret = -EBUSY;
Signature · 1 line
2.17.0.441.gb46fe60e1d-goog
Signature · 2 lines
Michal Hocko
SUSE Labs