[Devel] [PATCH rh7] mm: memcontrol: reclaim at least once for __GFP_NORETRY

Vladimir Davydov vdavydov at parallels.com
Fri Aug 7 03:18:22 PDT 2015


From: Johannes Weiner <hannes at cmpxchg.org>

Currently, __GFP_NORETRY tries charging once and gives up before even
trying to reclaim.  Bring the behavior on par with the page allocator
and reclaim at least once before giving up.

Signed-off-by: Johannes Weiner <hannes at cmpxchg.org>
Acked-by: Michal Hocko <mhocko at suse.cz>
Cc: Hugh Dickins <hughd at google.com>
Cc: Tejun Heo <tj at kernel.org>
Cc: Vladimir Davydov <vdavydov at parallels.com>
Signed-off-by: Andrew Morton <akpm at linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds at linux-foundation.org>
(cherry picked from commit 28c34c291e746aab1c2bfd6d6609b2e47fa0978b)
Signed-off-by: Vladimir Davydov <vdavydov at parallels.com>

Conflicts:
	mm/memcontrol.c
---
 mm/memcontrol.c | 8 +++-----
 1 file changed, 3 insertions(+), 5 deletions(-)

diff --git a/mm/memcontrol.c b/mm/memcontrol.c
index 7fc2931afa32..52c787165b17 100644
--- a/mm/memcontrol.c
+++ b/mm/memcontrol.c
@@ -2754,11 +2754,6 @@ static int mem_cgroup_do_charge(struct mem_cgroup *memcg, gfp_t gfp_mask,
 		return CHARGE_WOULDBLOCK;
 	}
 
-	if (gfp_mask & __GFP_NORETRY) {
-		mem_cgroup_inc_failcnt(mem_over_limit, gfp_mask, nr_pages);
-		return CHARGE_NOMEM;
-	}
-
 	ret = mem_cgroup_reclaim(mem_over_limit, gfp_mask, flags);
 	if (mem_cgroup_margin(mem_over_limit) >= nr_pages)
 		return CHARGE_RETRY;
@@ -2787,6 +2782,9 @@ static int mem_cgroup_do_charge(struct mem_cgroup *memcg, gfp_t gfp_mask,
 
 	mem_cgroup_inc_failcnt(mem_over_limit, gfp_mask, nr_pages);
 
+	if (gfp_mask & __GFP_NORETRY)
+		return CHARGE_NOMEM;
+
 	/* check OOM */
 	if (!mem_cgroup_handle_oom(mem_over_limit, gfp_mask, get_order(csize)))
 		return CHARGE_OOM_DIE;
-- 
2.1.4




More information about the Devel mailing list