Subject: memcontrol: do not oom on huge pages, fall back to normal pages From: Johannes Weiner Do not invoke the oom killer when failing to charge a huge page, instead bail out and let the fault handler fall back to normal pages. This allows extreme cases to survive and max out the limit with normal pages, where they would have been killed prematurely otherwise. Signed-off-by: Johannes Weiner Signed-off-by: Andrea Arcangeli --- diff --git a/mm/memcontrol.c b/mm/memcontrol.c index c395dcc..8454432 100644 --- a/mm/memcontrol.c +++ b/mm/memcontrol.c @@ -1672,6 +1672,15 @@ static int __mem_cgroup_try_charge(struct mm_struct *mm, if (mem_cgroup_check_room(mem_over_limit, csize)) continue; + /* + * With normal pages we should think about OOM now, + * but huge pages we can just fail, signalling the + * huge page fault handler to fall back to regular + * pages. + */ + if (csize > PAGE_SIZE) + goto nomem; + /* try to avoid oom while someone is moving charge */ if (mc.moving_task && current != mc.moving_task) { struct mem_cgroup *from, *to;