diff options
author | Qiang Huang <h.huangqiang@huawei.com> | 2013-11-12 18:07:22 -0500 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2013-11-12 22:09:04 -0500 |
commit | b9921ecdee66984b00c38c00a358ef3f611d2b50 (patch) | |
tree | caf420f152f6c8764f150ad336645deec9acaeb2 /mm/memcontrol.c | |
parent | 9c2606b77d6bffb422928bca66c8dc84d85089be (diff) |
mm: add a helper function to check may oom condition
Use helper function to check if we need to deal with oom condition.
Signed-off-by: Qiang Huang <h.huangqiang@huawei.com>
Acked-by: David Rientjes <rientjes@google.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'mm/memcontrol.c')
-rw-r--r-- | mm/memcontrol.c | 9 |
1 files changed, 1 insertions, 8 deletions
diff --git a/mm/memcontrol.c b/mm/memcontrol.c index 13b9d0f221b8..3427de9897a5 100644 --- a/mm/memcontrol.c +++ b/mm/memcontrol.c | |||
@@ -2984,21 +2984,14 @@ static int memcg_charge_kmem(struct mem_cgroup *memcg, gfp_t gfp, u64 size) | |||
2984 | struct res_counter *fail_res; | 2984 | struct res_counter *fail_res; |
2985 | struct mem_cgroup *_memcg; | 2985 | struct mem_cgroup *_memcg; |
2986 | int ret = 0; | 2986 | int ret = 0; |
2987 | bool may_oom; | ||
2988 | 2987 | ||
2989 | ret = res_counter_charge(&memcg->kmem, size, &fail_res); | 2988 | ret = res_counter_charge(&memcg->kmem, size, &fail_res); |
2990 | if (ret) | 2989 | if (ret) |
2991 | return ret; | 2990 | return ret; |
2992 | 2991 | ||
2993 | /* | ||
2994 | * Conditions under which we can wait for the oom_killer. Those are | ||
2995 | * the same conditions tested by the core page allocator | ||
2996 | */ | ||
2997 | may_oom = (gfp & __GFP_FS) && !(gfp & __GFP_NORETRY); | ||
2998 | |||
2999 | _memcg = memcg; | 2992 | _memcg = memcg; |
3000 | ret = __mem_cgroup_try_charge(NULL, gfp, size >> PAGE_SHIFT, | 2993 | ret = __mem_cgroup_try_charge(NULL, gfp, size >> PAGE_SHIFT, |
3001 | &_memcg, may_oom); | 2994 | &_memcg, oom_gfp_allowed(gfp)); |
3002 | 2995 | ||
3003 | if (ret == -EINTR) { | 2996 | if (ret == -EINTR) { |
3004 | /* | 2997 | /* |