[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <d735a408-1bf8-4c43-94fc-6e3fa1068bab@linux.alibaba.com>
Date: Thu, 21 Aug 2025 09:09:47 +0800
From: Baolin Wang <baolin.wang@...ux.alibaba.com>
To: Dev Jain <dev.jain@....com>, akpm@...ux-foundation.org, hughd@...gle.com,
david@...hat.com, lorenzo.stoakes@...cle.com
Cc: ziy@...dia.com, Liam.Howlett@...cle.com, npache@...hat.com,
ryan.roberts@....com, baohua@...nel.org, linux-mm@...ck.org,
linux-kernel@...r.kernel.org
Subject: Re: [RFC PATCH 01/11] mm: khugepaged: add khugepaged_max_ptes_none
check in collapse_file()
On 2025/8/20 18:13, Dev Jain wrote:
>
> On 20/08/25 2:37 pm, Baolin Wang wrote:
>> 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 <baolin.wang@...ux.alibaba.com>
>> ---
>> 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;
>> }
>
> Isn't this already being checked in collapse_scan_file(), in the block
> if (cc->is_khugepaged && present < HPAGE_PMD_NR -
> khugepaged_max_ptes_none)?
Yes, as I said in the commit message, this follows the same behavior as
for anonymous folios, by checking the folio’s present state again before
isolating it, since the folio's present state could change after the
check in collapse_scan_file().
In addition, and importantly, this prepares for the mTHP collapse check,
see patch 4.
Powered by blists - more mailing lists