diff options
Diffstat (limited to 'arch/x86/include/asm/pgtable-3level.h')
-rw-r--r-- | arch/x86/include/asm/pgtable-3level.h | 30 |
1 files changed, 17 insertions, 13 deletions
diff --git a/arch/x86/include/asm/pgtable-3level.h b/arch/x86/include/asm/pgtable-3level.h index 43876f16caf1..cb00ccc7d571 100644 --- a/arch/x86/include/asm/pgtable-3level.h +++ b/arch/x86/include/asm/pgtable-3level.h | |||
@@ -47,16 +47,26 @@ static inline void native_set_pte(pte_t *ptep, pte_t pte) | |||
47 | * they can run pmd_offset_map_lock or pmd_trans_huge or other pmd | 47 | * they can run pmd_offset_map_lock or pmd_trans_huge or other pmd |
48 | * operations. | 48 | * operations. |
49 | * | 49 | * |
50 | * Without THP if the mmap_sem is hold for reading, the | 50 | * Without THP if the mmap_sem is hold for reading, the pmd can only |
51 | * pmd can only transition from null to not null while pmd_read_atomic runs. | 51 | * transition from null to not null while pmd_read_atomic runs. So |
52 | * So there's no need of literally reading it atomically. | 52 | * we can always return atomic pmd values with this function. |
53 | * | 53 | * |
54 | * With THP if the mmap_sem is hold for reading, the pmd can become | 54 | * With THP if the mmap_sem is hold for reading, the pmd can become |
55 | * THP or null or point to a pte (and in turn become "stable") at any | 55 | * trans_huge or none or point to a pte (and in turn become "stable") |
56 | * time under pmd_read_atomic, so it's mandatory to read it atomically | 56 | * at any time under pmd_read_atomic. We could read it really |
57 | * with cmpxchg8b. | 57 | * atomically here with a atomic64_read for the THP enabled case (and |
58 | * it would be a whole lot simpler), but to avoid using cmpxchg8b we | ||
59 | * only return an atomic pmdval if the low part of the pmdval is later | ||
60 | * found stable (i.e. pointing to a pte). And we're returning a none | ||
61 | * pmdval if the low part of the pmd is none. In some cases the high | ||
62 | * and low part of the pmdval returned may not be consistent if THP is | ||
63 | * enabled (the low part may point to previously mapped hugepage, | ||
64 | * while the high part may point to a more recently mapped hugepage), | ||
65 | * but pmd_none_or_trans_huge_or_clear_bad() only needs the low part | ||
66 | * of the pmd to be read atomically to decide if the pmd is unstable | ||
67 | * or not, with the only exception of when the low part of the pmd is | ||
68 | * zero in which case we return a none pmd. | ||
58 | */ | 69 | */ |
59 | #ifndef CONFIG_TRANSPARENT_HUGEPAGE | ||
60 | static inline pmd_t pmd_read_atomic(pmd_t *pmdp) | 70 | static inline pmd_t pmd_read_atomic(pmd_t *pmdp) |
61 | { | 71 | { |
62 | pmdval_t ret; | 72 | pmdval_t ret; |
@@ -74,12 +84,6 @@ static inline pmd_t pmd_read_atomic(pmd_t *pmdp) | |||
74 | 84 | ||
75 | return (pmd_t) { ret }; | 85 | return (pmd_t) { ret }; |
76 | } | 86 | } |
77 | #else /* CONFIG_TRANSPARENT_HUGEPAGE */ | ||
78 | static inline pmd_t pmd_read_atomic(pmd_t *pmdp) | ||
79 | { | ||
80 | return (pmd_t) { atomic64_read((atomic64_t *)pmdp) }; | ||
81 | } | ||
82 | #endif /* CONFIG_TRANSPARENT_HUGEPAGE */ | ||
83 | 87 | ||
84 | static inline void native_set_pte_atomic(pte_t *ptep, pte_t pte) | 88 | static inline void native_set_pte_atomic(pte_t *ptep, pte_t pte) |
85 | { | 89 | { |