Similar to the anonymous folios collapse, we should also check the 'khugepaged_max_ptes_none' when trying to collapse shmem/file folios. Signed-off-by: Baolin Wang --- mm/khugepaged.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/mm/khugepaged.c b/mm/khugepaged.c index 5a3386043f39..5d4493b77f3c 100644 --- a/mm/khugepaged.c +++ b/mm/khugepaged.c @@ -2125,6 +2125,13 @@ static int collapse_file(struct mm_struct *mm, unsigned long addr, } } nr_none++; + + if (cc->is_khugepaged && nr_none > khugepaged_max_ptes_none) { + result = SCAN_EXCEED_NONE_PTE; + count_vm_event(THP_SCAN_EXCEED_NONE_PTE); + goto xa_locked; + } + index++; continue; } -- 2.43.5