mm/khugepaged: stop swapping in page when VM_FAULT_RETRY occurs
authorMiaohe Lin <linmiaohe@huawei.com>
Sat, 25 Jun 2022 09:28:11 +0000 (17:28 +0800)
committerakpm <akpm@linux-foundation.org>
Mon, 4 Jul 2022 01:08:51 +0000 (18:08 -0700)
commit4d928e20fd5b9fd97e1e631500386ef12a2858d7
tree9d01290c76ccf5a0a2742225fcbe370f597f5317
parentdd5ff79d4ab85ac0cdb5f87e8fee4c4725255c4b
mm/khugepaged: stop swapping in page when VM_FAULT_RETRY occurs

When do_swap_page returns VM_FAULT_RETRY, we do not retry here and thus
swap entry will remain in pagetable.  This will result in later failure.
So stop swapping in pages in this case to save cpu cycles.  As A further
optimization, mmap_lock is released when __collapse_huge_page_swapin()
fails to avoid relocking mmap_lock.  And "swapped_in++" is moved after
error handling to make it more accurate.

Link: https://lkml.kernel.org/r/20220625092816.4856-3-linmiaohe@huawei.com
Signed-off-by: Miaohe Lin <linmiaohe@huawei.com>
Cc: Alistair Popple <apopple@nvidia.com>
Cc: Andrea Arcangeli <aarcange@redhat.com>
Cc: David Hildenbrand <david@redhat.com>
Cc: David Howells <dhowells@redhat.com>
Cc: Matthew Wilcox (Oracle) <willy@infradead.org>
Cc: NeilBrown <neilb@suse.de>
Cc: Peter Xu <peterx@redhat.com>
Cc: Suren Baghdasaryan <surenb@google.com>
Cc: Vlastimil Babka <vbabka@suse.cz>
Cc: Yang Shi <shy828301@gmail.com>
Cc: Zach O'Keefe <zokeefe@google.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
mm/khugepaged.c