Commit adf05a3b authored by Lance Yang's avatar Lance Yang Committed by Kefeng Wang
Browse files

mm/khugepaged: keep mm in mm_slot without MMF_DISABLE_THP check

mainline inclusion
from mainline-v6.9-rc1
commit 5dad604809c5acc546ec74057498db1623f1c408
category: feature
bugzilla: https://gitee.com/openeuler/kernel/issues/I9H84X
CVE: NA

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

Previously, we removed the mm from mm_slot and dropped mm_count
if the MMF_THP_DISABLE flag was set. However, we didn't re-add
the mm back after clearing the MMF_THP_DISABLE flag. Additionally,
We add a check for the MMF_THP_DISABLE flag in hugepage_vma_revalidate().

Link: https://lkml.kernel.org/r/20240227035135.54593-1-ioworker0@gmail.com


Fixes: 879c6000e191 ("mm/khugepaged: bypassing unnecessary scans with MMF_DISABLE_THP check")
Signed-off-by: default avatarLance Yang <ioworker0@gmail.com>
Suggested-by: default avatarYang Shi <shy828301@gmail.com>
Reviewed-by: default avatarYang Shi <shy828301@gmail.com>
Reviewed-by: default avatarDavid Hildenbrand <david@redhat.com>
Cc: Michal Hocko <mhocko@suse.com>
Cc: Minchan Kim <minchan@kernel.org>
Cc: Muchun Song <songmuchun@bytedance.com>
Cc: Peter Xu <peterx@redhat.com>
Cc: Zach O'Keefe <zokeefe@google.com>
Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
(cherry picked from commit 5dad604809c5acc546ec74057498db1623f1c408)
Signed-off-by: default avatarKefeng Wang <wangkefeng.wang@huawei.com>
parent 798109a8
Loading
Loading
Loading
Loading
+3 −3
Original line number Diff line number Diff line
@@ -928,7 +928,7 @@ static int hugepage_vma_revalidate(struct mm_struct *mm, unsigned long address,
{
	struct vm_area_struct *vma;

	if (unlikely(hpage_collapse_test_exit(mm)))
	if (unlikely(hpage_collapse_test_exit_or_disable(mm)))
		return SCAN_ANY_PROCESS;

	*vmap = vma = find_vma(mm, address);
@@ -1445,7 +1445,7 @@ static void collect_mm_slot(struct khugepaged_mm_slot *mm_slot)

	lockdep_assert_held(&khugepaged_mm_lock);

	if (hpage_collapse_test_exit_or_disable(mm)) {
	if (hpage_collapse_test_exit(mm)) {
		/* free mm_slot */
		hash_del(&slot->hash);
		list_del(&slot->mm_node);
@@ -2483,7 +2483,7 @@ static unsigned int khugepaged_scan_mm_slot(unsigned int pages, int *result,
	 * Release the current mm_slot if this mm is about to die, or
	 * if we scanned all vmas of this mm.
	 */
	if (hpage_collapse_test_exit_or_disable(mm) || !vma) {
	if (hpage_collapse_test_exit(mm) || !vma) {
		/*
		 * Make sure that if mm_users is reaching zero while
		 * khugepaged runs here, khugepaged_exit will find