Re: [PATCH v5 2/2] selftests/mm: add PAGEMAP_SCAN test for THP PMD holes
From: David Hildenbrand (Arm)
Date: Thu Jul 16 2026 - 07:28:57 EST
> + /* 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().
Either by having a magical "use_thp" parameter or by factoring stuff out into a
helper.
Or am I missing an important point why that would not work or be really ugly?
--
Cheers,
David