This ports the switching from page to folio in add_to_swap_cache(). We saw multiple different hangs on mmap_lock, where the task holding the lock was livelocked spinning in this stack:
+-> __x64_sys_ioctl +-> kvm_vcpu_ioctl +-> kvm_arch_vcpu_ioctl_run +-> vcpu_run +-> vcpu_enter_guest +-> kvm_mmu_page_fault +-> kvm_tdp_page_fault +-> kvm_faultin_pfn +-> __kvm_faultin_pfn +-> hva_to_pfn +-> get_user_pages_unlocked +-> get_user_pages_unlocked +-> mmap_read_lock # 1 +-> __get_user_pages_locked # 2 +-> for-loop # taken once +-> __get_user_pages +-> retry-loop # constantly spinning +-> faultin_page # return 0 to trigger retry +-> handle_mm_fault +-> __handle_mm_fault +-> handle_pte_fault +-> do_swap_page +-> lookup_swap_cache # returns non-NULL +-> if (swapcache) +-> if (!folio_test_swapcache || page_private(page) != entry.val) +-> goto out_page +-> return 0 That can be due to an inconsistency in swapcache flag setting/reading, one can see that PageSwapCache reads the flag from folio, but SetPageSwapCache/ClearPageSwapCache instead affect the flag from page. After applying those patches SetPageSwapCache/ClearPageSwapCache become unused, thus all paths seek this flag from folio now. With it I don't see any hangs on mmap_lock anymore (on the same test setup). https://virtuozzo.atlassian.net/browse/PSBM-153264 Signed-off-by: Pavel Tikhomirov <ptikhomi...@virtuozzo.com> Matthew Wilcox (Oracle) (2): mm/swap: convert __read_swap_cache_async() to use a folio mm/swap: convert add_to_swap_cache() to take a folio mm/shmem.c | 2 +- mm/swap.h | 4 +-- mm/swap_state.c | 71 +++++++++++++++++++++++++------------------------ 3 files changed, 39 insertions(+), 38 deletions(-) -- 2.43.0 _______________________________________________ Devel mailing list Devel@openvz.org https://lists.openvz.org/mailman/listinfo/devel