Re: [PATCH 1/4] selftests/mm: open pagemap and kpageflags once for check_huge()

From: Zi Yan

Date: Tue Sep 29 2026 - 11:35:28 EST


On 29 Sep 2026, at 9:15, Kiryl Shutsemau wrote:

> From: "Kiryl Shutsemau (Meta)" <kas@xxxxxxxxxx>
>
> check_huge_anon() and check_huge_file() open /proc/self/pagemap and
> /proc/kpageflags on every call and read the PMD size from sysfs on top.
> The khugepaged test calls them hundreds of times.
>
> Open both once and keep the descriptors. A pagemap descriptor is tied
> to the mm of the process that opened it, and the khugepaged fork() cases
> call check_huge() from the child, so reopen it when getpid() changes.
>
> Cache the PMD size in read_pmd_pagesize() as well.

This part might be overlapping with Yeoreum’s another series[1].

[1] https://lore.kernel.org/all/20260921-fix_hpage_macro-v4-2-cdea4fc6ce3f@xxxxxxx/

>
> Assisted-by: LLM
> Signed-off-by: Kiryl Shutsemau (Meta) <kas@xxxxxxxxxx>
> ---
> tools/testing/selftests/mm/vm_util.c | 68 ++++++++++++++++++++--------
> 1 file changed, 50 insertions(+), 18 deletions(-)
>



Best Regards,
Yan, Zi