diff options
Diffstat (limited to 'arch/x86/include/asm/pgtable-3level.h')
-rw-r--r-- | arch/x86/include/asm/pgtable-3level.h | 36 |
1 files changed, 20 insertions, 16 deletions
diff --git a/arch/x86/include/asm/pgtable-3level.h b/arch/x86/include/asm/pgtable-3level.h index 43876f16caf1..4cc9f2b7cdc3 100644 --- a/arch/x86/include/asm/pgtable-3level.h +++ b/arch/x86/include/asm/pgtable-3level.h | |||
@@ -9,13 +9,13 @@ | |||
9 | */ | 9 | */ |
10 | 10 | ||
11 | #define pte_ERROR(e) \ | 11 | #define pte_ERROR(e) \ |
12 | printk("%s:%d: bad pte %p(%08lx%08lx).\n", \ | 12 | pr_err("%s:%d: bad pte %p(%08lx%08lx)\n", \ |
13 | __FILE__, __LINE__, &(e), (e).pte_high, (e).pte_low) | 13 | __FILE__, __LINE__, &(e), (e).pte_high, (e).pte_low) |
14 | #define pmd_ERROR(e) \ | 14 | #define pmd_ERROR(e) \ |
15 | printk("%s:%d: bad pmd %p(%016Lx).\n", \ | 15 | pr_err("%s:%d: bad pmd %p(%016Lx)\n", \ |
16 | __FILE__, __LINE__, &(e), pmd_val(e)) | 16 | __FILE__, __LINE__, &(e), pmd_val(e)) |
17 | #define pgd_ERROR(e) \ | 17 | #define pgd_ERROR(e) \ |
18 | printk("%s:%d: bad pgd %p(%016Lx).\n", \ | 18 | pr_err("%s:%d: bad pgd %p(%016Lx)\n", \ |
19 | __FILE__, __LINE__, &(e), pgd_val(e)) | 19 | __FILE__, __LINE__, &(e), pgd_val(e)) |
20 | 20 | ||
21 | /* Rules for using set_pte: the pte being assigned *must* be | 21 | /* Rules for using set_pte: the pte being assigned *must* be |
@@ -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 | { |