Skip to contentSkip to conversation

mm/autonuma: Let architecture override how the write bit should be stashed in a protnone pte.

PATCH Superseded Aneesh Kumar K.V 4 participants 8 messages Feb 9, 2017 – Feb 16, 2017

Subsystems (6)

v1 of 3 Superseded Latest is v3 →

lore
Share & tools
lore
#0 lore raw

PATCH 1/2 mm/autonuma: Let architecture override how the write bit should be stashed in a protnone pte.

Autonuma preserves the write permission across numa fault to avoid taking a writefault after a numa fault (Commit: b191f9b106ea " mm: numa: preserve PTE write permissions across a NUMA hinting fault"). Architecture can implement protnone in different ways and some may choose to implement that by clearing Read/ Write/Exec bit of pte. Setting the write bit on such pte can result in wrong behaviour. Fix this up by allowing arch to override how to save the write bit on a protnone pte.

---
 include/asm-generic/pgtable.h | 16 ++++++++++++++++
 mm/huge_memory.c              |  4 ++--
 mm/memory.c                   |  2 +-
 mm/mprotect.c                 |  4 ++--
 4 files changed, 21 insertions(+), 5 deletions(-)
include/asm-generic/pgtable.h +16 -0
index 18af2bcefe6a..b6f3a8a4b738 100644
@@ -192,6 +192,22 @@ static inline void ptep_set_wrprotect(struct mm_struct *mm, unsigned long addres
 }
 #endif
 
