Re: [PATCH v5 2/2] selftests/mm: add PAGEMAP_SCAN test for THP PMD holes

From: David Hildenbrand (Arm)

Date: Thu Jul 16 2026 - 11:54:28 EST


On 7/16/26 15:03, Kiryl Shutsemau wrote:
> On Thu, Jul 16, 2026 at 01:25:22PM +0200, David Hildenbrand (Arm) wrote:
>>
>>> + /* Fast path: category_mask == return_mask == PAGE_IS_WRITTEN. */
>>> + ret = pagemap_ioctl(mem, hpage_size, regions, ARRAY_SIZE(regions), 0, 0,
>>> + PAGE_IS_WRITTEN, 0, 0, PAGE_IS_WRITTEN);
>>> + for (i = 0; ret > 0 && i < ret; i++)
>>> + fast += LEN(regions[i]);
>>> +
>>> + /* Generic path: same query expressed via category_anyof_mask. */
>>> + ret = pagemap_ioctl(mem, hpage_size, regions, ARRAY_SIZE(regions), 0, 0,
>>> + 0, PAGE_IS_WRITTEN, 0, PAGE_IS_WRITTEN);
>>> + for (i = 0; ret > 0 && i < ret; i++)
>>> + slow += LEN(regions[i]);
>>> +
>>> + ksft_test_result(fast == npages && slow == npages,
>>> + "%s pmd-hole reported written by both paths (%ld, %ld of %d)\n",
>>> + __func__, fast, slow, npages);
>>> +out:
>>> + wp_free(mem, hpage_size);
>>> + munmap(area, 2 * hpage_size);
>>> +}
>>
>> Sorry if I wasn't clear. I think unpopulated_thp_scan_test() can actually reuse
>> bits of unpopulated_scan_test().
>
> Ah. Make sense.
>
> Here's my take on this. Looks good?

Yes, thanks!

--
Cheers,

David