Skip to contentSkip to conversation

x86,mm: use _PAGE_BIT_SOFTW2 as _PAGE_BIT_NUMA

RFC PATCH In review Wei Liu 2 participants 5 messages Nov 6, 2014 – Nov 7, 2014

Subsystems (2)
lore
Share & tools
lore

Wei Liu

author
#0 lore raw

RFC PATCH 1/1 x86,mm: use _PAGE_BIT_SOFTW2 as _PAGE_BIT_NUMA

In b38af4721 ("x86,mm: fix pte_special versus pte_numa") pte_special() (SPECIAL with PRESENT or PROTNONE) was made to complement pte_numa() (SPECIAL with neither PRESENT nor PROTNONE). That broke Xen PV guest with NUMA balancing support.

That's because Xen hypervisor sets _PAGE_GLOBAL (_PAGE_GLOBAL / _PAGE_PROTNONE in Linux) for guest user space mapping. So in a Xen PV guest, when NUMA balancing is enabled, a NUMA hinted PTE ends up "SPECIAL (in fact NUMA) with PROTNONE but not PRESENT", which makes pte_special() returns true when it shouldn't.

Fundamentally we only need _PAGE_NUMA and _PAGE_PRESENT to tell difference between an unmapped entry and an entry protected for NUMA hinting fault. So use _PAGE_BIT_SOFTW2 as _PAGE_BIT_NUMA, adjust _PAGE_NUMA_MASK and SWP_OFFSET_SHIFT as needed.

Cc "H. Peter Anvin" <[email protected]>
Cc Andrew Morton <[email protected]>
Cc Mel Gorman <[email protected]>
Cc David Vrabel <[email protected]>
Cc Konrad Rzeszutek Wilk <[email protected]>
Cc Cyrill Gorcunov <[email protected]>
Cc Hugh Dickins <[email protected]>
Cc Rik van Riel <[email protected]>
---
 arch/x86/include/asm/pgtable.h       |    5 -----
 arch/x86/include/asm/pgtable_64.h    |    2 +-
 arch/x86/include/asm/pgtable_types.h |    8 ++++----
 3 files changed, 5 insertions(+), 10 deletions(-)
arch/x86/include/asm/pgtable.h +0 -5
index aa97a07..8dee3ed 100644
@@ -131,11 +131,6 @@ static inline int pte_exec(pte_t pte)
 
 static inline int pte_special(pte_t pte)
 {
-	/*
-	 * See CONFIG_NUMA_BALANCING pte_numa in include/asm-generic/pgtable.h.
-	 * On x86 we have _PAGE_BIT_NUMA == _PAGE_BIT_GLOBAL+1 ==
-	 * __PAGE_BIT_SOFTW1 == _PAGE_BIT_SPECIAL.
-	 */
 	return (pte_flags(pte) & _PAGE_SPECIAL) &&
 		(pte_flags(pte) & (_PAGE_PRESENT|_PAGE_PROTNONE));
 }
arch/x86/include/asm/pgtable_64.h +1 -1
index 4572b2f..26f2ade 100644
@@ -148,7 +148,7 @@ static inline int pgd_large(pgd_t pgd) { return 0; }
 #define SWP_TYPE_BITS (_PAGE_BIT_FILE - _PAGE_BIT_PRESENT - 1)
 #ifdef CONFIG_NUMA_BALANCING
 /* Automatic NUMA balancing needs to be distinguishable from swap entries */
-#define SWP_OFFSET_SHIFT (_PAGE_BIT_PROTNONE + 2)
+#define SWP_OFFSET_SHIFT (_PAGE_BIT_PROTNONE + 3)
 #else
 #define SWP_OFFSET_SHIFT (_PAGE_BIT_PROTNONE + 1)
 #endif
