Re: [PATCH] selftests/mm: add folio_split() and filemap_get_entry() race test

From: Zi Yan

Date: Sat Mar 14 2026 - 19:45:07 EST


On 14 Mar 2026, at 18:27, Andrew Morton wrote:

> On Fri, 13 Mar 2026 07:40:37 -0400 Zi Yan <ziy@xxxxxxxxxx> wrote:
>
>> The added folio_split_race_test is a modified C port of the race condition
>> test from [1]. The test creates shmem huge pages shared by both a parent
>> and a child processes, where the parent process punches holes in the shmem
>> to cause folio_split() in the kernel and the child process reads the shmem
>> in 16 threads to cause filemap_get_entry() in the kernel.
>> filemap_get_entry() reads the folio and xarray split by folio_split()
>> locklessly. The original test[2] is written in rust and uses memfd (shmem
>> backed). This C port uses shmem directly.
>
> Cool.
>
>> Note: the initial rust to C conversion is done by Cursor.
>
> Hence the CaMeLcAsE "struct SharedCtl". Fair enough.

Will change it to struct shared_ctl.

I also got some AI feedback[1] on this test program and will fix them
in a new version. I will send the new one late next week, so that I can
get feedback from human. :)

I will post the AI feedback inline in a separate email.


[1] https://sashiko.dev/#/patchset/20260313114037.3593642-1-ziy%40nvidia.com

>
>> Link: https://lore.kernel.org/all/CAKNNEtw5_kZomhkugedKMPOG-sxs5Q5OLumWJdiWXv+C9Yct0w@xxxxxxxxxxxxxx/ [1]
>> Link: https://github.com/dfinity/thp-madv-remove-test [2]
>
> I couldn't immediately find any licensing info there. Bas and Adam,
> please advise? And sending your Signed-off-by's would be appropriate.
>
> Thanks.


--
Best Regards,
Yan, Zi