Skip to content

Commit 96a9c28

Browse files
xzpeterakpm00
authored andcommitted
mm/migrate: fix wrongly apply write bit after mkdirty on sparc64
Nick Bowler reported another sparc64 breakage after the young/dirty persistent work for page migration (per "Link:" below). That's after a similar report [2]. It turns out page migration was overlooked, and it wasn't failing before because page migration was not enabled in the initial report test environment. David proposed another way [2] to fix this from sparc64 side, but that patch didn't land somehow. Neither did I check whether there's any other arch that has similar issues. Let's fix it for now as simple as moving the write bit handling to be after dirty, like what we did before. Note: this is based on mm-unstable, because the breakage was since 6.1 and we're at a very late stage of 6.2 (-rc8), so I assume for this specific case we should target this at 6.3. [1] https://lore.kernel.org/all/[email protected]/ [2] https://lore.kernel.org/all/[email protected]/ Link: https://lkml.kernel.org/r/[email protected] Fixes: 2e34687 ("mm: remember young/dirty bit for page migrations") Link: https://lore.kernel.org/all/CADyTPExpEqaJiMGoV+Z6xVgL50ZoMJg49B10LcZ=8eg19u34BA@mail.gmail.com/ Signed-off-by: Peter Xu <[email protected]> Reported-by: Nick Bowler <[email protected]> Acked-by: David Hildenbrand <[email protected]> Tested-by: Nick Bowler <[email protected]> Cc: <[email protected]> Cc: <[email protected]> Signed-off-by: Andrew Morton <[email protected]>
1 parent 5c7388b commit 96a9c28

File tree

2 files changed

+6
-2
lines changed

2 files changed

+6
-2
lines changed

mm/huge_memory.c

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3272,15 +3272,17 @@ void remove_migration_pmd(struct page_vma_mapped_walk *pvmw, struct page *new)
32723272
pmde = mk_huge_pmd(new, READ_ONCE(vma->vm_page_prot));
32733273
if (pmd_swp_soft_dirty(*pvmw->pmd))
32743274
pmde = pmd_mksoft_dirty(pmde);
3275-
if (is_writable_migration_entry(entry))
3276-
pmde = maybe_pmd_mkwrite(pmde, vma);
32773275
if (pmd_swp_uffd_wp(*pvmw->pmd))
32783276
pmde = pmd_wrprotect(pmd_mkuffd_wp(pmde));
32793277
if (!is_migration_entry_young(entry))
32803278
pmde = pmd_mkold(pmde);
32813279
/* NOTE: this may contain setting soft-dirty on some archs */
32823280
if (PageDirty(new) && is_migration_entry_dirty(entry))
32833281
pmde = pmd_mkdirty(pmde);
3282+
if (is_writable_migration_entry(entry))
3283+
pmde = maybe_pmd_mkwrite(pmde, vma);
3284+
else
3285+
pmde = pmd_wrprotect(pmde);
32843286

32853287
if (PageAnon(new)) {
32863288
rmap_t rmap_flags = RMAP_COMPOUND;

mm/migrate.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -224,6 +224,8 @@ static bool remove_migration_pte(struct folio *folio,
224224
pte = maybe_mkwrite(pte, vma);
225225
else if (pte_swp_uffd_wp(*pvmw.pte))
226226
pte = pte_mkuffd_wp(pte);
227+
else
228+
pte = pte_wrprotect(pte);
227229

228230
if (folio_test_anon(folio) && !is_readable_migration_entry(entry))
229231
rmap_flags |= RMAP_EXCLUSIVE;

0 commit comments

Comments
 (0)