mm: thp: fix pmd_bad() triggering in code paths holding mmap_sem read mode
Andrea Arcangeli authored
In some cases it may happen that pmd_none_or_clear_bad() is called with
the mmap_sem hold in read mode.  In those cases the huge page faults can
allocate hugepmds under pmd_none_or_clear_bad() and that can trigger a
false positive from pmd_bad() that will not like to see a pmd
materializing as trans huge.

It's not khugepaged causing the problem, khugepaged holds the mmap_sem
in write mode (and all those sites must hold the mmap_sem in read mode
to prevent pagetables to go away from under them, during code review it
seems vm86 mode on 32bit kernels requires that too unless it's
restricted to 1 thread per process or UP builds).  The race is only with
the huge pagefaults that can convert a pmd_none() into a
pmd_trans_huge().

Effectively all these pmd_none_or_clear_bad() sites running with
mmap_sem in read mode are somewhat speculative with the page faults, and
the result is always undefined when they run simultaneously.  This is
pro...
1a5a9906
Name Last commit Last update
..
alpha Merge branch 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/jikos/trivial
arm Merge tag 'regulator-3.4' of git://git.kernel.org/pub/scm/linux/kernel/git/broonie/regulator
avr32 Merge git://git.kernel.org/pub/scm/linux/kernel/git/davem/net-next
blackfin Merge git://git.kernel.org/pub/scm/linux/kernel/git/davem/net-next
c6x Merge tag 'irqdomain-for-linus' of git://git.secretlab.ca/git/linux-2.6
cris Merge git://git.kernel.org/pub/scm/linux/kernel/git/davem/net-next
frv Merge branch 'kmap_atomic' of git://github.com/congwang/linux
h8300 Merge git://git.kernel.org/pub/scm/linux/kernel/git/davem/net-next
hexagon Merge branch 'sched-core-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip
ia64 Merge branch 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/jikos/trivial
m32r Merge git://git.kernel.org/pub/scm/linux/kernel/git/davem/net-next
m68k Merge git://git.kernel.org/pub/scm/linux/kernel/git/davem/net-next
microblaze Merge tag 'irqdomain-for-linus' of git://git.secretlab.ca/git/linux-2.6
mips Merge tag 'irqdomain-for-linus' of git://git.secretlab.ca/git/linux-2.6
mn10300 Merge branch 'kmap_atomic' of git://github.com/congwang/linux
openrisc Merge tag 'irqdomain-for-linus' of git://git.secretlab.ca/git/linux-2.6
parisc Merge branch 'kmap_atomic' of git://github.com/congwang/linux
powerpc Merge tag 'dt-for-linus' of git://git.secretlab.ca/git/linux-2.6
s390 Merge git://git.kernel.org/pub/scm/linux/kernel/git/davem/net-next
score Merge branch 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/jikos/trivial
sh Merge branch 'kmap_atomic' of git://github.com/congwang/linux
sparc Merge tag 'irqdomain-for-linus' of git://git.secretlab.ca/git/linux-2.6
tile Merge branch 'kmap_atomic' of git://github.com/congwang/linux
um Merge branch 'kmap_atomic' of git://github.com/congwang/linux
unicore32 Merge branch 'linux-next' of git://git.kernel.org/pub/scm/linux/kernel/git/jbarnes/pci
x86 mm: thp: fix pmd_bad() triggering in code paths holding mmap_sem read mode
xtensa Merge git://git.kernel.org/pub/scm/linux/kernel/git/davem/net-next
.gitignore arch: Ignore arch/i386 and arch/x86_64
Kconfig static keys: Introduce 'struct static_key', static_key_true()/false() and static_key_slow_[inc|dec]()