https://github.com/torvalds/linux
Revision e4eed03fd06578571c01d4f1478c874bb432c815 authored by Andrea Arcangeli on 20 June 2012, 19:52:57 UTC, committed by Linus Torvalds on 20 June 2012, 21:39:35 UTC
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.

Signed-off-by: Andrea Arcangeli <aarcange@redhat.com>
Cc: Jonathan Nieder <jrnieder@gmail.com>
Cc: Ulrich Obergfell <uobergfe@redhat.com>
Cc: Mel Gorman <mgorman@suse.de>
Cc: Hugh Dickins <hughd@google.com>
Cc: Larry Woodman <lwoodman@redhat.com>
Cc: Petr Matousek <pmatouse@redhat.com>
Cc: Rik van Riel <riel@redhat.com>
Cc: Jan Beulich <jbeulich@suse.com>
Cc: KOSAKI Motohiro <kosaki.motohiro@gmail.com>
Tested-by: Andrew Jones <drjones@redhat.com>
Cc: <stable@vger.kernel.org>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
1 parent abca7c4
History
Tip revision: e4eed03fd06578571c01d4f1478c874bb432c815 authored by Andrea Arcangeli on 20 June 2012, 19:52:57 UTC
thp: avoid atomic64_read in pmd_read_atomic for 32bit PAE
Tip revision: e4eed03
File Mode Size
async_tx
Kconfig -rw-r--r-- 27.4 KB
Makefile -rw-r--r-- 3.3 KB
ablkcipher.c -rw-r--r-- 18.3 KB
aead.c -rw-r--r-- 14.1 KB
aes_generic.c -rw-r--r-- 61.9 KB
af_alg.c -rw-r--r-- 9.3 KB
ahash.c -rw-r--r-- 12.7 KB
algapi.c -rw-r--r-- 20.2 KB
algboss.c -rw-r--r-- 6.3 KB
algif_hash.c -rw-r--r-- 6.8 KB
algif_skcipher.c -rw-r--r-- 13.2 KB
ansi_cprng.c -rw-r--r-- 11.1 KB
anubis.c -rw-r--r-- 27.8 KB
api.c -rw-r--r-- 13.4 KB
arc4.c -rw-r--r-- 2.0 KB
authenc.c -rw-r--r-- 19.6 KB
authencesn.c -rw-r--r-- 23.4 KB
blkcipher.c -rw-r--r-- 19.4 KB
blowfish_common.c -rw-r--r-- 15.7 KB
blowfish_generic.c -rw-r--r-- 3.4 KB
camellia_generic.c -rw-r--r-- 35.0 KB
cast5.c -rw-r--r-- 33.0 KB
cast6.c -rw-r--r-- 21.4 KB
cbc.c -rw-r--r-- 7.4 KB
ccm.c -rw-r--r-- 21.5 KB
chainiv.c -rw-r--r-- 8.6 KB
cipher.c -rw-r--r-- 3.3 KB
compress.c -rw-r--r-- 1.3 KB
crc32c.c -rw-r--r-- 4.3 KB
cryptd.c -rw-r--r-- 24.8 KB
crypto_null.c -rw-r--r-- 4.9 KB
crypto_user.c -rw-r--r-- 11.8 KB
crypto_wq.c -rw-r--r-- 968 bytes
ctr.c -rw-r--r-- 10.8 KB
cts.c -rw-r--r-- 9.8 KB
deflate.c -rw-r--r-- 5.4 KB
des_generic.c -rw-r--r-- 35.6 KB
ecb.c -rw-r--r-- 4.9 KB
eseqiv.c -rw-r--r-- 6.5 KB
fcrypt.c -rw-r--r-- 18.0 KB
fips.c -rw-r--r-- 705 bytes
gcm.c -rw-r--r-- 34.5 KB
gf128mul.c -rw-r--r-- 13.2 KB
ghash-generic.c -rw-r--r-- 3.8 KB
hmac.c -rw-r--r-- 6.9 KB
internal.h -rw-r--r-- 4.0 KB
khazad.c -rw-r--r-- 51.8 KB
krng.c -rw-r--r-- 1.5 KB
lrw.c -rw-r--r-- 9.2 KB
lzo.c -rw-r--r-- 2.5 KB
md4.c -rw-r--r-- 6.2 KB
md5.c -rw-r--r-- 3.9 KB
michael_mic.c -rw-r--r-- 3.6 KB
pcbc.c -rw-r--r-- 7.7 KB
pcompress.c -rw-r--r-- 3.0 KB
pcrypt.c -rw-r--r-- 14.7 KB
proc.c -rw-r--r-- 3.7 KB
ripemd.h -rw-r--r-- 974 bytes
rmd128.c -rw-r--r-- 10.2 KB
rmd160.c -rw-r--r-- 12.6 KB
rmd256.c -rw-r--r-- 10.5 KB
rmd320.c -rw-r--r-- 13.1 KB
rng.c -rw-r--r-- 3.3 KB
salsa20_generic.c -rw-r--r-- 6.7 KB
scatterwalk.c -rw-r--r-- 2.9 KB
seed.c -rw-r--r-- 17.4 KB
seqiv.c -rw-r--r-- 8.6 KB
serpent_generic.c -rw-r--r-- 21.4 KB
sha1_generic.c -rw-r--r-- 3.5 KB
sha256_generic.c -rw-r--r-- 12.2 KB
sha512_generic.c -rw-r--r-- 8.7 KB
shash.c -rw-r--r-- 16.9 KB
tcrypt.c -rw-r--r-- 37.0 KB
tcrypt.h -rw-r--r-- 3.5 KB
tea.c -rw-r--r-- 7.1 KB
testmgr.c -rw-r--r-- 58.8 KB
testmgr.h -rw-r--r-- 506.6 KB
tgr192.c -rw-r--r-- 30.8 KB
twofish_common.c -rw-r--r-- 37.8 KB
twofish_generic.c -rw-r--r-- 6.3 KB
vmac.c -rw-r--r-- 17.9 KB
wp512.c -rw-r--r-- 60.1 KB
xcbc.c -rw-r--r-- 7.2 KB
xor.c -rw-r--r-- 4.0 KB
xts.c -rw-r--r-- 8.7 KB
zlib.c -rw-r--r-- 9.5 KB

back to top