[PATCH RFC 0/5] Test readback from fd on hugetlbfs mount

Ackerley Tng via B4 Relay posted 5 patches 6 days, 9 hours ago
tools/testing/selftests/mm/hugepage-mmap.c | 143 +++++++++++++++++++++--------
1 file changed, 105 insertions(+), 38 deletions(-)
[PATCH RFC 0/5] Test readback from fd on hugetlbfs mount
Posted by Ackerley Tng via B4 Relay 6 days, 9 hours ago
Hi,

I'm thinking of consolidating the tests for libhugetlbfs as kernel
selftests, and to start that off, I picked the simplest test:
tests/readback.c

I refactored hugepage-mmap.c to use the kselftest harness, and then used
FIXTURE_VARIANT from the harness to port in testing readback from an fd on
a hugetlbfs mount.

This output shows that the original test behavior was retained for the
memfd part:

  # ./hugepage-mmap
  TAP version 13
  1..1
  # Returned address is 0x7f312f200000
  # First hex is 0
  # First hex is 3020100
  ok 1 Read same data
  # Totals: pass:1 fail:0 xfail:0 xpass:0 skip:0 error:0

  # ./hugepage-mmap
  TAP version 13
  1..1
  # Starting 1 tests from 1 test cases.
  #  RUN           hugepage_mmap.read_write ...
  # hugepage-mmap.c:41:read_write:Returned address is 0x7f19f3a00000
  # hugepage-mmap.c:54:read_write:First hex is 0
  # hugepage-mmap.c:59:read_write:First hex is 3020100
  #            OK  hugepage_mmap.read_write
  ok 1 hugepage_mmap.read_write
  # PASSED: 1 / 1 tests passed.
  # Totals: pass:1 fail:0 xfail:0 xpass:0 skip:0 error:0

Let me know what you think before I genericize the 2M hugepage size to
other sizes!

Signed-off-by: Ackerley Tng <ackerleytng@google.com>
---
Ackerley Tng (5):
      mm: selftests: Inline check_bytes() function into caller
      mm: selftests: Inline {read,write}_bytes functions
      mm: selftests: Refactor hugepage-mmap to use kselftest harness
      mm: selftests: Update hugepage-mmap to support hugetlbfs mount
      mm: selftests: Port readback test logic from libhugetlbfs

 tools/testing/selftests/mm/hugepage-mmap.c | 143 +++++++++++++++++++++--------
 1 file changed, 105 insertions(+), 38 deletions(-)
---
base-commit: 66edb901bf874d9e0787326ba12d3548b2da8700
change-id: 20260503-port-hugetlb-selftests-9bc63bde5116

Best regards,
--
Ackerley Tng <ackerleytng@google.com>
Re: [PATCH RFC 0/5] Test readback from fd on hugetlbfs mount
Posted by tarunsahu@google.com 5 days, 14 hours ago
If you are planning to port all the libhugetlbfs tests to kselftests
I had similar efforts done in past for LTP here:
https://github.com/linux-test-project/ltp/commits/master/?author=tar-unix

These tests were migrated to LTP from libhugetlbfs.

Just want to make sure if we completely want to itegrate in kselftests
or LTP fulfil that purpose.

OR Only tests that are not part of LTP should be ported to kselftests.

Thanks

Ackerley Tng <ackerleytng@google.com> writes:

