selftests/mm: hugetlb-mremap: add setup of HugeTLB pages
Subsystems (4)
PATCH v3 1/1 selftests/mm: hugetlb-mremap: add setup of HugeTLB pages
From: "Mike Rapoport (Microsoft)" <[email protected]>
commit a914785f6349da754e1226420bf4e51961956769 upstream.
hugetlb-mremap test fails if there are no free huge pages prepared by a wrapper script.
Add setup of HugeTLB pages to the test and make sure that the original settings are restored on the test exit.
[ Backport-notes: this is a partial backport containing only the aligning of 'length' to the hugepage size. The hugepage_settings.h include line and the hugetlb_setup_default() call are omitted. Without this fix, the uffd_register() call always fails on arm64 with 64K base pages and 512 MiB default HugeTLB page size causing the test to fail with the error below as 'length' is 10 MiB and not aligned to the HugeTLB page size.
# -------------------------
# running ./hugepage-mremap # ------------------------- # TAP version 13 # 1..1 # # Map haddr: Returned address is 0x7eaa40000000 # # Map daddr: Returned address is 0x7daa40000000 # # Map vaddr: Returned address is 0x7faa40000000 # Bail out! ioctl-UFFDIO_REGISTER: Invalid argument # # Planned tests != run tests (1 != 0) # # Totals: pass:0 fail:0 xfail:0 xpass:0 skip:0 error:0 # [FAIL] not ok 1 hugepage-mremap # exit=1 # NOTE: These hugetlb tests provide minimal coverage. Use # https://github.com/libhugetlbfs/libhugetlbfs.git for # hugetlb regression testing. # SKIP ./uffd-wp-mremap ] Signed-off-by: Luiz Capitulino <[email protected]> --- tools/testing/selftests/mm/hugepage-mremap.c | 5 +++++ 1 file changed, 5 insertions(+)
v3
- Preserved original changelog & subject
- Small code style difference from v2 due to git cherry-pick usage which preserved the original commit style
v2
- Added "commit <sha1> upstream" line to changelog
tools/testing/selftests/mm/hugepage-mremap.c +5 -0
@@ -97,6 +97,7 @@ static void register_region_with_uffd(char *addr, size_t len)int main (int argc,char *argv[]) { +unsigned long hugepage_size;size_t length =0 ;int ret =0 , fd;
@@ -114,7 +115,11 @@ int main(int argc, char *argv[])else length =DEFAULT_LENGTH_MB ; + hugepage_size =default_huge_page_size (); +if (!hugepage_size) +ksft_exit_skip ("Could not detect default hugetlb page size\n" ); length =MB_TO_BYTES (length); + length = (length + hugepage_size -1 ) & ~(hugepage_size -1 ); fd =memfd_create (argv[0 ],MFD_HUGETLB );if (fd <0 )ksft_exit_fail_msg ("Open failed: %s\n" ,strerror (errno));
Signature · 1 line
2.55.0
Quoted 2 lines
[ Backport-notes: this is a partial backport containing only the aligning of 'length' to the hugepage size.
Queued for 6.18, thanks.
Signature · 2 lines
Thanks, Sasha