zap_huge_pmd() assumes any non-present PMD it clears references a folio, so a PMD swap entry would reach normal_or_softleaf_folio_pmd() and warn. Worse, nothing would release the slots it points at: unmapping a swapped-out THP would leak the whole PMD's worth of swap. Handle it before the folio lookup, as zap_pte_range() already does for a PTE swap entry. Signed-off-by: Usama Arif --- mm/huge_memory.c | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/mm/huge_memory.c b/mm/huge_memory.c index 56eb87fa98376..9cf7c4747cac9 100644 --- a/mm/huge_memory.c +++ b/mm/huge_memory.c @@ -2605,6 +2605,16 @@ bool zap_huge_pmd(struct mmu_gather *tlb, struct vm_area_struct *vma, arch_check_zapped_pmd(vma, orig_pmd); tlb_remove_pmd_tlb_entry(tlb, pmd, addr); + if (pmd_is_swap_entry(orig_pmd)) { + softleaf_t entry = softleaf_from_pmd(orig_pmd); + + zap_deposited_table(mm, pmd); + spin_unlock(ptl); + swap_put_entries_direct(entry, HPAGE_PMD_NR); + add_mm_counter(mm, MM_SWAPENTS, -HPAGE_PMD_NR); + return true; + } + is_present = pmd_present(orig_pmd); folio = normal_or_softleaf_folio_pmd(vma, addr, orig_pmd, is_present); has_deposit = has_deposited_pgtable(vma, orig_pmd, folio); -- 2.53.0-Meta