[PATCH] Partly revert "mm/thp: carry over dirty bit when thp splits on pmd"

From: Peter Xu
Date: Sun Oct 23 2022 - 15:29:29 EST


Anatoly Pugachev <matorola@xxxxxxxxx> reported sparc64 breakage on the
patch:

https://lore.kernel.org/r/20221021160603.GA23307@xxxxxxxxxxxx

The sparc64 impl of pte_mkdirty() is definitely slightly special in that it
leverages a code patching mechanism for sun4u/sun4v on relevant pgtable
entry operations.

Before having a clue of why the sparc64 is special and caused the patch to
SIGSEGV the processes, revert the patch for now. The swap path of dirty
bit inheritage is kept because that's using the swap shared code so we
assume it'll not be affected.

Signed-off-by: Peter Xu <peterx@xxxxxxxxxx>
---
mm/huge_memory.c | 9 ++++++---
1 file changed, 6 insertions(+), 3 deletions(-)

diff --git a/mm/huge_memory.c b/mm/huge_memory.c
index ad17c8d3c0fe..72b9b4622a38 100644
--- a/mm/huge_memory.c
+++ b/mm/huge_memory.c
@@ -2160,9 +2160,12 @@ static void __split_huge_pmd_locked(struct vm_area_struct *vma, pmd_t *pmd,
entry = pte_wrprotect(entry);
if (!young)
entry = pte_mkold(entry);
- /* NOTE: this may set soft-dirty too on some archs */
- if (dirty)
- entry = pte_mkdirty(entry);
+ /*
+ * NOTE: we don't do pte_mkdirty when dirty==true
+ * because it breaks sparc64 which can sigsegv
+ * random process. Need to revisit when we figure
+ * out what is special with sparc64.
+ */
if (soft_dirty)
entry = pte_mksoft_dirty(entry);
if (uffd_wp)
--
2.37.3


--V+D6jZxSD7O649r4--