android_kernel_samsung_msm8976/mm
Andrea Arcangeli a57dd9f235 mm: thp: fix SMP race condition between THP page fault and MADV_DONTNEED
commit ad33bb04b2a6cee6c1f99fabb15cddbf93ff0433 upstream.

pmd_trans_unstable()/pmd_none_or_trans_huge_or_clear_bad() were
introduced to locklessy (but atomically) detect when a pmd is a regular
(stable) pmd or when the pmd is unstable and can infinitely transition
from pmd_none() and pmd_trans_huge() from under us, while only holding
the mmap_sem for reading (for writing not).

While holding the mmap_sem only for reading, MADV_DONTNEED can run from
under us and so before we can assume the pmd to be a regular stable pmd
we need to compare it against pmd_none() and pmd_trans_huge() in an
atomic way, with pmd_trans_unstable().  The old pmd_trans_huge() left a
tiny window for a race.

Useful applications are unlikely to notice the difference as doing
MADV_DONTNEED concurrently with a page fault would lead to undefined
behavior.

[js] 3.12 backport: no pmd_devmap in 3.12 yet.

[akpm@linux-foundation.org: tidy up comment grammar/layout]
Signed-off-by: Andrea Arcangeli <aarcange@redhat.com>
Reported-by: Kirill A. Shutemov <kirill.shutemov@linux.intel.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Cc: Vlastimil Babka <vbabka@suse.cz>
Signed-off-by: Jiri Slaby <jslaby@suse.cz>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: Willy Tarreau <w@1wt.eu>
2019-07-27 21:42:02 +02:00
..
kasan
backing-dev.c
balloon_compaction.c
bootmem.c
bounce.c
cleancache.c
compaction.c Import latest Samsung release 2017-04-18 03:43:52 +02:00
debug-pagealloc.c
dmapool.c
early_ioremap.c
fadvise.c
failslab.c
filemap.c Import T813XXS2BRC2 kernel source changes 2018-05-26 00:39:42 +02:00
filemap_xip.c
fremap.c
frontswap.c
highmem.c
huge_memory.c
hugetlb.c
hugetlb_cgroup.c
hwpoison-inject.c
init-mm.c
internal.h
interval_tree.c
Kconfig Import T813XXS2BRC2 kernel source changes 2018-05-26 00:39:42 +02:00
Kconfig.debug
kmemcheck.c
kmemleak-test.c
kmemleak.c
ksm.c Import latest Samsung release 2017-04-18 03:43:52 +02:00
maccess.c
madvise.c
Makefile BACKPORT: mm/zpool: implement common zpool api to zbud/zsmalloc 2016-05-18 14:35:03 +05:30
memblock.c
memcontrol.c UPSTREAM: memcg: Only free spare array when readers are done 2016-05-18 14:36:06 +05:30
memory-failure.c This is the 3.10.98 stable release 2017-04-18 17:17:24 +02:00
memory.c mm: thp: fix SMP race condition between THP page fault and MADV_DONTNEED 2019-07-27 21:42:02 +02:00
memory_hotplug.c This is the 3.10.98 stable release 2017-04-18 17:17:24 +02:00
mempolicy.c mm/mempolicy.c: fix error handling in set_mempolicy and mbind. 2017-04-22 23:02:48 +02:00
mempool.c
memtest.c
migrate.c squash mm: Export migrate_page_... : also make it non-static 2019-07-27 21:42:00 +02:00
mincore.c
mlock.c
mm_init.c
mmap.c fs: Remove Samsung implementation of sdcardfs 2018-02-06 13:12:17 +01:00
mmu_context.c
mmu_notifier.c
mmzone.c
mprotect.c
mremap.c
msync.c
nobootmem.c
nommu.c
oom_kill.c
page-writeback.c Import latest Samsung release 2017-04-18 03:43:52 +02:00
page_alloc.c Import latest Samsung release 2017-04-18 03:43:52 +02:00
page_cgroup.c
page_io.c Import latest Samsung release 2017-04-18 03:43:52 +02:00
page_isolation.c
pageowner.c
pagewalk.c
percpu-km.c
percpu-vm.c
percpu.c
pgtable-generic.c
process_reclaim.c lowmemorykiller: Introduce sysfs node for ALMK and PPR adj threshold 2016-07-06 23:07:02 -07:00
process_vm_access.c ptrace: use fsuid, fsgid, effective creds for fs access checks 2016-02-25 11:57:47 -08:00
quicklist.c
readahead.c
rmap.c
shmem.c tmpfs: fix regression hang in fallocate undo 2019-07-27 21:41:47 +02:00
showmem.c Import latest Samsung release 2017-04-18 03:43:52 +02:00
slab.c
slab.h
slab_common.c
slob.c
slub.c
sparse-vmemmap.c
sparse.c
swap.c
swap_state.c Import latest Samsung release 2017-04-18 03:43:52 +02:00
swapfile.c BACKPORT: mm: /proc/pid/smaps:: show proportional swap share of the mapping 2016-05-18 14:35:57 +05:30
truncate.c
util.c Import latest Samsung release 2017-04-18 03:43:52 +02:00
vmalloc.c Import latest Samsung release 2017-04-18 03:43:52 +02:00
vmpressure.c
vmscan.c Import latest Samsung release 2017-04-18 03:43:52 +02:00
vmstat.c Import latest Samsung release 2017-04-18 03:43:52 +02:00
zbud.c Import latest Samsung release 2017-04-18 03:43:52 +02:00
zpool.c Import latest Samsung release 2017-04-18 03:43:52 +02:00
zsmalloc.c Import latest Samsung release 2017-04-18 03:43:52 +02:00
zswap.c Import latest Samsung release 2017-04-18 03:43:52 +02:00