Commit 9ca4598b authored by Nanyong Sun's avatar Nanyong Sun
Browse files

mm: filemap: optimize semantic when thp_exec_enabled is set to 3

hulk inclusion
category: feature
bugzilla: https://gitee.com/openeuler/kernel/issues/IAEOV4


CVE: NA

--------------------------------

When thp_exec_enabled is set to 3, try PMD mapping THP first,
if failed, then try mTHP like cont-64K on ARM64. The previous
implementation use hugepage_madvise() in try_enable_file_exec_thp()
and it will always set VM_HUGEPAGE to vm_flags, so we lost this
semantic, let's check PMD_ORDER by thp_vma_allowable_order() to
correct the semantic.

And now the khugepaged_enter_vma() step in hugepage_madvise()
is missing, this is OK because the process is already entered
in khugepaged after this commit 613bec09 ("mm: mmap: register
suitable readonly file vmas for khugepaged").

Signed-off-by: default avatarNanyong Sun <sunnanyong@huawei.com>
parent 3dce4f55
Loading
Loading
Loading
Loading
+6 −2
Original line number Diff line number Diff line
@@ -3159,8 +3159,12 @@ static inline void try_enable_file_exec_thp(struct vm_area_struct *vma,
	if (file->f_op->get_unmapped_area != thp_get_unmapped_area)
		return;

	if (file_exec_thp_enabled())
		hugepage_madvise(vma, vm_flags, MADV_HUGEPAGE);
	if (!file_exec_thp_enabled())
		return;

	if (thp_vma_allowable_order(vma, *vm_flags, TVA_ENFORCE_SYSFS,
				PMD_ORDER))
		*vm_flags |= VM_HUGEPAGE;
}

static inline bool file_exec_can_enable_mthp(struct address_space *mapping,