Skip to content

Commit

Permalink
mm: memcg: do not declare OOM from __GFP_NOFAIL allocations
Browse files Browse the repository at this point in the history
Commit 84235de ("fs: buffer: move allocation failure loop into the
allocator") started recognizing __GFP_NOFAIL in memory cgroups but
forgot to disable the OOM killer.

Any task that does not fail allocation will also not enter the OOM
completion path.  So don't declare an OOM state in this case or it'll be
leaked and the task be able to bypass the limit until the next
userspace-triggered page fault cleans up the OOM state.

Reported-by: William Dauchy <wdauchy@gmail.com>
Signed-off-by: Johannes Weiner <hannes@cmpxchg.org>
Acked-by: Michal Hocko <mhocko@suse.cz>
Cc: David Rientjes <rientjes@google.com>
Cc: <stable@vger.kernel.org>	[3.12.x]
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
  • Loading branch information
Johannes Weiner authored and Linus Torvalds committed Dec 13, 2013
1 parent f40386a commit a0d8b00
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions mm/memcontrol.c
Original file line number Diff line number Diff line change
Expand Up @@ -2696,6 +2696,9 @@ static int __mem_cgroup_try_charge(struct mm_struct *mm,
if (unlikely(task_in_memcg_oom(current)))
goto bypass;

if (gfp_mask & __GFP_NOFAIL)
oom = false;

/*
* We always charge the cgroup the mm_struct belongs to.
* The mm_struct's mem_cgroup changes on task migration if the
Expand Down

0 comments on commit a0d8b00

Please sign in to comment.