Re: [PATCH v3 13/16] mm: remove non_swap_entry() and use softleaf helpers instead

From: Vlastimil Babka

Date: Thu Nov 27 2025 - 12:12:34 EST


On 11/10/25 23:21, Lorenzo Stoakes wrote:
> There is simply no need for the hugely confusing concept of 'non-swap' swap
> entries now we have the concept of softleaf entries and relevant
> softleaf_xxx() helpers.
>
> Adjust all callers to use these instead and remove non_swap_entry()
> altogether.
>
> No functional change intended.
>
> Signed-off-by: Lorenzo Stoakes <lorenzo.stoakes@xxxxxxxxxx>

Nice!

Reviewed-by: Vlastimil Babka <vbabka@xxxxxxx>

> @@ -1430,19 +1429,20 @@ static long move_pages_ptes(struct mm_struct *mm, pmd_t *dst_pmd, pmd_t *src_pmd
> orig_dst_pte, orig_src_pte, dst_pmd,
> dst_pmdval, dst_ptl, src_ptl, &src_folio,
> len);
> - } else {
> + } else { /* !pte_present() */
> struct folio *folio = NULL;
> + const softleaf_t entry = softleaf_from_pte(orig_src_pte);
>
> - entry = pte_to_swp_entry(orig_src_pte);
> - if (non_swap_entry(entry)) {
> - if (is_migration_entry(entry)) {
> - pte_unmap(src_pte);
> - pte_unmap(dst_pte);
> - src_pte = dst_pte = NULL;
> - migration_entry_wait(mm, src_pmd, src_addr);
> - ret = -EAGAIN;
> - } else
> - ret = -EFAULT;

Eww, good to get rid of this.

> + if (softleaf_is_migration(entry)) {
> + pte_unmap(src_pte);
> + pte_unmap(dst_pte);
> + src_pte = dst_pte = NULL;
> + migration_entry_wait(mm, src_pmd, src_addr);
> +
> + ret = -EAGAIN;
> + goto out;
> + } else if (!softleaf_is_swap(entry)) {
> + ret = -EFAULT;
> goto out;
> }
>