Re: [RESEND v7 11/29] mm: split PMD swap entries into PTE swap entries
From: David Hildenbrand (Arm)
Date: Thu Sep 24 2026 - 16:00:39 EST
>
> Done, it reads better than I expected, because the three bit tests
> hoist out of the loop rather than running HPAGE_PMD_NR times:
>
> } else if (pmd_is_swap_entry(old_pmd)) {
> pte_t entry = softleaf_to_pte(softleaf_from_pmd(old_pmd));
>
> if (soft_dirty)
> entry = pte_swp_mksoft_dirty(entry);
> if (uffd_wp)
> entry = pte_swp_mkuffd(entry);
> if (anon_exclusive)
> entry = pte_swp_mkexclusive(entry);
>
> for (i = 0, addr = haddr; i < HPAGE_PMD_NR;
> i++, addr += PAGE_SIZE) {
> VM_WARN_ON(!pte_none(ptep_get(pte + i)));
> set_pte_at(mm, addr, pte + i, entry);
> entry = pte_next_swp_offset(entry);
> }
>
pte_next_swp_offset() does something similar internally. I suspect there could
be ways to optimize that out ... anyhow, good enough for now :)
--
Cheers,
David