Re: [PATCH v4] selftests/mm: khugepaged: initialize file contents via mmap
From: David Hildenbrand (Arm)
Date: Tue Apr 28 2026 - 16:08:44 EST
On 4/28/26 21:56, Zi Yan wrote:
> On 28 Apr 2026, at 9:31, Vineet Agarwal wrote:
>
>> file_setup_area() currently allocates anonymous memory, fills it,
>> and writes it into the backing file used for collapse testing.
>>
>> Instead of copying data through write(), resize the file with
>> ftruncate(), map it directly with MAP_SHARED, and initialize the
>> mapped area in place.
>>
>> This simplifies the setup path and avoids the need for explicit
>> partial write handling.
>>
>> Signed-off-by: Vineet Agarwal <agarwal.vineet2006@xxxxxxxxx>
>>
>> v3 -> v4:
>> - Restore unrelated blank line removal
>> - Restore original close()/munmap() ordering
>> ---
>> tools/testing/selftests/mm/khugepaged.c | 14 ++++++++++++--
>> 1 file changed, 12 insertions(+), 2 deletions(-)
>
> This patch breaks the khugepaged test for READ_ONLY_THP_FOR_FS.
>
> When I ran sudo ./khugepaged all:file ~/ on ext4,
>
> collapse_max_ptes_none (khugepaged:file) fails.
madvise() still works? Is it maybe because of dirty folios? (but that should
also be the case on write ...)
--
Cheers,
David