arch/x86/include/asm/pgtable_types.h +4 -4
index 0778964..bc82d6b 100644
@@ -31,9 +31,9 @@
  * Swap offsets on configurations that allow automatic NUMA balancing use the
  * bits after _PAGE_BIT_GLOBAL. To uniquely distinguish NUMA hinting PTEs from
  * swap entries, we use the first bit after _PAGE_BIT_GLOBAL and shrink the
- * maximum possible swap space from 16TB to 8TB.
+ * maximum possible swap space from 16TB to 4TB.
  */
-#define _PAGE_BIT_NUMA		(_PAGE_BIT_GLOBAL+1)
+#define _PAGE_BIT_NUMA		_PAGE_BIT_SOFTW2
 
 /* If _PAGE_BIT_PRESENT is clear, we use these: */
 /* - if the user mapped it with PROT_NONE; pte_present gives true */
@@ -325,8 +325,8 @@ static inline pteval_t pte_flags(pte_t pte)
 }
 
 #ifdef CONFIG_NUMA_BALANCING
-/* Set of bits that distinguishes present, prot_none and numa ptes */
-#define _PAGE_NUMA_MASK (_PAGE_NUMA|_PAGE_PROTNONE|_PAGE_PRESENT)
+/* Set of bits that distinguishes present and numa ptes */
+#define _PAGE_NUMA_MASK (_PAGE_NUMA|_PAGE_PRESENT)
 static inline pteval_t ptenuma_flags(pte_t pte)
 {
 	return pte_flags(pte) & _PAGE_NUMA_MASK;
Signature · 7 lines
1.7.10.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
Quoted 11 lines · Wei Liu

In b38af4721 ("x86,mm: fix pte_special versus pte_numa") pte_special() (SPECIAL with PRESENT or PROTNONE) was made to complement pte_numa() (SPECIAL with neither PRESENT nor PROTNONE). That broke Xen PV guest with NUMA balancing support.

That's because Xen hypervisor sets _PAGE_GLOBAL (_PAGE_GLOBAL / _PAGE_PROTNONE in Linux) for guest user space mapping. So in a Xen PV guest, when NUMA balancing is enabled, a NUMA hinted PTE ends up "SPECIAL (in fact NUMA) with PROTNONE but not PRESENT", which makes pte_special() returns true when it shouldn't.

Quoted 7 lines

Fundamentally we only need _PAGE_NUMA and _PAGE_PRESENT to tell difference between an unmapped entry and an entry protected for NUMA hinting fault. So use _PAGE_BIT_SOFTW2 as _PAGE_BIT_NUMA, adjust _PAGE_NUMA_MASK and SWP_OFFSET_SHIFT as needed.

I suggest instead that you force automatic NUMA balancing to be disabled on Xen PV guests until I or someone else finds time to implement Linus' idea to remove _PAGE_NUMA entirely. It's been on my TODO list for a few weeks but I still have not reached the point where I'm back working on upstream material properly.

Signature · 8 lines
Mel Gorman
SUSE Labs

--
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>
author
#2 lore raw

Re: [PATCH RFC] x86, mm: use _PAGE_BIT_SOFTW2 as _PAGE_BIT_NUMA

Quoted 17 lines · Mel Gorman
Quoted 16 lines · Wei Liu

In b38af4721 ("x86,mm: fix pte_special versus pte_numa") pte_special() (SPECIAL with PRESENT or PROTNONE) was made to complement pte_numa() (SPECIAL with neither PRESENT nor PROTNONE). That broke Xen PV guest with NUMA balancing support.

That's because Xen hypervisor sets _PAGE_GLOBAL (_PAGE_GLOBAL / _PAGE_PROTNONE in Linux) for guest user space mapping. So in a Xen PV guest, when NUMA balancing is enabled, a NUMA hinted PTE ends up "SPECIAL (in fact NUMA) with PROTNONE but not PRESENT", which makes pte_special() returns true when it shouldn't.

Fundamentally we only need _PAGE_NUMA and _PAGE_PRESENT to tell difference between an unmapped entry and an entry protected for NUMA hinting fault. So use _PAGE_BIT_SOFTW2 as _PAGE_BIT_NUMA, adjust _PAGE_NUMA_MASK and SWP_OFFSET_SHIFT as needed.

Quoted 9 lines
Quoted 2 lines

I suggest instead that you force automatic NUMA balancing to be disabled on Xen PV guests until I or someone else finds time to implement Linus' idea to remove _PAGE_NUMA entirely. It's been on my TODO list for a few weeks but I still have not reached the point where I'm back working on upstream material properly.

No problem. Thanks for the suggestion.

Wei.

Quoted 3 lines
Signature · 2 lines
Mel Gorman
SUSE Labs
author
#3 lore raw
In reply to Mel Gorman
Quoted 17 lines · Mel Gorman
Quoted 16 lines · Wei Liu

In b38af4721 ("x86,mm: fix pte_special versus pte_numa") pte_special() (SPECIAL with PRESENT or PROTNONE) was made to complement pte_numa() (SPECIAL with neither PRESENT nor PROTNONE). That broke Xen PV guest with NUMA balancing support.

That's because Xen hypervisor sets _PAGE_GLOBAL (_PAGE_GLOBAL / _PAGE_PROTNONE in Linux) for guest user space mapping. So in a Xen PV guest, when NUMA balancing is enabled, a NUMA hinted PTE ends up "SPECIAL (in fact NUMA) with PROTNONE but not PRESENT", which makes pte_special() returns true when it shouldn't.

Fundamentally we only need _PAGE_NUMA and _PAGE_PRESENT to tell difference between an unmapped entry and an entry protected for NUMA hinting fault. So use _PAGE_BIT_SOFTW2 as _PAGE_BIT_NUMA, adjust _PAGE_NUMA_MASK and SWP_OFFSET_SHIFT as needed.

Quoted 9 lines
Quoted 2 lines

I suggest instead that you force automatic NUMA balancing to be disabled on Xen PV guests until I or someone else finds time to implement Linus' idea to remove _PAGE_NUMA entirely. It's been on my TODO list for a few weeks but I still have not reached the point where I'm back working on upstream material properly.

No problem. Thanks for the suggestion.

Wei.

Quoted 3 lines
Signature · 2 lines
Mel Gorman
SUSE Labs

--
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>

#4 lore raw

Re: [PATCH RFC] x86, mm: use _PAGE_BIT_SOFTW2 as _PAGE_BIT_NUMA

In reply to Wei Liu
Quoted 11 lines · Wei Liu

In b38af4721 ("x86,mm: fix pte_special versus pte_numa") pte_special() (SPECIAL with PRESENT or PROTNONE) was made to complement pte_numa() (SPECIAL with neither PRESENT nor PROTNONE). That broke Xen PV guest with NUMA balancing support.

That's because Xen hypervisor sets _PAGE_GLOBAL (_PAGE_GLOBAL / _PAGE_PROTNONE in Linux) for guest user space mapping. So in a Xen PV guest, when NUMA balancing is enabled, a NUMA hinted PTE ends up "SPECIAL (in fact NUMA) with PROTNONE but not PRESENT", which makes pte_special() returns true when it shouldn't.

Quoted 7 lines

Fundamentally we only need _PAGE_NUMA and _PAGE_PRESENT to tell difference between an unmapped entry and an entry protected for NUMA hinting fault. So use _PAGE_BIT_SOFTW2 as _PAGE_BIT_NUMA, adjust _PAGE_NUMA_MASK and SWP_OFFSET_SHIFT as needed.

I suggest instead that you force automatic NUMA balancing to be disabled on Xen PV guests until I or someone else finds time to implement Linus' idea to remove _PAGE_NUMA entirely. It's been on my TODO list for a few weeks but I still have not reached the point where I'm back working on upstream material properly.

Signature · 2 lines
Mel Gorman
SUSE Labs