Re: [RFC PATCH 02/11] mm/khugepaged: remove READ_ONLY_THP_FOR_FS code in collapse_file()
From: David Hildenbrand (Arm)
Date: Mon Mar 23 2026 - 15:55:04 EST
On 3/23/26 20:47, Zi Yan wrote:
> On 23 Mar 2026, at 15:41, David Hildenbrand (Arm) wrote:
>
>> On 3/23/26 20:06, Zi Yan wrote:
>>> READ_ONLY_THP_FOR_FS is no longer present, remove corresponding code.
>>>
>>> Signed-off-by: Zi Yan <ziy@xxxxxxxxxx>
>>> ---
>>> mm/khugepaged.c | 159 +++++++++++-------------------------------------
>>> 1 file changed, 34 insertions(+), 125 deletions(-)
>>>
>>> diff --git a/mm/khugepaged.c b/mm/khugepaged.c
>>> index b2ac28ddd480..39f0b8959535 100644
>>> --- a/mm/khugepaged.c
>>> +++ b/mm/khugepaged.c
>>> @@ -1899,7 +1899,7 @@ static enum scan_result collapse_file(struct mm_struct *mm, unsigned long addr,
>>> int nr_none = 0;
>>> bool is_shmem = shmem_file(file);
>>>
>>> - VM_BUG_ON(!IS_ENABLED(CONFIG_READ_ONLY_THP_FOR_FS) && !is_shmem);
>>> + VM_WARN_ON_ONCE(!is_shmem);
>>
>> Oh, but if that means that khugepaged cannot collapse large folios in
>> FSes anymore, then this is the wrong approach I suppose?
>>
>> I would have assumed that we would now collapse for any files that
>> support large folios (in PMD size), not stopping to collapse entirely.
>
> My understanding is that collapse_file() is only used for
> READ_ONLY_THP_FOR_FS. If FSes with large folio support also use it,
> I can replace IS_ENABLE with mapping_large_folio_support().
Otherwise we'd be losing support for THP collapse in files? We'd have to
cross fingers that readahead gives us some.
So we have to be a bit careful here. We want khugepaged to collapse THPs
in filesystems that support large folios even without READ_ONLY_THP_FOR_FS.
--
Cheers,
David