Skip to content

Commit 545b1b0

Browse files
Michal Hockotorvalds
authored andcommitted
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/[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]>
1 parent 313a525 commit 545b1b0

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

mm/memory.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3140,8 +3140,10 @@ vm_fault_t do_swap_page(struct vm_fault *vmf)
31403140
err = mem_cgroup_charge(page, vma->vm_mm,
31413141
GFP_KERNEL);
31423142
ClearPageSwapCache(page);
3143-
if (err)
3143+
if (err) {
3144+
ret = VM_FAULT_OOM;
31443145
goto out_page;
3146+
}
31453147

31463148
lru_cache_add(page);
31473149
swap_readpage(page, true);

0 commit comments

Comments
 (0)