Skip to content

Commit

Permalink
mm: do_swap_page(): fix up the error code
Browse files Browse the repository at this point in the history
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/[email protected]
Fixes: 4c6355b ("mm: memcontrol: charge swapin pages on instantiation")
Signed-off-by: Michal Hocko <[email protected]>
Acked-by: Johannes Weiner <[email protected]>
Cc: Alex Shi <[email protected]>
Cc: Joonsoo Kim <[email protected]>
Cc: Shakeel Butt <[email protected]>
Cc: Hugh Dickins <[email protected]>
Cc: "Kirill A. Shutemov" <[email protected]>
Cc: Roman Gushchin <[email protected]>
Signed-off-by: Andrew Morton <[email protected]>
Signed-off-by: Linus Torvalds <[email protected]>
  • Loading branch information
Michal Hocko authored and torvalds committed Jun 26, 2020
1 parent 313a525 commit 545b1b0
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion mm/memory.c
Original file line number Diff line number Diff line change
Expand Up @@ -3140,8 +3140,10 @@ vm_fault_t do_swap_page(struct vm_fault *vmf)
err = mem_cgroup_charge(page, vma->vm_mm,
GFP_KERNEL);
ClearPageSwapCache(page);
if (err)
if (err) {
ret = VM_FAULT_OOM;
goto out_page;
}

lru_cache_add(page);
swap_readpage(page, true);
Expand Down

0 comments on commit 545b1b0

Please sign in to comment.