Skip to contentSkip to conversation

memcg, oom: no oom-kill for __GFP_RETRY_MAYFAIL

PATCH In review Shakeel Butt 2 participants 4 messages Apr 28, 2019 – Apr 29, 2019

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

PATCH 1/1 memcg, oom: no oom-kill for __GFP_RETRY_MAYFAIL

The documentation of __GFP_RETRY_MAYFAIL clearly mentioned that the OOM killer will not be triggered and indeed the page alloc does not invoke OOM killer for such allocations. However we do trigger memcg OOM killer for __GFP_RETRY_MAYFAIL. Fix that.

---
 mm/memcontrol.c | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)
mm/memcontrol.c +1 -3
index 2713b45ec3f0..99eca724ed3b 100644
@@ -2294,7 +2294,6 @@ static int try_charge(struct mem_cgroup *memcg, gfp_t gfp_mask,
 	unsigned long nr_reclaimed;
 	bool may_swap = true;
 	bool drained = false;
-	bool oomed = false;
 	enum oom_status oom_status;
 
 	if (mem_cgroup_is_root(memcg))
@@ -2381,7 +2380,7 @@ static int try_charge(struct mem_cgroup *memcg, gfp_t gfp_mask,
 	if (nr_retries--)
 		goto retry;
 
-	if (gfp_mask & __GFP_RETRY_MAYFAIL && oomed)
+	if (gfp_mask & __GFP_RETRY_MAYFAIL)
 		goto nomem;
 
 	if (gfp_mask & __GFP_NOFAIL)
@@ -2400,7 +2399,6 @@ static int try_charge(struct mem_cgroup *memcg, gfp_t gfp_mask,
 	switch (oom_status) {
 	case OOM_SUCCESS:
 		nr_retries = MEM_CGROUP_RECLAIM_RETRIES;
-		oomed = true;
 		goto retry;
 	case OOM_FAILED:
 		goto force;
Signature · 1 line
2.21.0.593.g511ec345e18-goog
maintainer Acked-by on v1 1/1
#1 lore raw
Quoted 4 lines · Shakeel Butt

The documentation of __GFP_RETRY_MAYFAIL clearly mentioned that the OOM killer will not be triggered and indeed the page alloc does not invoke OOM killer for such allocations. However we do trigger memcg OOM killer for __GFP_RETRY_MAYFAIL. Fix that.

An example of __GFP_RETRY_MAYFAIL memcg OOM report would be nice. I thought we haven't been using that flag for memcg allocations yet. But this is definitely good to have addressed.

Quoted 1 line
Quoted 36 lines
---
 mm/memcontrol.c | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)
mm/memcontrol.c +1 -3
index 2713b45ec3f0..99eca724ed3b 100644
@@ -2294,7 +2294,6 @@ static int try_charge(struct mem_cgroup *memcg, gfp_t gfp_mask,
 	unsigned long nr_reclaimed;
 	bool may_swap = true;
 	bool drained = false;
-	bool oomed = false;
 	enum oom_status oom_status;
 
 	if (mem_cgroup_is_root(memcg))
@@ -2381,7 +2380,7 @@ static int try_charge(struct mem_cgroup *memcg, gfp_t gfp_mask,
 	if (nr_retries--)
 		goto retry;
 
-	if (gfp_mask & __GFP_RETRY_MAYFAIL && oomed)
+	if (gfp_mask & __GFP_RETRY_MAYFAIL)
 		goto nomem;
 
 	if (gfp_mask & __GFP_NOFAIL)
@@ -2400,7 +2399,6 @@ static int try_charge(struct mem_cgroup *memcg, gfp_t gfp_mask,
 	switch (oom_status) {
 	case OOM_SUCCESS:
 		nr_retries = MEM_CGROUP_RECLAIM_RETRIES;
-		oomed = true;
 		goto retry;
 	case OOM_FAILED:
 		goto force;
Signature · 1 line
2.21.0.593.g511ec345e18-goog
Signature · 2 lines
Michal Hocko
SUSE Labs
#2 lore raw
Quoted 10 lines · Michal Hocko
Quoted 4 lines · Shakeel Butt

The documentation of __GFP_RETRY_MAYFAIL clearly mentioned that the OOM killer will not be triggered and indeed the page alloc does not invoke OOM killer for such allocations. However we do trigger memcg OOM killer for __GFP_RETRY_MAYFAIL. Fix that.

An example of __GFP_RETRY_MAYFAIL memcg OOM report would be nice. I thought we haven't been using that flag for memcg allocations yet. But this is definitely good to have addressed.

Actually I am planning to use it for memcg allocations (specifically fsnotify allocations).

Quoted 4 lines
Quoted 2 lines

Thanks.

Quoted 41 lines
Quoted 35 lines
---
 mm/memcontrol.c | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)
mm/memcontrol.c +1 -4
index 2713b45ec3f0..99eca724ed3b 100644
@@ -2294,7 +2294,6 @@ static int try_charge(struct mem_cgroup *memcg, gfp_t gfp_mask,
      unsigned long nr_reclaimed;
      bool may_swap = true;
      bool drained = false;
-     bool oomed = false;
      enum oom_status oom_status;
 
      if (mem_cgroup_is_root(memcg))
@@ -2381,7 +2380,7 @@ static int try_charge(struct mem_cgroup *memcg, gfp_t gfp_mask,
      if (nr_retries--)
              goto retry;
 
-     if (gfp_mask & __GFP_RETRY_MAYFAIL && oomed)
+     if (gfp_mask & __GFP_RETRY_MAYFAIL)
              goto nomem;
 
      if (gfp_mask & __GFP_NOFAIL)
@@ -2400,7 +2399,6 @@ static int try_charge(struct mem_cgroup *memcg, gfp_t gfp_mask,
      switch (oom_status) {
      case OOM_SUCCESS:
              nr_retries = MEM_CGROUP_RECLAIM_RETRIES;
-             oomed = true;
              goto retry;
      case OOM_FAILED:
              goto force;
--
Quoted 2 lines

2.21.0.593.g511ec345e18-goog

--
Michal Hocko
SUSE Labs

maintainer
#3 lore raw
Quoted 8 lines · Shakeel Butt
Quoted 7 lines · Michal Hocko
Quoted 4 lines · Shakeel Butt

The documentation of __GFP_RETRY_MAYFAIL clearly mentioned that the OOM killer will not be triggered and indeed the page alloc does not invoke OOM killer for such allocations. However we do trigger memcg OOM killer for __GFP_RETRY_MAYFAIL. Fix that.

Quoted 6 lines
Quoted 3 lines

An example of __GFP_RETRY_MAYFAIL memcg OOM report would be nice. I thought we haven't been using that flag for memcg allocations yet. But this is definitely good to have addressed.

Actually I am planning to use it for memcg allocations (specifically fsnotify allocations).

OK, then articulate it in the changelog please.

Quoted 3 lines
Quoted 3 lines
Quoted 1 line
Signature · 2 lines
Michal Hocko
SUSE Labs