Skip to content

Commit

Permalink
mm: memcontrol: clean up reclaim size variable use in try_charge()
Browse files Browse the repository at this point in the history
Charge reclaim and OOM currently use the charge batch variable, but
batching is already disabled at that point.  To simplify the charge
logic, the batch variable is reset to the original request size when
reclaim is entered, so it's functionally equal, but it's misleading.

Switch reclaim/OOM to nr_pages, which is the original request size.

Signed-off-by: Johannes Weiner <[email protected]>
Cc: Michal Hocko <[email protected]>
Signed-off-by: Andrew Morton <[email protected]>
Signed-off-by: Linus Torvalds <[email protected]>
  • Loading branch information
hnaz authored and torvalds committed Aug 7, 2014
1 parent 618fde8 commit 61e02c7
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions mm/memcontrol.c
Original file line number Diff line number Diff line change
Expand Up @@ -2612,7 +2612,7 @@ static int mem_cgroup_try_charge(struct mem_cgroup *memcg,

nr_reclaimed = mem_cgroup_reclaim(mem_over_limit, gfp_mask, flags);

if (mem_cgroup_margin(mem_over_limit) >= batch)
if (mem_cgroup_margin(mem_over_limit) >= nr_pages)
goto retry;

if (gfp_mask & __GFP_NORETRY)
Expand All @@ -2626,7 +2626,7 @@ static int mem_cgroup_try_charge(struct mem_cgroup *memcg,
* unlikely to succeed so close to the limit, and we fall back
* to regular pages anyway in case of failure.
*/
if (nr_reclaimed && batch <= (1 << PAGE_ALLOC_COSTLY_ORDER))
if (nr_reclaimed && nr_pages <= (1 << PAGE_ALLOC_COSTLY_ORDER))
goto retry;
/*
* At task move, charge accounts can be doubly counted. So, it's
Expand All @@ -2644,7 +2644,7 @@ static int mem_cgroup_try_charge(struct mem_cgroup *memcg,
if (fatal_signal_pending(current))
goto bypass;

mem_cgroup_oom(mem_over_limit, gfp_mask, get_order(batch));
mem_cgroup_oom(mem_over_limit, gfp_mask, get_order(nr_pages));
nomem:
if (!(gfp_mask & __GFP_NOFAIL))
return -ENOMEM;
Expand Down

0 comments on commit 61e02c7

Please sign in to comment.