mm/huge_memory: revert "Partly revert "mm/thp: carry over dirty bit when thp splits on pmd""

This reverts commit 624a2c94f5 ("Partly revert "mm/thp: carry over dirty
bit when thp splits on pmd"") and the fixup in commit e833bc5034
("mm/thp: re-apply mkdirty for small pages after split").

Now that sparc64 mkdirty handling is fixed and no longer sets a PTE/PMD
writable that shouldn't be writable, let's revert the temporary fix and
remove the stale comment.

The mkdirty mm selftest still passes with this change on sparc64.

Note that loongarch handling was fixed in commit bf2f34a506 ("LoongArch:
Set _PAGE_DIRTY only if _PAGE_WRITE is set in {pmd,pte}_mkdirty()")

Link: https://lkml.kernel.org/r/20230411142512.438404-6-david@redhat.com
Signed-off-by: David Hildenbrand <david@redhat.com>
Cc: Anshuman Khandual <anshuman.khandual@arm.com>
Cc: David S. Miller <davem@davemloft.net>
Cc: Hugh Dickins <hughd@google.com>
Cc: Peter Xu <peterx@redhat.com>
Cc: Sam Ravnborg <sam@ravnborg.org>
Cc: Shuah Khan <shuah@kernel.org>
Cc: Yu Zhao <yuzhao@google.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
This commit is contained in:
David Hildenbrand 2023-04-11 16:25:11 +02:00 committed by Andrew Morton
parent 3c811f7883
commit 5436d65569
1 changed files with 2 additions and 7 deletions

View File

@ -2236,18 +2236,13 @@ static void __split_huge_pmd_locked(struct vm_area_struct *vma, pmd_t *pmd,
entry = maybe_mkwrite(entry, vma); entry = maybe_mkwrite(entry, vma);
if (anon_exclusive) if (anon_exclusive)
SetPageAnonExclusive(page + i); SetPageAnonExclusive(page + i);
if (!write)
entry = pte_wrprotect(entry);
if (!young) if (!young)
entry = pte_mkold(entry); entry = pte_mkold(entry);
/* NOTE: this may set soft-dirty too on some archs */ /* NOTE: this may set soft-dirty too on some archs */
if (dirty) if (dirty)
entry = pte_mkdirty(entry); entry = pte_mkdirty(entry);
/*
* NOTE: this needs to happen after pte_mkdirty,
* because some archs (sparc64, loongarch) could
* set hw write bit when mkdirty.
*/
if (!write)
entry = pte_wrprotect(entry);
if (soft_dirty) if (soft_dirty)
entry = pte_mksoft_dirty(entry); entry = pte_mksoft_dirty(entry);
if (uffd_wp) if (uffd_wp)