Using the per-VMA hugepage flag to avoid system wide default
behavior. If 'vma->vm_flags' indicates a preference for huge pages,
then the exec THP COW can be attempted.
Signed-off-by: Zhang Qilong <zhangqilong3@huawei.com>
---
v2:
- Use 'vma->vm_flags' as hint for exec THP COW suggested by David
---
mm/memory.c | 7 +++++++
1 file changed, 7 insertions(+)
diff --git a/mm/memory.c b/mm/memory.c
index 691e3ca38cc6..eb2bb36e284c 100644
--- a/mm/memory.c
+++ b/mm/memory.c
@@ -6128,10 +6128,17 @@ static inline vm_fault_t wp_huge_pmd(struct vm_fault *vmf)
}
}
if (is_exec_mapping(vm_flags) &&
is_cow_mapping(vm_flags)) {
+ /*
+ * Reuse the per-VMA flag, only if VM_HUGEPAGE is
+ * set, do exec THP COW.
+ */
+ if (!(vm_flags & VM_HUGEPAGE))
+ goto split;
+
ret = do_huge_pmd_exec_cow(vmf);
if (!(ret & VM_FAULT_FALLBACK))
return ret;
}
--
2.43.0