Re: [PATCH] selftests/mm: thuge-gen: fix test_shmget() for PAGE_SIZE check

From: David Hildenbrand (Arm)

Date: Tue Aug 11 2026 - 11:50:57 EST


On 8/9/26 10:03, Mike Rapoport (Microsoft) wrote:
> Commit 49a4e7186b08 ("selftests/mm: thuge-gen: add setup of HugeTLB pages")
> changed thuge-gen test to use common functions for reading hugetlb
> attributes from sysfs, but it missed that the original read_free() function
> special cased PAGE_SIZE tests.
>
> For PAGE_SIZE tests, failure to read sysfs was ignored and read_free()
> returned 0.
>
> This allowed test_shmget() to essentially skip the check of how many huge
> pages was consumed when it ran with PAGE_SIZE.
>
> Commit 3199b0c09efa ("selftests/mm: fix read_file() return value check")
> fixed the common read_file() to actually return error on failure and this
> exposed the issue in test_shmget() that checks the number of free hugetlb
> pages even for PAGE_SIZE test, tries to access
>
> /sys/kernel/mm/hugepages/hugepages-<PAGE_SIZE>/free_hugepages
>
> and obviously fails there.
>
> Gate the checks for free huge pages on size != getpagesize() and initialize
> before and after variables to values matching PAGE_SIZE test.
>
> Fixes: 49a4e7186b08 ("selftests/mm: thuge-gen: add setup of HugeTLB pages")
> Signed-off-by: Mike Rapoport (Microsoft) <rppt@xxxxxxxxxx>
> ---

Heh :)

Acked-by: David Hildenbrand (Arm) <david@xxxxxxxxxx>

--
Cheers,

David