+#ifndef pte_savedwrite
+#define pte_savedwrite pte_write
+#endif
+
+#ifndef pte_mk_savedwrite
+#define pte_mk_savedwrite pte_mkwrite
+#endif
+
+#ifndef pmd_savedwrite
+#define pmd_savedwrite pmd_write
+#endif
+
+#ifndef pmd_mk_savedwrite
+#define pmd_mk_savedwrite pmd_mkwrite
+#endif
+
 #ifndef __HAVE_ARCH_PMDP_SET_WRPROTECT
 #ifdef CONFIG_TRANSPARENT_HUGEPAGE
 static inline void pmdp_set_wrprotect(struct mm_struct *mm,
mm/huge_memory.c +2 -2
index 9a6bd6c8d55a..2f0f855ec911 100644
@@ -1300,7 +1300,7 @@ int do_huge_pmd_numa_page(struct vm_fault *vmf, pmd_t pmd)
 	goto out;
 clear_pmdnuma:
 	BUG_ON(!PageLocked(page));
-	was_writable = pmd_write(pmd);
+	was_writable = pmd_savedwrite(pmd);
 	pmd = pmd_modify(pmd, vma->vm_page_prot);
 	pmd = pmd_mkyoung(pmd);
 	if (was_writable)
@@ -1555,7 +1555,7 @@ int change_huge_pmd(struct vm_area_struct *vma, pmd_t *pmd,
 			entry = pmdp_huge_get_and_clear_notify(mm, addr, pmd);
 			entry = pmd_modify(entry, newprot);
 			if (preserve_write)
-				entry = pmd_mkwrite(entry);
+				entry = pmd_mk_savedwrite(entry);
 			ret = HPAGE_PMD_NR;
 			set_pmd_at(mm, addr, pmd, entry);
 			BUG_ON(vma_is_anonymous(vma) && !preserve_write &&
mm/memory.c +1 -1
index e78bf72f30dd..88c24f89d6d3 100644
@@ -3388,7 +3388,7 @@ static int do_numa_page(struct vm_fault *vmf)
 	int target_nid;
 	bool migrated = false;
 	pte_t pte;
-	bool was_writable = pte_write(vmf->orig_pte);
+	bool was_writable = pte_savedwrite(vmf->orig_pte);
 	int flags = 0;
 
 	/*
mm/mprotect.c +2 -2
index f9c07f54dd62..15f5c174a7c1 100644
@@ -113,13 +113,13 @@ static unsigned long change_pte_range(struct vm_area_struct *vma, pmd_t *pmd,
 			ptent = ptep_modify_prot_start(mm, addr, pte);
 			ptent = pte_modify(ptent, newprot);
 			if (preserve_write)
-				ptent = pte_mkwrite(ptent);
+				ptent = pte_mk_savedwrite(ptent);
 
 			/* Avoid taking write faults for known dirty pages */
 			if (dirty_accountable && pte_dirty(ptent) &&
 					(pte_soft_dirty(ptent) ||
 					 !(vma->vm_flags & VM_SOFTDIRTY))) {
-				ptent = pte_mkwrite(ptent);
+				ptent = pte_mk_savedwrite(ptent);
 			}
 			ptep_modify_prot_commit(mm, addr, pte, ptent);
 			pages++;
Signature · 7 lines
2.7.4

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to [email protected].  For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
#1 lore raw

PATCH 2/2 powerpc/mm/autonuma: Switch ppc64 to its own implementeation of saved write

With this our protnone becomes a present pte with READ/WRITE/EXEC bit cleared. By default we also set _PAGE_PRIVILEGED on such pte. This is now used to help us identify a protnone pte that as saved write bit. For such pte, we will clear the _PAGE_PRIVILEGED bit. The pte still remain non-accessible from both user and kernel.

---
 arch/powerpc/include/asm/book3s/64/mmu-hash.h |  3 +++
 arch/powerpc/include/asm/book3s/64/pgtable.h  | 32 +++++++++++++++++++++++++--
 2 files changed, 33 insertions(+), 2 deletions(-)
arch/powerpc/include/asm/book3s/64/mmu-hash.h +3 -0
index 0735d5a8049f..8720a406bbbe 100644
@@ -16,6 +16,9 @@
 #include <asm/page.h>
 #include <asm/bug.h>
 
+#ifndef __ASSEMBLY__
+#include <linux/mmdebug.h>
+#endif
 /*
  * This is necessary to get the definition of PGTABLE_RANGE which we
  * need for various slices related matters. Note that this isn't the
arch/powerpc/include/asm/book3s/64/pgtable.h +30 -2
index e91ada786d48..efff910a84b1 100644
@@ -443,8 +443,8 @@ static inline pte_t pte_clear_soft_dirty(pte_t pte)
  */
 static inline int pte_protnone(pte_t pte)
 {
-	return (pte_raw(pte) & cpu_to_be64(_PAGE_PRESENT | _PAGE_PRIVILEGED)) ==
-		cpu_to_be64(_PAGE_PRESENT | _PAGE_PRIVILEGED);
+	return (pte_raw(pte) & cpu_to_be64(_PAGE_PRESENT | _PAGE_RWX)) ==
+		cpu_to_be64(_PAGE_PRESENT);
 }
 #endif /* CONFIG_NUMA_BALANCING */
 
@@ -514,6 +514,32 @@ static inline pte_t pte_mkhuge(pte_t pte)
 	return pte;
 }
 
+#define pte_mk_savedwrite pte_mk_savedwrite
+static inline pte_t pte_mk_savedwrite(pte_t pte)
+{
+	/*
+	 * Used by Autonuma subsystem to preserve the write bit
+	 * while marking the pte PROT_NONE. Only allow this
+	 * on PROT_NONE pte
+	 */
+	VM_BUG_ON((pte_raw(pte) & cpu_to_be64(_PAGE_PRESENT | _PAGE_RWX | _PAGE_PRIVILEGED)) !=
+		  cpu_to_be64(_PAGE_PRESENT | _PAGE_PRIVILEGED));
+	return __pte(pte_val(pte) & ~_PAGE_PRIVILEGED);
+}
+
+#define pte_savedwrite pte_savedwrite
+static inline bool pte_savedwrite(pte_t pte)
+{
+	/*
+	 * Saved write ptes are prot none ptes that doesn't have
+	 * privileged bit sit. We mark prot none as one which has
+	 * present and pviliged bit set and RWX cleared. To mark
+	 * protnone which used to have _PAGE_WRITE set we clear
+	 * the privileged bit.
+	 */
+	return !(pte_raw(pte) & cpu_to_be64(_PAGE_RWX | _PAGE_PRIVILEGED));
+}
+
 static inline pte_t pte_mkdevmap(pte_t pte)
 {
 	return __pte(pte_val(pte) | _PAGE_SPECIAL|_PAGE_DEVMAP);
@@ -885,6 +911,7 @@ static inline pte_t *pmdp_ptep(pmd_t *pmd)
 #define pmd_mkclean(pmd)	pte_pmd(pte_mkclean(pmd_pte(pmd)))
 #define pmd_mkyoung(pmd)	pte_pmd(pte_mkyoung(pmd_pte(pmd)))
 #define pmd_mkwrite(pmd)	pte_pmd(pte_mkwrite(pmd_pte(pmd)))
+#define pmd_mk_savedwrite(pmd)	pte_pmd(pte_mk_savedwrite(pmd_pte(pmd)))
 
 #ifdef CONFIG_HAVE_ARCH_SOFT_DIRTY
 #define pmd_soft_dirty(pmd)    pte_soft_dirty(pmd_pte(pmd))
@@ -901,6 +928,7 @@ static inline int pmd_protnone(pmd_t pmd)
 
 #define __HAVE_ARCH_PMD_WRITE
 #define pmd_write(pmd)		pte_write(pmd_pte(pmd))
+#define pmd_savedwrite(pmd)	pte_savedwrite(pmd_pte(pmd))
 
 #ifdef CONFIG_TRANSPARENT_HUGEPAGE
 extern pmd_t pfn_pmd(unsigned long pfn, pgprot_t pgprot);
Signature · 7 lines
2.7.4

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to [email protected].  For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
Acked-by on v1 2/2
#2 lore raw

Re: [PATCH 2/2] powerpc/mm/autonuma: Switch ppc64 to its own implementeation of saved write

Quoted 8 lines · Aneesh Kumar K.V

With this our protnone becomes a present pte with READ/WRITE/EXEC bit cleared. By default we also set _PAGE_PRIVILEGED on such pte. This is now used to help us identify a protnone pte that as saved write bit. For such pte, we will clear
the _PAGE_PRIVILEGED bit. The pte still remain non-accessible from both user and kernel.

FWIW I've tested this, so:

Quoted 89 lines

---
 arch/powerpc/include/asm/book3s/64/mmu-hash.h |  3 +++ arch/powerpc/include/asm/book3s/64/pgtable.h  | 32 +++++++++++++++++++++++++- -

 2 files changed, 33 insertions(+), 2 deletions(-)
arch/powerpc/include/asm/book3s/64/mmu-hash.h +0 -0
index 0735d5a8049f..8720a406bbbe 100644
@@ -16,6 +16,9 @@
  #include <asm/page.h>
  #include <asm/bug.h>

arch/powerpc/include/asm/book3s/64/mmu-hash.h +3 -0
+#ifndef __ASSEMBLY__
+#include <linux/mmdebug.h>
+#endif

 /*
  * This is necessary to get the definition of PGTABLE_RANGE which we
  * need for various slices related matters. Note that this isn't the

arch/powerpc/include/asm/book3s/64/pgtable.h +0 -1
index e91ada786d48..efff910a84b1 100644
@@ -443,8 +443,8 @@ static inline pte_t pte_clear_soft_dirty(pte_t pte)
   */
  static inline int pte_protnone(pte_t pte)
  {
-	return (pte_raw(pte) & cpu_to_be64(_PAGE_PRESENT | _PAGE_PRIVILEGED))

==

arch/powerpc/include/asm/book3s/64/pgtable.h +2 -1
-		cpu_to_be64(_PAGE_PRESENT | _PAGE_PRIVILEGED);
+	return (pte_raw(pte) & cpu_to_be64(_PAGE_PRESENT | _PAGE_RWX)) ==
+		cpu_to_be64(_PAGE_PRESENT);

 }
 #endif /* CONFIG_NUMA_BALANCING */

arch/powerpc/include/asm/book3s/64/pgtable.h +0 -0
@@ -514,6 +514,32 @@ static inline pte_t pte_mkhuge(pte_t pte)
  	return pte;
  }

arch/powerpc/include/asm/book3s/64/pgtable.h +9 -0
+#define pte_mk_savedwrite pte_mk_savedwrite
+static inline pte_t pte_mk_savedwrite(pte_t pte)
+{
+	/*
+	 * Used by Autonuma subsystem to preserve the write bit
+	 * while marking the pte PROT_NONE. Only allow this
+	 * on PROT_NONE pte
+	 */
+	VM_BUG_ON((pte_raw(pte) & cpu_to_be64(_PAGE_PRESENT | _PAGE_RWX |

_PAGE_PRIVILEGED)) !=

arch/powerpc/include/asm/book3s/64/pgtable.h +17 -0
+		  cpu_to_be64(_PAGE_PRESENT | _PAGE_PRIVILEGED));
+	return __pte(pte_val(pte) & ~_PAGE_PRIVILEGED);
+}
+
+#define pte_savedwrite pte_savedwrite
+static inline bool pte_savedwrite(pte_t pte)
+{
+	/*
+	 * Saved write ptes are prot none ptes that doesn't have
+	 * privileged bit sit. We mark prot none as one which has
+	 * present and pviliged bit set and RWX cleared. To mark
+	 * protnone which used to have _PAGE_WRITE set we clear
+	 * the privileged bit.
+	 */
+	return !(pte_raw(pte) & cpu_to_be64(_PAGE_RWX | _PAGE_PRIVILEGED));
+}
+

 static inline pte_t pte_mkdevmap(pte_t pte)
 {
  return __pte(pte_val(pte) | _PAGE_SPECIAL|_PAGE_DEVMAP);

arch/powerpc/include/asm/book3s/64/pgtable.h +1 -0
@@ -885,6 +911,7 @@ static inline pte_t *pmdp_ptep(pmd_t *pmd)
  #define pmd_mkclean(pmd)	pte_pmd(pte_mkclean(pmd_pte(pmd)))
  #define pmd_mkyoung(pmd)	pte_pmd(pte_mkyoung(pmd_pte(pmd)))
  #define pmd_mkwrite(pmd)	pte_pmd(pte_mkwrite(pmd_pte(pmd)))
+#define pmd_mk_savedwrite(pmd)	pte_pmd(pte_mk_savedwrite(pmd_pte(pmd))
 )


 #ifdef CONFIG_HAVE_ARCH_SOFT_DIRTY
 #define pmd_soft_dirty(pmd)    pte_soft_dirty(pmd_pte(pmd))

arch/powerpc/include/asm/book3s/64/pgtable.h +0 -0
@@ -901,6 +928,7 @@ static inline int pmd_protnone(pmd_t pmd)


 #define __HAVE_ARCH_PMD_WRITE
 #define pmd_write(pmd) pte_write(pmd_pte(pmd))
+#define pmd_savedwrite(pmd) pte_savedwrite(pmd_pte(pmd))

 #ifdef CONFIG_TRANSPARENT_HUGEPAGE
 extern pmd_t pfn_pmd(unsigned long pfn, pgprot_t pgprot);

#3 lore raw

Re: [PATCH 2/2] powerpc/mm/autonuma: Switch ppc64 to its own implementeation of saved write

Quoted 8 lines · Michael Neuling
Quoted 7 lines · Aneesh Kumar K.V

With this our protnone becomes a present pte with READ/WRITE/EXEC bit cleared. By default we also set _PAGE_PRIVILEGED on such pte. This is now used to help us identify a protnone pte that as saved write bit. For such pte, we will clear
the _PAGE_PRIVILEGED bit. The pte still remain non-accessible from both user and kernel.

Quoted 6 lines
Quoted 1 line

FWIW I've tested this, so:

In future if you've tested something then "Tested-by:" is the right tag to use.

cheers

maintainer
#4 lore raw

Re: [PATCH 2/2] powerpc/mm/autonuma: Switch ppc64 to its own implementeation of saved write

In reply to Aneesh Kumar K.V
Quoted 5 lines · On Thu, 9 Feb 2017 08:30:59 +0530 "Aneesh Kumar K.V"…

With this our protnone becomes a present pte with READ/WRITE/EXEC bit cleared. By default we also set _PAGE_PRIVILEGED on such pte. This is now used to help us identify a protnone pte that as saved write bit. For such pte, we will clear the _PAGE_PRIVILEGED bit. The pte still remain non-accessible from both user and kernel.

I don't see how these patches differ from the ones which are presently in -mm.

It helps to have a [0/n] email for a patch series and to put a version number in there as well.

Quoted 19 lines
arch/powerpc/include/asm/book3s/64/pgtable.h +19 -0
+#define pte_mk_savedwrite pte_mk_savedwrite
+static inline pte_t pte_mk_savedwrite(pte_t pte)
+{
+	/*
+	 * Used by Autonuma subsystem to preserve the write bit
+	 * while marking the pte PROT_NONE. Only allow this
+	 * on PROT_NONE pte
+	 */
+	VM_BUG_ON((pte_raw(pte) & cpu_to_be64(_PAGE_PRESENT | _PAGE_RWX | _PAGE_PRIVILEGED)) !=
+		  cpu_to_be64(_PAGE_PRESENT | _PAGE_PRIVILEGED));
+	return __pte(pte_val(pte) & ~_PAGE_PRIVILEGED);
+}
+
+#define pte_savedwrite pte_savedwrite
+static inline bool pte_savedwrite(pte_t pte)
+{
+	/*
+	 * Saved write ptes are prot none ptes that doesn't have
+	 * privileged bit sit. We mark prot none as one which has

arch/powerpc/include/asm/book3s/64/pgtable.h static inline pte_t pte_mkhuge(pte_t pte) · line 545

Quoted 10 lines
arch/powerpc/include/asm/book3s/64/pgtable.h +7 -0
+	 * present and pviliged bit set and RWX cleared. To mark
+	 * protnone which used to have _PAGE_WRITE set we clear
+	 * the privileged bit.
+	 */
+	return !(pte_raw(pte) & cpu_to_be64(_PAGE_RWX | _PAGE_PRIVILEGED));
+}
+
 static inline pte_t pte_mkdevmap(pte_t pte)
 {
 	return __pte(pte_val(pte) | _PAGE_SPECIAL|_PAGE_DEVMAP);

arch/powerpc/include/asm/book3s/64/pgtable.h doesn't have pte_mkdevmap(). What tree are you patching here?

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>

#5 lore raw

Re: [PATCH 2/2] powerpc/mm/autonuma: Switch ppc64 to its own implementeation of saved write

Quoted 36 lines · Andrew Morton
Quoted 5 lines · On Thu, 9 Feb 2017 08:30:59 +0530 "Aneesh Kumar K.V"…

With this our protnone becomes a present pte with READ/WRITE/EXEC bit cleared. By default we also set _PAGE_PRIVILEGED on such pte. This is now used to help us identify a protnone pte that as saved write bit. For such pte, we will clear the _PAGE_PRIVILEGED bit. The pte still remain non-accessible from both user and kernel.

I don't see how these patches differ from the ones which are presently in -mm.

It helps to have a [0/n] email for a patch series and to put a version number in there as well.

Quoted 23 lines
arch/powerpc/include/asm/book3s/64/pgtable.h +23 -0
+#define pte_mk_savedwrite pte_mk_savedwrite
+static inline pte_t pte_mk_savedwrite(pte_t pte)
+{
+	/*
+	 * Used by Autonuma subsystem to preserve the write bit
+	 * while marking the pte PROT_NONE. Only allow this
+	 * on PROT_NONE pte
+	 */
+	VM_BUG_ON((pte_raw(pte) & cpu_to_be64(_PAGE_PRESENT | _PAGE_RWX | _PAGE_PRIVILEGED)) !=
+		  cpu_to_be64(_PAGE_PRESENT | _PAGE_PRIVILEGED));
+	return __pte(pte_val(pte) & ~_PAGE_PRIVILEGED);
+}
+
+#define pte_savedwrite pte_savedwrite
+static inline bool pte_savedwrite(pte_t pte)
+{
+	/*
+	 * Saved write ptes are prot none ptes that doesn't have
+	 * privileged bit sit. We mark prot none as one which has
+	 * present and pviliged bit set and RWX cleared. To mark
+	 * protnone which used to have _PAGE_WRITE set we clear
+	 * the privileged bit.
+	 */
Quoted 10 lines

arch/powerpc/include/asm/book3s/64/pgtable.h static inline pte_t pte_mkhuge(pte_t pte) · line 545

Quoted 6 lines
arch/powerpc/include/asm/book3s/64/pgtable.h +3 -0
+	return !(pte_raw(pte) & cpu_to_be64(_PAGE_RWX | _PAGE_PRIVILEGED));
+}
+
  static inline pte_t pte_mkdevmap(pte_t pte)
  {
  	return __pte(pte_val(pte) | _PAGE_SPECIAL|_PAGE_DEVMAP);

arch/powerpc/include/asm/book3s/64/pgtable.h doesn't have pte_mkdevmap(). What tree are you patching here?

I did post a V2 of this for which you replied
https://lkml.kernel.org/r/[email protected]

I actually found the issue with this patch. I will be sending V3 after more testing.

-aneesh

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>

#6 lore raw
In reply to Aneesh Kumar K.V
Quoted 8 lines · Aneesh Kumar K.V

Autonuma preserves the write permission across numa fault to avoid taking a writefault after a numa fault (Commit: b191f9b106ea " mm: numa: preserve PTE write permissions across a NUMA hinting fault"). Architecture can implement protnone in different ways and some may choose to implement that by clearing Read/ Write/Exec bit of pte. Setting the write bit on such pte can result in wrong behaviour. Fix this up by allowing arch to override how to save the write bit on a protnone pte.

The problem we are trying to fix here is w.r.t autnuma related thp migration. migrate_misplaced_transhuge_page() cannot deal with concurrent modification of the page. It does a page copy without following the migration pte sequence. IIUC, this was done to keep the migration simpler and at the time of implemenation we didn't had THP page cache which would have required a more elaborate migration scheme. [1]. That means thp autonuma migration expect the protnone with saved write to be done such that both kernel and user cannot update the page content. This patch series enables archs like ppc64 to do that. We are good with the hash translation mode with the current code, because we never create a hardware page table entry for a protnone pte.

-aneesh

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>

Acked-by on v1 1/2
#7 lore raw
In reply to Aneesh Kumar K.V
Quoted 2 lines · Aneesh Kumar K.V

Autonuma preserves the write permission across numa fault to avoid taking a writefault after a numa fault (Commit: b191f9b106ea " mm: numa: preserv=

e PTE

Quoted 1 line

write permissions across a NUMA hinting fault"). Architecture can impleme=

nt

Quoted 1 line

protnone in different ways and some may choose to implement that by clear=

ing

Quoted 2 lines

Read/
Write/Exec bit of pte. Setting the write bit on such pte can result in wr=

ong

Quoted 1 line

behaviour. Fix this up by allowing arch to override how to save the write=

bit

Quoted 3 lines

on a protnone pte.
=20

FWIW this is pretty simple and helps with us in powerpc...

Quoted 3 lines

---
=C2=A0include/asm-generic/pgtable.h | 16 ++++++++++++++++ =C2=A0mm/huge_memory.c=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=

=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0|=C2=A0=C2=A04 ++--

Quoted 1 line

=C2=A0mm/memory.c=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=

=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0|=C2=A0=C2=A02 = +-

Quoted 1 line

=C2=A0mm/mprotect.c=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=

=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0|=C2=A0=C2=A04 ++--

include/asm-generic/pgtable.=

Quoted 3 lines

=C2=A04 files changed, 21 insertions(+), 5 deletions(-) =20

include/asm-generic/pgtable.= renamed from include/asm-generic/pgtable.h +0 -0

h

include/asm-generic/pgtable.h static inline void ptep_set_wrprotect(struct mm_stru=

Quoted 4 lines

index 18af2bcefe6a..b6f3a8a4b738 100644

include/asm-generic/pgtable.h +0 -0
@@ -192,6 +192,22 @@ static inline void ptep_set_wrprotect(struct mm_stru=

ct

mm/huge_memory.c int do_huge_pmd_numa_page(struct vm_fault *vmf, pmd=

Quoted 28 lines
include/asm-generic/pgtable.h +0 -0
 *mm, unsigned long addres
 =C2=A0}

=C2=A0#endif
=C2=A0

include/asm-generic/pgtable.h +16 -0
+#ifndef pte_savedwrite
+#define pte_savedwrite pte_write
+#endif
+
+#ifndef pte_mk_savedwrite
+#define pte_mk_savedwrite pte_mkwrite
+#endif
+
+#ifndef pmd_savedwrite
+#define pmd_savedwrite pmd_write
+#endif
+
+#ifndef pmd_mk_savedwrite
+#define pmd_mk_savedwrite pmd_mkwrite
+#endif
+

=C2=A0#ifndef __HAVE_ARCH_PMDP_SET_WRPROTECT =C2=A0#ifdef CONFIG_TRANSPARENT_HUGEPAGE
=C2=A0static inline void pmdp_set_wrprotect(struct mm_struct *mm,

mm/huge_memory.c +0 -0
index 9a6bd6c8d55a..2f0f855ec911 100644
@@ -1300,7 +1300,7 @@ int do_huge_pmd_numa_page(struct vm_fault *vmf, pmd=

_t

mm/huge_memory.c int change_huge_pmd(struct vm_area_struct *vma, pmd=

Quoted 10 lines
mm/huge_memory.c +0 -0
 pmd)
 =C2=A0	goto out;

=C2=A0clear_pmdnuma:
=C2=A0 BUG_ON(!PageLocked(page));

mm/huge_memory.c +1 -1
-	was_writable =3D pmd_write(pmd);
+	was_writable =3D pmd_savedwrite(pmd);

=C2=A0 pmd =3D pmd_modify(pmd, vma->vm_page_prot);
=C2=A0 pmd =3D pmd_mkyoung(pmd);
=C2=A0 if (was_writable)

mm/huge_memory.c +0 -0
@@ -1555,7 +1555,7 @@ int change_huge_pmd(struct vm_area_struct *vma, pmd=

_t

Quoted 44 lines
mm/huge_memory.c +1 -1
 *pmd,
 =C2=A0			entry =3D pmdp_huge_get_and_clear_notify(mm, addr,
 pmd);
 =C2=A0			entry =3D pmd_modify(entry, newprot);
 =C2=A0			if (preserve_write)
-				entry =3D pmd_mkwrite(entry);
+				entry =3D pmd_mk_savedwrite(entry);
 =C2=A0			ret =3D HPAGE_PMD_NR;

=C2=A0 set_pmd_at(mm, addr, pmd, entry);
=C2=A0 BUG_ON(vma_is_anonymous(vma) && !preserve_write &&

mm/memory.c +1 -1
index e78bf72f30dd..88c24f89d6d3 100644
@@ -3388,7 +3388,7 @@ static int do_numa_page(struct vm_fault *vmf)
 =C2=A0	int target_nid;
 =C2=A0	bool migrated =3D false;
 =C2=A0	pte_t pte;
-	bool was_writable =3D pte_write(vmf->orig_pte);
+	bool was_writable =3D pte_savedwrite(vmf->orig_pte);
 =C2=A0	int flags =3D 0;

=C2=A0
=C2=A0 /*

mm/mprotect.c +1 -1
index f9c07f54dd62..15f5c174a7c1 100644
@@ -113,13 +113,13 @@ static unsigned long change_pte_range(struct
 vm_area_struct *vma, pmd_t *pmd,
 =C2=A0			ptent =3D ptep_modify_prot_start(mm, addr, pte);
 =C2=A0			ptent =3D pte_modify(ptent, newprot);
 =C2=A0			if (preserve_write)
-				ptent =3D pte_mkwrite(ptent);
+				ptent =3D pte_mk_savedwrite(ptent);

=C2=A0
=C2=A0 /* Avoid taking write faults for known dirty pages */
=C2=A0 if (dirty_accountable && pte_dirty(ptent) &&
=C2=A0 (pte_soft_dirty(ptent) ||
=C2=A0 =C2=A0!(vma->vm_flags & VM_SOFTDIRTY))) {

mm/mprotect.c +1 -1
-				ptent =3D pte_mkwrite(ptent);
+				ptent =3D pte_mk_savedwrite(ptent);

=C2=A0 }
=C2=A0 ptep_modify_prot_commit(mm, addr, pte, ptent);
=C2=A0 pages++;