aboutsummaryrefslogtreecommitdiffstats
path: root/mm/memory.c
diff options
context:
space:
mode:
authorIngo Molnar <mingo@kernel.org>2016-03-07 09:27:30 +0100
committerIngo Molnar <mingo@kernel.org>2016-03-07 09:27:30 +0100
commitec87e1cf7d8399d81d8965c6d852f8057a8dd687 (patch)
tree472a168fa4861090edf110c8a9712a5c15ea259f /mm/memory.c
parentuprobes: __create_xol_area() must nullify xol_mapping.fault (diff)
parentLinux 4.5-rc7 (diff)
downloadlinux-dev-ec87e1cf7d8399d81d8965c6d852f8057a8dd687.tar.xz
linux-dev-ec87e1cf7d8399d81d8965c6d852f8057a8dd687.zip
Merge tag 'v4.5-rc7' into x86/asm, to pick up SMAP fix
Signed-off-by: Ingo Molnar <mingo@kernel.org>
Diffstat (limited to 'mm/memory.c')
-rw-r--r--mm/memory.c14
1 files changed, 12 insertions, 2 deletions
diff --git a/mm/memory.c b/mm/memory.c
index 38090ca37a08..906d8e3b42c0 100644
--- a/mm/memory.c
+++ b/mm/memory.c
@@ -3425,8 +3425,18 @@ static int __handle_mm_fault(struct mm_struct *mm, struct vm_area_struct *vma,
if (unlikely(pmd_none(*pmd)) &&
unlikely(__pte_alloc(mm, vma, pmd, address)))
return VM_FAULT_OOM;
- /* if an huge pmd materialized from under us just retry later */
- if (unlikely(pmd_trans_huge(*pmd) || pmd_devmap(*pmd)))
+ /*
+ * If a huge pmd materialized under us just retry later. Use
+ * pmd_trans_unstable() instead of pmd_trans_huge() to ensure the pmd
+ * didn't become pmd_trans_huge under us and then back to pmd_none, as
+ * a result of MADV_DONTNEED running immediately after a huge pmd fault
+ * in a different thread of this mm, in turn leading to a misleading
+ * pmd_trans_huge() retval. All we have to ensure is that it is a
+ * regular pmd that we can walk with pte_offset_map() and we can do that
+ * through an atomic read in C, which is what pmd_trans_unstable()
+ * provides.
+ */
+ if (unlikely(pmd_trans_unstable(pmd) || pmd_devmap(*pmd)))
return 0;
/*
* A regular pmd is established and it can't morph into a huge pmd