Commit 545b1b07 authored by Michal Hocko's avatar Michal Hocko Committed by Linus Torvalds

mm: do_swap_page(): fix up the error code

do_swap_page() returns error codes from the VM_FAULT* space.  try_charge()
might return -ENOMEM, though, and then do_swap_page() simply returns 0
which means a success.

We almost never return ENOMEM for GFP_KERNEL single page charge.  Except
for async OOM handling (oom_disabled v1).  So this needs translation to
VM_FAULT_OOM otherwise the the page fault path will not notify the
userspace and wait for an action.

Link: http://lkml.kernel.org/r/20200617090238.GL9499@dhcp22.suse.cz
Fixes: 4c6355b2 ("mm: memcontrol: charge swapin pages on instantiation")
Signed-off-by: default avatarMichal Hocko <mhocko@suse.com>
Acked-by: default avatarJohannes Weiner <hannes@cmpxchg.org>
Cc: Alex Shi <alex.shi@linux.alibaba.com>
Cc: Joonsoo Kim <js1304@gmail.com>
Cc: Shakeel Butt <shakeelb@google.com>
Cc: Hugh Dickins <hughd@google.com>
Cc: "Kirill A. Shutemov" <kirill@shutemov.name>
Cc: Roman Gushchin <guro@fb.com>
Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
parent 313a5257
...@@ -3140,8 +3140,10 @@ vm_fault_t do_swap_page(struct vm_fault *vmf) ...@@ -3140,8 +3140,10 @@ vm_fault_t do_swap_page(struct vm_fault *vmf)
err = mem_cgroup_charge(page, vma->vm_mm, err = mem_cgroup_charge(page, vma->vm_mm,
GFP_KERNEL); GFP_KERNEL);
ClearPageSwapCache(page); ClearPageSwapCache(page);
if (err) if (err) {
ret = VM_FAULT_OOM;
goto out_page; goto out_page;
}
lru_cache_add(page); lru_cache_add(page);
swap_readpage(page, true); swap_readpage(page, true);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment