Re: [PATCH] mm: use softleaf_migration_mkreadable() in change_protection()

From: Muchun Song

Date: Wed Dec 02 2026 - 22:15:10 EST




> On Dec 2, 2026, at 12:59, Chris Down <chris@xxxxxxxxxxxxxx> wrote:
>
> change_protection() downgrades a writable migration entry to a readable
> one in change_softleaf_pte(), change_non_present_huge_pmd() and
> hugetlb_change_protection(). Each of them open codes the same choice:
> the new entry is readable exclusive if the folio is anonymous, since a
> writable anon migration entry implies AnonExclusive, and plain readable
> otherwise.
>
> PAGEMAP_SCAN's write-protect path needed the same downgrade, so
> softleaf_migration_mkreadable() was added to leafops.h for it. Let's use
> it in change_protection() too. Each site still handles the soft-dirty
> and uffd bits itself as before. hugetlb_change_protection() only looked
> up the folio for this choice, so its local goes away.
>
> The other places that choose between readable exclusive and readable
> migration entries, such as try_to_migrate_one() and
> __split_huge_pmd_locked(), carry over the exclusive state of the page or
> of the old entry rather than downgrade a writable one, so they are left
> alone.
>
> No functional change intended.
>
> Suggested-by: Lorenzo Stoakes (ARM) <ljs@xxxxxxxxxx>
> Signed-off-by: Chris Down <chris@xxxxxxxxxxxxxx>

Nive cleanup.

Acked-by: Muchun Song (ByteDance) <muchun.song@xxxxxxxxx>

THanks.