mm: memcg: use proper memcg in limit bypass
Commit 84235de394
("fs: buffer: move allocation failure loop into the
allocator") allowed __GFP_NOFAIL allocations to bypass the limit if they
fail to reclaim enough memory for the charge. But because the main test
case was on a 3.2-based system, the patch missed the fact that on newer
kernels the charge function needs to return root_mem_cgroup when
bypassing the limit, and not NULL. This will corrupt whatever memory is
at NULL + percpu pointer offset. Fix this quickly before problems are
reported.
Signed-off-by: Johannes Weiner <hannes@cmpxchg.org>
Acked-by: Michal Hocko <mhocko@suse.cz>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
This commit is contained in:
parent
12aee278b5
commit
3168ecbe1c
1 changed files with 4 additions and 4 deletions
|
@ -2765,10 +2765,10 @@ static int __mem_cgroup_try_charge(struct mm_struct *mm,
|
|||
*ptr = memcg;
|
||||
return 0;
|
||||
nomem:
|
||||
*ptr = NULL;
|
||||
if (gfp_mask & __GFP_NOFAIL)
|
||||
return 0;
|
||||
return -ENOMEM;
|
||||
if (!(gfp_mask & __GFP_NOFAIL)) {
|
||||
*ptr = NULL;
|
||||
return -ENOMEM;
|
||||
}
|
||||
bypass:
|
||||
*ptr = root_mem_cgroup;
|
||||
return -EINTR;
|
||||
|
|
Loading…
Reference in a new issue