[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <ac9ed6d71b439611f9c94b3506a8ce975d4636e9.1748435162.git.baolin.wang@linux.alibaba.com>
Date: Wed, 28 May 2025 20:31:46 +0800
From: Baolin Wang <baolin.wang@...ux.alibaba.com>
To: npache@...hat.com
Cc: Liam.Howlett@...cle.com,
aarcange@...hat.com,
akpm@...ux-foundation.org,
anshuman.khandual@....com,
baohua@...nel.org,
baolin.wang@...ux.alibaba.com,
catalin.marinas@....com,
cl@...two.org,
corbet@....net,
dave.hansen@...ux.intel.com,
david@...hat.com,
dev.jain@....com,
hannes@...xchg.org,
jack@...e.cz,
jglisse@...gle.com,
kirill.shutemov@...ux.intel.com,
linux-doc@...r.kernel.org,
linux-kernel@...r.kernel.org,
linux-mm@...ck.org,
linux-trace-kernel@...r.kernel.org,
lorenzo.stoakes@...cle.com,
mathieu.desnoyers@...icios.com,
mhiramat@...nel.org,
mhocko@...e.com,
peterx@...hat.com,
raquini@...hat.com,
rdunlap@...radead.org,
rientjes@...gle.com,
rostedt@...dmis.org,
ryan.roberts@....com,
sunnanyong@...wei.com,
surenb@...gle.com,
thomas.hellstrom@...ux.intel.com,
tiwai@...e.de,
usamaarif642@...il.com,
vishal.moola@...il.com,
wangkefeng.wang@...wei.com,
will@...nel.org,
willy@...radead.org,
yang@...amperecomputing.com,
ziy@...dia.com,
zokeefe@...gle.com
Subject: [PATCH 1/2] mm: khugepaged: allow khugepaged to check all anonymous mTHP orders
We have now allowed mTHP collapse, but thp_vma_allowable_order() still only
checks if the PMD-sized mTHP is allowed to collapse. This prevents scanning
and collapsing of 64K mTHP when only 64K mTHP is enabled. Thus, we should
modify the checks to allow all large orders of anonymous mTHP.
Signed-off-by: Baolin Wang <baolin.wang@...ux.alibaba.com>
---
mm/khugepaged.c | 13 +++++++++----
1 file changed, 9 insertions(+), 4 deletions(-)
diff --git a/mm/khugepaged.c b/mm/khugepaged.c
index 0723b184c7a4..16542ecf02dc 100644
--- a/mm/khugepaged.c
+++ b/mm/khugepaged.c
@@ -491,8 +491,11 @@ void khugepaged_enter_vma(struct vm_area_struct *vma,
{
if (!test_bit(MMF_VM_HUGEPAGE, &vma->vm_mm->flags) &&
hugepage_pmd_enabled()) {
- if (thp_vma_allowable_order(vma, vm_flags, TVA_ENFORCE_SYSFS,
- PMD_ORDER))
+ unsigned long orders = vma_is_anonymous(vma) ?
+ THP_ORDERS_ALL_ANON : BIT(PMD_ORDER);
+
+ if (thp_vma_allowable_orders(vma, vm_flags, TVA_ENFORCE_SYSFS,
+ orders))
__khugepaged_enter(vma->vm_mm);
}
}
@@ -2618,6 +2621,8 @@ static unsigned int khugepaged_scan_mm_slot(unsigned int pages, int *result,
vma_iter_init(&vmi, mm, khugepaged_scan.address);
for_each_vma(vmi, vma) {
+ unsigned long orders = vma_is_anonymous(vma) ?
+ THP_ORDERS_ALL_ANON : BIT(PMD_ORDER);
unsigned long hstart, hend;
cond_resched();
@@ -2625,8 +2630,8 @@ static unsigned int khugepaged_scan_mm_slot(unsigned int pages, int *result,
progress++;
break;
}
- if (!thp_vma_allowable_order(vma, vma->vm_flags,
- TVA_ENFORCE_SYSFS, PMD_ORDER)) {
+ if (!thp_vma_allowable_orders(vma, vma->vm_flags,
+ TVA_ENFORCE_SYSFS, orders)) {
skip:
progress++;
continue;
--
2.43.5
Powered by blists - more mailing lists