Skip to content

Commit 44e0956

Browse files
author
Ingo Molnar
committed
x86/mm: Clean up the pmd_read_atomic() comments
Fix spelling, consistent parenthesis and grammar - and also clarify the language where needed. Reviewed-by: Wei Yang <[email protected]> Cc: Andy Lutomirski <[email protected]> Cc: Borislav Petkov <[email protected]> Cc: Dave Hansen <[email protected]> Cc: H. Peter Anvin <[email protected]> Cc: Linus Torvalds <[email protected]> Cc: Peter Zijlstra <[email protected]> Cc: Rik van Riel <[email protected]> Cc: Thomas Gleixner <[email protected]> Signed-off-by: Ingo Molnar <[email protected]>
1 parent a2f7a0b commit 44e0956

File tree

1 file changed

+23
-21
lines changed

1 file changed

+23
-21
lines changed

arch/x86/include/asm/pgtable-3level.h

Lines changed: 23 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -36,39 +36,41 @@ static inline void native_set_pte(pte_t *ptep, pte_t pte)
3636

3737
#define pmd_read_atomic pmd_read_atomic
3838
/*
39-
* pte_offset_map_lock on 32bit PAE kernels was reading the pmd_t with
40-
* a "*pmdp" dereference done by gcc. Problem is, in certain places
41-
* where pte_offset_map_lock is called, concurrent page faults are
39+
* pte_offset_map_lock() on 32-bit PAE kernels was reading the pmd_t with
40+
* a "*pmdp" dereference done by GCC. Problem is, in certain places
41+
* where pte_offset_map_lock() is called, concurrent page faults are
4242
* allowed, if the mmap_sem is hold for reading. An example is mincore
4343
* vs page faults vs MADV_DONTNEED. On the page fault side
44-
* pmd_populate rightfully does a set_64bit, but if we're reading the
44+
* pmd_populate() rightfully does a set_64bit(), but if we're reading the
4545
* pmd_t with a "*pmdp" on the mincore side, a SMP race can happen
46-
* because gcc will not read the 64bit of the pmd atomically. To fix
47-
* this all places running pte_offset_map_lock() while holding the
46+
* because GCC will not read the 64-bit value of the pmd atomically.
47+
*
48+
* To fix this all places running pte_offset_map_lock() while holding the
4849
* mmap_sem in read mode, shall read the pmdp pointer using this
49-
* function to know if the pmd is null nor not, and in turn to know if
50+
* function to know if the pmd is null or not, and in turn to know if
5051
* they can run pte_offset_map_lock() or pmd_trans_huge() or other pmd
5152
* operations.
5253
*
53-
* Without THP if the mmap_sem is hold for reading, the pmd can only
54-
* transition from null to not null while pmd_read_atomic runs. So
54+
* Without THP if the mmap_sem is held for reading, the pmd can only
55+
* transition from null to not null while pmd_read_atomic() runs. So
5556
* we can always return atomic pmd values with this function.
5657
*
57-
* With THP if the mmap_sem is hold for reading, the pmd can become
58+
* With THP if the mmap_sem is held for reading, the pmd can become
5859
* trans_huge or none or point to a pte (and in turn become "stable")
59-
* at any time under pmd_read_atomic. We could read it really
60-
* atomically here with a atomic64_read for the THP enabled case (and
60+
* at any time under pmd_read_atomic(). We could read it truly
61+
* atomically here with an atomic64_read() for the THP enabled case (and
6162
* it would be a whole lot simpler), but to avoid using cmpxchg8b we
6263
* only return an atomic pmdval if the low part of the pmdval is later
63-
* found stable (i.e. pointing to a pte). And we're returning a none
64-
* pmdval if the low part of the pmd is none. In some cases the high
65-
* and low part of the pmdval returned may not be consistent if THP is
66-
* enabled (the low part may point to previously mapped hugepage,
67-
* while the high part may point to a more recently mapped hugepage),
68-
* but pmd_none_or_trans_huge_or_clear_bad() only needs the low part
69-
* of the pmd to be read atomically to decide if the pmd is unstable
70-
* or not, with the only exception of when the low part of the pmd is
71-
* zero in which case we return a none pmd.
64+
* found to be stable (i.e. pointing to a pte). We are also returning a
65+
* 'none' (zero) pmdval if the low part of the pmd is zero.
66+
*
67+
* In some cases the high and low part of the pmdval returned may not be
68+
* consistent if THP is enabled (the low part may point to previously
69+
* mapped hugepage, while the high part may point to a more recently
70+
* mapped hugepage), but pmd_none_or_trans_huge_or_clear_bad() only
71+
* needs the low part of the pmd to be read atomically to decide if the
72+
* pmd is unstable or not, with the only exception when the low part
73+
* of the pmd is zero, in which case we return a 'none' pmd.
7274
*/
7375
static inline pmd_t pmd_read_atomic(pmd_t *pmdp)
7476
{

0 commit comments

Comments
 (0)