]> www.infradead.org Git - users/jedix/linux-maple.git/commit
thp: avoid atomic64_read in pmd_read_atomic for 32bit PAE
authorAndrea Arcangeli <aarcange@redhat.com>
Thu, 7 Jun 2012 19:45:30 +0000 (21:45 +0200)
committerMaxim Uvarov <maxim.uvarov@oracle.com>
Thu, 21 Jun 2012 15:39:28 +0000 (08:39 -0700)
commitefc7e39d45ef6b40c88b8869ca84323e5e8cb156
tree2d81b087f996dbaef59e75108882f1a37698a444
parent52297fb8b3183c27f1d99f80b8f40c906bc314f7
thp: avoid atomic64_read in pmd_read_atomic for 32bit PAE

In the x86 32bit PAE CONFIG_TRANSPARENT_HUGEPAGE=y case while holding
the mmap_sem for reading, cmpxchg8b cannot be used to read pmd
contents under Xen.

So instead of dealing only with "consistent" pmdvals in
pmd_none_or_trans_huge_or_clear_bad() (which would be conceptually
simpler) we let pmd_none_or_trans_huge_or_clear_bad() deal with pmdvals
where the low 32bit and high 32bit could be inconsistent (to avoid
having to use cmpxchg8b).

The only guarantee we get from pmd_read_atomic is that if the low part
of the pmd was found null, the high part will be null too (so the pmd
will be considered unstable). And if the low part of the pmd is found
"stable" later, then it means the whole pmd was read atomically
(because after a pmd is stable, neither MADV_DONTNEED nor page faults
can alter it anymore, and we read the high part after the low part).

In the 32bit PAE x86 case, it is enough to read the low part of the
pmdval atomically to declare the pmd as "stable" and that's true for
THP and no THP, furthermore in the THP case we also have a barrier()
that will prevent any inconsistent pmdvals to be cached by a later
re-read of the *pmd.
(cherry picked from commit cdc7a76d4903387391fba3284be3b0b5c364f3d2)

Orabug: 14217003
Signed-off-by: Chuck Anderson <chuck.anderson@oracle.com>
arch/x86/include/asm/pgtable-3level.h
include/asm-generic/pgtable.h