> Hi,
>
> I'm thinking of consolidating the tests for libhugetlbfs as kernel
> selftests, and to start that off, I picked the simplest test:
> tests/readback.c
>
> I refactored hugepage-mmap.c to use the kselftest harness, and then used
> FIXTURE_VARIANT from the harness to port in testing readback from an fd on
> a hugetlbfs mount.
>
> This output shows that the original test behavior was retained for the
> memfd part:
>
>   # ./hugepage-mmap
>   TAP version 13
>   1..1
>   # Returned address is 0x7f312f200000
>   # First hex is 0
>   # First hex is 3020100
>   ok 1 Read same data
>   # Totals: pass:1 fail:0 xfail:0 xpass:0 skip:0 error:0
>
>   # ./hugepage-mmap
>   TAP version 13
>   1..1
>   # Starting 1 tests from 1 test cases.
>   #  RUN           hugepage_mmap.read_write ...
>   # hugepage-mmap.c:41:read_write:Returned address is 0x7f19f3a00000
>   # hugepage-mmap.c:54:read_write:First hex is 0
>   # hugepage-mmap.c:59:read_write:First hex is 3020100
>   #            OK  hugepage_mmap.read_write
>   ok 1 hugepage_mmap.read_write
>   # PASSED: 1 / 1 tests passed.
>   # Totals: pass:1 fail:0 xfail:0 xpass:0 skip:0 error:0
>
> Let me know what you think before I genericize the 2M hugepage size to
> other sizes!
>
> Signed-off-by: Ackerley Tng <ackerleytng@google.com>
> ---
> Ackerley Tng (5):
>       mm: selftests: Inline check_bytes() function into caller
>       mm: selftests: Inline {read,write}_bytes functions
>       mm: selftests: Refactor hugepage-mmap to use kselftest harness
>       mm: selftests: Update hugepage-mmap to support hugetlbfs mount
>       mm: selftests: Port readback test logic from libhugetlbfs
>
>  tools/testing/selftests/mm/hugepage-mmap.c | 143 +++++++++++++++++++++--------
>  1 file changed, 105 insertions(+), 38 deletions(-)
> ---
> base-commit: 66edb901bf874d9e0787326ba12d3548b2da8700
> change-id: 20260503-port-hugetlb-selftests-9bc63bde5116
>
> Best regards,
> --
> Ackerley Tng <ackerleytng@google.com>
Re: [PATCH RFC 0/5] Test readback from fd on hugetlbfs mount
Posted by Mike Rapoport 5 days, 22 hours ago
Hi,

On Mon, May 18, 2026 at 11:17:32AM -0700, Ackerley Tng via B4 Relay wrote:
> Hi,
> 
> I'm thinking of consolidating the tests for libhugetlbfs as kernel
> selftests, and to start that off, I picked the simplest test:
> tests/readback.c
> 
> I refactored hugepage-mmap.c to use the kselftest harness, and then used

I made a lot of changes to mm selftests recently:
https://lore.kernel.org/all/20260511162840.375890-1-rppt@kernel.org/

This work is currently in mm.git, please take a look to avoid effort
duplication.

> FIXTURE_VARIANT from the harness to port in testing readback from an fd on
> a hugetlbfs mount.

I didn't look into the patches, but in general I'm not sure that
FIXTURE_VARIANT is such a win for simple tests.
 
> This output shows that the original test behavior was retained for the
> memfd part:
> 
>   # ./hugepage-mmap
>   TAP version 13
>   1..1
>   # Returned address is 0x7f312f200000
>   # First hex is 0
>   # First hex is 3020100
>   ok 1 Read same data
>   # Totals: pass:1 fail:0 xfail:0 xpass:0 skip:0 error:0
> 
>   # ./hugepage-mmap
>   TAP version 13
>   1..1
>   # Starting 1 tests from 1 test cases.
>   #  RUN           hugepage_mmap.read_write ...
>   # hugepage-mmap.c:41:read_write:Returned address is 0x7f19f3a00000
>   # hugepage-mmap.c:54:read_write:First hex is 0
>   # hugepage-mmap.c:59:read_write:First hex is 3020100
>   #            OK  hugepage_mmap.read_write
>   ok 1 hugepage_mmap.read_write
>   # PASSED: 1 / 1 tests passed.
>   # Totals: pass:1 fail:0 xfail:0 xpass:0 skip:0 error:0
> 
> Let me know what you think before I genericize the 2M hugepage size to
> other sizes!
> 
> Signed-off-by: Ackerley Tng <ackerleytng@google.com>
> ---
> Ackerley Tng (5):
>       mm: selftests: Inline check_bytes() function into caller
>       mm: selftests: Inline {read,write}_bytes functions
>       mm: selftests: Refactor hugepage-mmap to use kselftest harness
>       mm: selftests: Update hugepage-mmap to support hugetlbfs mount
>       mm: selftests: Port readback test logic from libhugetlbfs
> 
>  tools/testing/selftests/mm/hugepage-mmap.c | 143 +++++++++++++++++++++--------
>  1 file changed, 105 insertions(+), 38 deletions(-)
> ---
> base-commit: 66edb901bf874d9e0787326ba12d3548b2da8700
> change-id: 20260503-port-hugetlb-selftests-9bc63bde5116
> 
> Best regards,
> --
> Ackerley Tng <ackerleytng@google.com>
> 
> 

-- 
Sincerely yours,
Mike.