The patch titled Subject: swap: Deal with PTE mapped THP when unuse PTE has been added to the -mm tree. Its filename is mm-rid-swapoff-of-quadratic-complexity-fix-2.patch This patch should soon appear at http://ozlabs.org/~akpm/mmots/broken-out/mm-rid-swapoff-of-quadratic-complexity-fix-2.patch and later at http://ozlabs.org/~akpm/mmotm/broken-out/mm-rid-swapoff-of-quadratic-complexity-fix-2.patch Before you just go and hit "reply", please: a) Consider who else should be cc'ed b) Prefer to cc a suitable mailing list as well c) Ideally: find the original patch on the mailing list and do a reply-to-all to that, adding suitable additional cc's *** Remember to use Documentation/process/submit-checklist.rst when testing your code *** The -mm tree is included into linux-next and is updated there every 3-4 working days ------------------------------------------------------ From: Huang Ying <ying.huang@xxxxxxxxx> Subject: swap: Deal with PTE mapped THP when unuse PTE A PTE swap entry may map to a normal swap slot inside a huge swap cluster. To free the huge swap cluster and the corresponding THP (transparent huge page), all PTE swap entry mappings need to be unmapped. The original implementation only checks current PTE swap entry mapping, this is fixed via calling try_to_free_swap() instead, which will check all PTE swap mappings inside the huge swap cluster. This fix could be folded into the patch: mm, swap: rid swapoff of quadratic complexity in -mm patchset. Link: http://lkml.kernel.org/r/20181211084609.19553-2-ying.huang@xxxxxxxxx Signed-off-by: "Huang, Ying" <ying.huang@xxxxxxxxx> Reviewed-by: William Kucharski <william.kucharski@xxxxxxxxxx> Cc: Vineeth Remanan Pillai <vpillai@xxxxxxxxxxxxxxxx> Cc: Kelley Nielsen <kelleynnn@xxxxxxxxx> Cc: Rik van Riel <riel@xxxxxxxxxxx> Cc: Matthew Wilcox <willy@xxxxxxxxxxxxx> Cc: Hugh Dickins <hughd@xxxxxxxxxx> Signed-off-by: Andrew Morton <akpm@xxxxxxxxxxxxxxxxxxxx> --- mm/swapfile.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) --- a/mm/swapfile.c~mm-rid-swapoff-of-quadratic-complexity-fix-2 +++ a/mm/swapfile.c @@ -1853,10 +1853,8 @@ static int unuse_pte_range(struct vm_are goto out; } - if (PageSwapCache(page) && (swap_count(*swap_map) == 0)) - delete_from_swap_cache(compound_head(page)); + try_to_free_swap(page); - SetPageDirty(page); unlock_page(page); put_page(page); _ Patches currently in -mm which might be from ying.huang@xxxxxxxxx are mm-rid-swapoff-of-quadratic-complexity-fix-1.patch mm-rid-swapoff-of-quadratic-complexity-fix-2.patch mm-swap-fix-race-between-swapoff-and-some-swap-operations.patch mm-swap-fix-race-between-swapoff-and-some-swap-operations-v6.patch mm-fix-race-between-swapoff-and-mincore.patch