selftests/mm: separate GUP microbenchmarking from functional testing
Subsystems (5)
v2 cover selftests/mm: separate GUP microbenchmarking from functional testing
gup_test.c currently serves two distinct purposes: microbenchmarking (GUP_FAST_BENCHMARK, PIN_FAST_BENCHMARK, PIN_LONGTERM_BENCHMARK) and functional correctness testing (GUP_BASIC_TEST, PIN_BASIC_TEST, DUMP_USER_PAGES_TEST). Mixing these in a single binary means functional tests cannot be run or reported individually, and run_vmtests.sh must invoke the binary multiple times with different flag combinations to cover all configurations. This patch series separates the two concerns:tools/mm/gup_bench for benchmarking and tools/testing/selftests/mm/gup_test for functional testing.
Patch 1 adds tools/mm/gup_bench.c, a standalone microbenchmark for GUP_FAST, PIN_FAST and PIN_LONGTERM via the CONFIG_GUP_TEST debugfs interface. It runs the same matrix of configurations as the old run_gup_matrix() shell function (all three commands, read/write, private/shared, four page counts, THP on/off, hugetlb), but as a standalone C program under tools/mm with no dependency on kselftest.
Patch 2 rewrites gup_test.c as a kselftest harness-based selftest. It covers all five GUP kernel functions (get_user_pages, get_user_pages_fast, pin_user_pages, pin_user_pages_fast, pin_user_pages with FOLL_LONGTERM) plus DUMP_USER_PAGES_TEST, across 12 mapping configurations (THP on, THP off and hugetlb, each across private/shared and read/write variants) and four batch sizes (1, 512, 123, all pages). Results are reported as standard TAP output with no command-line arguments required.
---
These patches apply on top of mm/mm-new.
Changes in v2:
- Address v1 feedback from Sashiko
- Add fast and longterm GUP/PUP coverage
- Sweep nr_pages_per_call over 1, 512, 123, and all pages
- Call madvise(MADV_NOHUGEPAGE) in non-THP variants
- Use 256 MB for hugetlb fixtures
- Use hugetlb_restore_settings() in FIXTURE_TEARDOWN instead of atexit()
- Add TH_LOG to report nr_pages_per_call for each iteration
- Update Documentation/core-api/pin_user_pages.rst unit testing section
Sarthak Sharma (2):
tools/mm: add a standalone GUP microbenchmark selftests/mm: rewrite gup_test as a standalone harness-based selftest
Documentation/core-api/pin_user_pages.rst | 12 +- MAINTAINERS | 1 + tools/mm/.gitignore | 2 + tools/mm/Makefile | 6 +- tools/mm/gup_bench.c | 491 ++++++++++++++++++++ tools/testing/selftests/mm/gup_test.c | 536 +++++++++++++--------- tools/testing/selftests/mm/run_vmtests.sh | 37 +- 7 files changed, 822 insertions(+), 263 deletions(-) create mode 100644 tools/mm/gup_bench.c
base-commit: 2c3f468717231305523ddcd94d91c0d5e4a72419
Signature · 1 line
2.39.5
PATCH v2 1/2 tools/mm: add a standalone GUP microbenchmark
Add a command-line tool for benchmarking get_user_pages fast-path (GUP_FAST), pin_user_pages fast-path (PIN_FAST), and pin_user_pages longterm (PIN_LONGTERM) via the CONFIG_GUP_TEST debugfs interface.
When invoked without arguments, gup_bench runs the same matrix of configurations as run_gup_matrix() in run_vmtests.sh: all three GUP commands across read/write, private/shared mappings, and a range of page counts, with THP on/off for regular mappings and hugetlb for huge page mappings.
This tool is a mix of reused and new logic. The mapping/setup path comes from selftests/mm/gup_test.c, while the default benchmark matrix matches run_gup_matrix() in run_vmtests.sh. The standalone CLI and tools/mm integration are added here so tools/mm does not depend on kselftest.
Add gup_bench to BUILD_TARGETS and INSTALL_TARGETS in tools/mm/Makefile, and ignore the resulting binary in tools/mm/.gitignore. While here, also add the missing thp_swap_allocator_test entry to .gitignore.
Add tools/mm/gup_bench.c to the GUP entry in MAINTAINERS.
--- MAINTAINERS | 1 + tools/mm/.gitignore | 2 + tools/mm/Makefile | 6 +- tools/mm/gup_bench.c | 491 +++++++++++++++++++++++++++++++++++++++++++ 4 files changed, 497 insertions(+), 3 deletions(-) create mode 100644 tools/mm/gup_bench.c
MAINTAINERS +1 -0
@@ -16830,6 +16830,7 @@ T: git git://git.kernel.org/pub/scm/linux/kernel/git/akpm/mm F: mm/gup.c F: mm/gup_test.c F: mm/gup_test.h +F: tools/mm/gup_bench.c F: tools/testing/selftests/mm/gup_longterm.c F: tools/testing/selftests/mm/gup_test.c
tools/mm/.gitignore +2 -0
@@ -2,3 +2,5 @@ slabinfo page-types page_owner_sort +thp_swap_allocator_test +gup_bench
tools/mm/Makefile +3 -3
@@ -3,13 +3,13 @@ # include ../scripts/Makefile.include -BUILD_TARGETS=page-types slabinfo page_owner_sort thp_swap_allocator_test +BUILD_TARGETS=page-types slabinfo page_owner_sort thp_swap_allocator_test gup_bench INSTALL_TARGETS = $(BUILD_TARGETS) thpmaps LIB_DIR = ../lib/api LIBS = $(LIB_DIR)/libapi.a -CFLAGS += -Wall -Wextra -I../lib/ -pthread +CFLAGS += -Wall -Wextra -I../lib/ -I../.. -pthread LDFLAGS += $(LIBS) -pthread all: $(BUILD_TARGETS)
@@ -23,7 +23,7 @@ $(LIBS): $(CC) $(CFLAGS) -o $@ $< $(LDFLAGS) clean: - $(RM) page-types slabinfo page_owner_sort thp_swap_allocator_test + $(RM) page-types slabinfo page_owner_sort thp_swap_allocator_test gup_bench make -C $(LIB_DIR) clean sbindir ?= /usr/sbin
tools/mm/gup_bench.c new file +491 -0
491 lines not on this page · raw message
Signature · 1 line
2.39.5
Mike Rapoport
reviewerRe: [PATCH v2 1/2] tools/mm: add a standalone GUP microbenchmark
(added broonie)
Hi,
Quoted 30 lines · Sarthak Sharma
Add a command-line tool for benchmarking
get_user_pagesfast-path (GUP_FAST),pin_user_pagesfast-path (PIN_FAST), andpin_user_pageslongterm (PIN_LONGTERM) via theCONFIG_GUP_TESTdebugfs interface.When invoked without arguments,
gup_benchruns the same matrix of configurations asrun_gup_matrix()inrun_vmtests.sh: all three GUP commands across read/write, private/shared mappings, and a range of page counts, with THP on/off for regular mappings and hugetlb for huge page mappings.This tool is a mix of reused and new logic. The mapping/setup path comes from
selftests/mm/gup_test.c, while the default benchmark matrix matchesrun_gup_matrix()inrun_vmtests.sh. The standalone CLI andtools/mmintegration are added here sotools/mmdoes not depend on kselftest.Add
gup_benchtoBUILD_TARGETSandINSTALL_TARGETSintools/mm/Makefile, and ignore the resulting binary intools/mm/.gitignore. While here, also add the missingthp_swap_allocator_testentry to .gitignore.Add
tools/mm/gup_bench.cto the GUP entry inMAINTAINERS.Suggested-by David Hildenbrand (Arm) <[email protected]>Signed-off-by Sarthak Sharma <[email protected]>--- MAINTAINERS | 1 + tools/mm/.gitignore | 2 + tools/mm/Makefile | 6 +- tools/mm/gup_bench.c | 491 +++++++++++++++++++++++++++++++++++++++++++ 4 files changed, 497 insertions(+), 3 deletions(-) create mode 100644 tools/mm/gup_bench.c
...
Quoted 7 lines
+/*
+ * Local HugeTLB setup helpers forgup_bench.
+ *
+ * These helpers were copied fromtools/testing/selftests/mm/and adjusted to
+ * remove the ksft formatting. Keep this copy local sotools/mmdoes not
+ * depend on ksft output behavior.
+ */
It looks like self tests of at least 5 subsystems beside mm use hugetlb:
$ git grep -l "Hugepagesize:" tools/testing/selftests/ | grep -v "selftests/mm" tools/testing/selftests/arm64/mte/check_hugetlb_options.c tools/testing/selftests/cgroup/test_hugetlb_memcg.c tools/testing/selftests/kvm/lib/test_util.c tools/testing/selftests/memfd/common.c tools/testing/selftests/net/tcp_mmap.c
It seems that we need to better share the common code in tools/testing/selftest.
And adding another copy of the hugetlb detection and setup code does not seem like a great idea.
Quoted 26 lines
tools/mm/gup_bench.c new file +26
-0+ +static unsigned int psize (void ) +{ +static unsigned int __page_size; + +if (!__page_size) + __page_size =sysconf (_SC_PAGESIZE); +return __page_size; +} + +static unsigned long default_huge_page_size (void ) +{ +FILE *f =fopen ("/proc/meminfo" ,"r" ); +unsigned long hpage_size =0 ; +char buf[256 ]; + +if (!f) +return 0 ; +while (fgets (buf,sizeof (buf), f)) { +if (sscanf (buf,"Hugepagesize: %lu kB" , &hpage_size) ==1 ) +break ; + } +fclose (f); + hpage_size <<=10 ; +return hpage_size; +}
Signature · 2 lines
Sincerely yours, Mike.
Re: [PATCH v2 1/2] tools/mm: add a standalone GUP microbenchmark
Quoted 55 lines · Mike Rapoport
(added broonie)
Hi,
Quoted 30 lines · Sarthak Sharma
Add a command-line tool for benchmarking
get_user_pagesfast-path (GUP_FAST),pin_user_pagesfast-path (PIN_FAST), andpin_user_pageslongterm (PIN_LONGTERM) via theCONFIG_GUP_TESTdebugfs interface.When invoked without arguments,
gup_benchruns the same matrix of configurations asrun_gup_matrix()inrun_vmtests.sh: all three GUP commands across read/write, private/shared mappings, and a range of page counts, with THP on/off for regular mappings and hugetlb for huge page mappings.This tool is a mix of reused and new logic. The mapping/setup path comes from
selftests/mm/gup_test.c, while the default benchmark matrix matchesrun_gup_matrix()inrun_vmtests.sh. The standalone CLI andtools/mmintegration are added here sotools/mmdoes not depend on kselftest.Add
gup_benchtoBUILD_TARGETSandINSTALL_TARGETSintools/mm/Makefile, and ignore the resulting binary intools/mm/.gitignore. While here, also add the missingthp_swap_allocator_testentry to .gitignore.Add
tools/mm/gup_bench.cto the GUP entry inMAINTAINERS.Suggested-by David Hildenbrand (Arm) <[email protected]>Signed-off-by Sarthak Sharma <[email protected]>--- MAINTAINERS | 1 + tools/mm/.gitignore | 2 + tools/mm/Makefile | 6 +- tools/mm/gup_bench.c | 491 +++++++++++++++++++++++++++++++++++++++++++ 4 files changed, 497 insertions(+), 3 deletions(-) create mode 100644 tools/mm/gup_bench.c...
Quoted 7 lines
+/*
+ * Local HugeTLB setup helpers forgup_bench.
+ *
+ * These helpers were copied fromtools/testing/selftests/mm/and adjusted to
+ * remove the ksft formatting. Keep this copy local sotools/mmdoes not
+ * depend on ksft output behavior.
+ */It looks like self tests of at least 5 subsystems beside mm use hugetlb:
$ git grep -l "Hugepagesize:" tools/testing/selftests/ | grep -v "selftests/mm" tools/testing/selftests/arm64/mte/check_hugetlb_options.c tools/testing/selftests/cgroup/test_hugetlb_memcg.c tools/testing/selftests/kvm/lib/test_util.c tools/testing/selftests/memfd/common.c tools/testing/selftests/net/tcp_mmap.c
Quoted 5 lines
It seems that we need to better share the common code in
tools/testing/selftest.And adding another copy of the hugetlb detection and setup code does not seem like a great idea.
Does it sound too insane to just do some sort of #include "../testing/selftests/mm/..." to use the common helpers?
Quoted 28 lines
Quoted 27 lines
tools/mm/gup_bench.c new file +26
-0+ +static unsigned int psize (void ) +{ +static unsigned int __page_size; + +if (!__page_size) + __page_size =sysconf (_SC_PAGESIZE); +return __page_size; +} + +static unsigned long default_huge_page_size (void ) +{ +FILE *f =fopen ("/proc/meminfo" ,"r" ); +unsigned long hpage_size =0 ; +char buf[256 ]; + +if (!f) +return 0 ; +while (fgets (buf,sizeof (buf), f)) { +if (sscanf (buf,"Hugepagesize: %lu kB" , &hpage_size) ==1 ) +break ; + } +fclose (f); + hpage_size <<=10 ; +return hpage_size; +}
Re: [PATCH v2 1/2] tools/mm: add a standalone GUP microbenchmark
In reply to Mike RapoportHi Mike!
Quoted 55 lines · Mike Rapoport
(added broonie)
Hi,
Quoted 30 lines · Sarthak Sharma
Add a command-line tool for benchmarking
get_user_pagesfast-path (GUP_FAST),pin_user_pagesfast-path (PIN_FAST), andpin_user_pageslongterm (PIN_LONGTERM) via theCONFIG_GUP_TESTdebugfs interface.When invoked without arguments,
gup_benchruns the same matrix of configurations asrun_gup_matrix()inrun_vmtests.sh: all three GUP commands across read/write, private/shared mappings, and a range of page counts, with THP on/off for regular mappings and hugetlb for huge page mappings.This tool is a mix of reused and new logic. The mapping/setup path comes from
selftests/mm/gup_test.c, while the default benchmark matrix matchesrun_gup_matrix()inrun_vmtests.sh. The standalone CLI andtools/mmintegration are added here sotools/mmdoes not depend on kselftest.Add
gup_benchtoBUILD_TARGETSandINSTALL_TARGETSintools/mm/Makefile, and ignore the resulting binary intools/mm/.gitignore. While here, also add the missingthp_swap_allocator_testentry to .gitignore.Add
tools/mm/gup_bench.cto the GUP entry inMAINTAINERS.Suggested-by David Hildenbrand (Arm) <[email protected]>Signed-off-by Sarthak Sharma <[email protected]>--- MAINTAINERS | 1 + tools/mm/.gitignore | 2 + tools/mm/Makefile | 6 +- tools/mm/gup_bench.c | 491 +++++++++++++++++++++++++++++++++++++++++++ 4 files changed, 497 insertions(+), 3 deletions(-) create mode 100644 tools/mm/gup_bench.c...
Quoted 7 lines
+/*
+ * Local HugeTLB setup helpers forgup_bench.
+ *
+ * These helpers were copied fromtools/testing/selftests/mm/and adjusted to
+ * remove the ksft formatting. Keep this copy local sotools/mmdoes not
+ * depend on ksft output behavior.
+ */It looks like self tests of at least 5 subsystems beside mm use hugetlb:
$ git grep -l "Hugepagesize:" tools/testing/selftests/ | grep -v "selftests/mm" tools/testing/selftests/arm64/mte/check_hugetlb_options.c tools/testing/selftests/cgroup/test_hugetlb_memcg.c tools/testing/selftests/kvm/lib/test_util.c tools/testing/selftests/memfd/common.c tools/testing/selftests/net/tcp_mmap.c
Quoted 5 lines
It seems that we need to better share the common code in
tools/testing/selftest.And adding another copy of the hugetlb detection and setup code does not seem like a great idea.
Agreed, but that was the least disruptive approach I could think of.
I am thinking of doing this now: should I move the hugepage_settings.[ch] to tools/lib/ and move the read_num(), write_num(), read_file() and write_file() helpers to a separate file in tools/lib/ itself without any ksft dependency? Then both tools/testing/selftests/* and tools/mm/ could share the same code.
Please let me know if some different approach is preferred.
Quoted 28 lines
Quoted 27 lines
tools/mm/gup_bench.c new file +26
-0+ +static unsigned int psize (void ) +{ +static unsigned int __page_size; + +if (!__page_size) + __page_size =sysconf (_SC_PAGESIZE); +return __page_size; +} + +static unsigned long default_huge_page_size (void ) +{ +FILE *f =fopen ("/proc/meminfo" ,"r" ); +unsigned long hpage_size =0 ; +char buf[256 ]; + +if (!f) +return 0 ; +while (fgets (buf,sizeof (buf), f)) { +if (sscanf (buf,"Hugepagesize: %lu kB" , &hpage_size) ==1 ) +break ; + } +fclose (f); + hpage_size <<=10 ; +return hpage_size; +}
Re: [PATCH v2 1/2] tools/mm: add a standalone GUP microbenchmark
Quoted 8 lines · Sarthak Sharma
Quoted 5 lines · Mike Rapoport
It seems that we need to better share the common code in
tools/testing/selftest.And adding another copy of the hugetlb detection and setup code does not seem like a great idea.
Quoted 7 lines
Agreed, but that was the least disruptive approach I could think of.
I am thinking of doing this now: should I move the hugepage_settings.[ch] to
tools/lib/and move theread_num(),write_num(),read_file()andwrite_file()helpers to a separate file intools/lib/itself without any ksft dependency? Then bothtools/testing/selftests/*andtools/mm/could share the same code.
Using tools/lib sounds sensible to me - as well as the sharing it makes it clear that it's a library used by multiple things so avoids the issues we sometimes have with selftest directories referencing each other.
Mike Rapoport
reviewerRe: [PATCH v2 1/2] tools/mm: add a standalone GUP microbenchmark
Quoted 6 lines · Mark Brown
Quoted 4 lines · Sarthak Sharma
Quoted 2 lines · Mike Rapoport
It seems that we need to better share the common code in
tools/testing/selftest.
Quoted 8 lines
Quoted 8 lines
Quoted 2 lines
And adding another copy of the hugetlb detection and setup code does not seem like a great idea.
Agreed, but that was the least disruptive approach I could think of.
I am thinking of doing this now: should I move the hugepage_settings.[ch] to
tools/lib/and move theread_num(),write_num(),read_file()andwrite_file()helpers to a separate file in
these might need some adjustments because they use ksft_(), but in general it makes sense to me.
Quoted 7 lines
Quoted 2 lines
tools/lib/itself without any ksft dependency? Then bothtools/testing/selftests/*andtools/mm/could share the same code.Using
tools/libsounds sensible to me - as well as the sharing it makes it clear that it's a library used by multiple things so avoids the issues we sometimes have with selftest directories referencing each other.
I'd make it tools/lib/mm as most of the files tools/lib/*.c are stubs for the kernel functions.
Signature · 2 lines
Sincerely yours, Mike.
Re: [PATCH v2 1/2] tools/mm: add a standalone GUP microbenchmark
Quoted 22 lines · Mike Rapoport
Quoted 6 lines · Mark Brown
Quoted 4 lines · Sarthak Sharma
Quoted 2 lines · Mike Rapoport
It seems that we need to better share the common code in
tools/testing/selftest.Quoted 8 lines
Quoted 8 lines
Quoted 2 lines
And adding another copy of the hugetlb detection and setup code does not seem like a great idea.
Agreed, but that was the least disruptive approach I could think of.
I am thinking of doing this now: should I move the hugepage_settings.[ch] to
tools/lib/and move theread_num(),write_num(),read_file()andwrite_file()helpers to a separate file inthese might need some adjustments because they use
ksft_(), but in general it makes sense to me.Quoted 3 lines
Quoted 2 lines
tools/lib/itself without any ksft dependency? Then bothtools/testing/selftests/*andtools/mm/could share the same code.
Quoted 8 lines
Quoted 4 lines
Using
tools/libsounds sensible to me - as well as the sharing it makes it clear that it's a library used by multiple things so avoids the issues we sometimes have with selftest directories referencing each other.I'd make it
tools/lib/mmas most of the filestools/lib/*.care stubs for the kernel functions.
Thanks Mark and Mike, I'll include these changes in v3.
PATCH v2 2/2 selftests/mm: rewrite gup_test as a standalone harness-based selftest
In reply to Sarthak SharmaRewrite gup_test.c using kselftest_harness.h. The new test covers 12 mapping configurations: THP on, THP off and hugetlb, each across private/shared and read/write variants. It runs seven test cases per
variant: get_user_pages, get_user_pages_fast, pin_user_pages, pin_user_pages_fast, pin_user_pages_longterm, and DUMP_USER_PAGES_TEST via both get and pin.
Each test case sweeps four nr_pages_per_call values: 1, 512, 123, and all pages. This preserves the old run_gup_matrix() sweep: 12 mapping combinations x 5 GUP/PUP operations x 4 batch sizes = 240 ioctl sweeps. It also expands DUMP_USER_PAGES_TEST coverage from one standalone invocation to 12 variants x 2 dump modes x 4 batch sizes = 96 additional sweeps, for 336 total ioctl sweeps and 84 TAP-reported cases.
On a Radxa Orion O6 board, ./gup_test completes in 5.07s on average over 10 runs (range: 4.94s - 5.18s).
Update run_vmtests.sh: remove run_gup_matrix() and the multiple flagged invocations of gup_test, replacing them with a single unconditional invocation. Benchmark functionality is handled by tools/mm/gup_bench introduced in the previous patch.
Update Documentation/core-api/pin_user_pages.rst to reflect the new harness-based gup_test interface rather than command-line flag invocations.
--- Documentation/core-api/pin_user_pages.rst | 12 +- tools/testing/selftests/mm/gup_test.c | 536 +++++++++++++--------- tools/testing/selftests/mm/run_vmtests.sh | 37 +- 3 files changed, 325 insertions(+), 260 deletions(-)
Documentation/core-api/pin_user_pages.rst +9 -3
@@ -230,10 +230,16 @@ This file:: tools/testing/selftests/mm/gup_test.c -has the following new calls to exercise the new pin*() wrapper functions: +contains the following test cases to exercise pin_user_pages*(): -* PIN_FAST_BENCHMARK (./gup_test -a) -* PIN_BASIC_TEST (./gup_test -b) +* pin_user_pages via PIN_BASIC_TEST +* pin_user_pages_fast via PIN_FAST_BENCHMARK +* pin_user_pages_longterm via PIN_LONGTERM_BENCHMARK + +Run with:: + + make -C tools/testing/selftests/mm + ./tools/testing/selftests/mm/gup_test You can monitor how many total dma-pinned pages have been acquired and released since the system was booted, via two new /proc/vmstat entries: ::
tools/testing/selftests/mm/gup_test.c +315 -221
582 lines not on this page · raw message
tools/testing/selftests/mm/run_vmtests.sh +1 -36
@@ -130,30 +130,6 @@ test_selected() { fi } -run_gup_matrix() { - # -t: thp=on, -T: thp=off, -H: hugetlb=on - local hugetlb_mb=256 - - for huge in -t -T "-H -m $hugetlb_mb"; do - # -u: gup-fast, -U: gup-basic, -a: pin-fast, -b: pin-basic, -L: pin-longterm - for test_cmd in -u -U -a -b -L; do - # -w: write=1, -W: write=0 - for write in -w -W; do - # -S: shared - for share in -S " "; do - # -n: How many pages to fetch together? 512 is special - # because it's default thp size (or 2M on x86), 123 to - # just test partial gup when hit a huge in whatever form - for num in "-n 1" "-n 512" "-n 123" "-n -1"; do - CATEGORY="gup_test" run_test ./gup_test \ - $huge $test_cmd $write $share $num - done - done - done - done - done -} - # filter 64bit architectures ARCH64STR="arm64 mips64 parisc64 ppc64 ppc64le riscv64 s390x sparc64 x86_64" if [ -z "$ARCH" ]; then
@@ -239,18 +215,7 @@ fi CATEGORY="mmap" run_test ./map_fixed_noreplace -if $RUN_ALL; then - run_gup_matrix -else - # get_user_pages_fast() benchmark - CATEGORY="gup_test" run_test ./gup_test -u -n 1 - CATEGORY="gup_test" run_test ./gup_test -u -n -1 - # pin_user_pages_fast() benchmark - CATEGORY="gup_test" run_test ./gup_test -a -n 1 - CATEGORY="gup_test" run_test ./gup_test -a -n -1 -fi -# Dump pages 0, 19, and 4096, using pin_user_pages: -CATEGORY="gup_test" run_test ./gup_test -ct -F 0x1 0 19 0x1000 +CATEGORY="gup_test" run_test ./gup_test CATEGORY="gup_test" run_test ./gup_longterm CATEGORY="userfaultfd" run_test ./uffd-unit-tests
Signature · 1 line
2.39.5
Andrew Morton
maintainerQuoted 17 lines · On Tue, 19 May 2026 17:35:04 +0530 Sarthak Sharma <[email protected]>…
gup_test.ccurrently serves two distinct purposes: microbenchmarking (GUP_FAST_BENCHMARK,PIN_FAST_BENCHMARK,PIN_LONGTERM_BENCHMARK) and functional correctness testing (GUP_BASIC_TEST,PIN_BASIC_TEST,DUMP_USER_PAGES_TEST). Mixing these in a single binary means functional tests cannot be run or reported individually, andrun_vmtests.shmust invoke the binary multiple times with different flag combinations to cover all configurations. This patch series separates the two concerns:tools/mm/gup_benchfor benchmarking andtools/testing/selftests/mm/gup_testfor functional testing.Patch 1 adds
tools/mm/gup_bench.c, a standalone microbenchmark forGUP_FAST,PIN_FASTandPIN_LONGTERMvia theCONFIG_GUP_TESTdebugfs interface. It runs the same matrix of configurations as the oldrun_gup_matrix()shell function (all three commands, read/write, private/shared, four page counts, THP on/off, hugetlb), but as a standalone C program undertools/mmwith no dependency on kselftest.
Quoted 7 lines
Patch 2 rewrites
gup_test.cas a kselftest harness-based selftest. It covers all five GUP kernel functions (get_user_pages,get_user_pages_fast,pin_user_pages,pin_user_pages_fast,pin_user_pageswithFOLL_LONGTERM) plusDUMP_USER_PAGES_TEST, across 12 mapping configurations (THP on, THP off and hugetlb, each across private/shared and read/write variants) and four batch sizes (1, 512, 123, all pages). Results are reported as standard TAP output with no command-line arguments required.
Thanks. AI review asked a few things which seem fairly minor to me, but probably legitimate:
https://sashiko.dev/#/patchset/[email protected]
Hi Andrew!
Quoted 27 lines · Andrew Morton
Quoted 17 lines · On Tue, 19 May 2026 17:35:04 +0530 Sarthak Sharma <[email protected]>…
gup_test.ccurrently serves two distinct purposes: microbenchmarking (GUP_FAST_BENCHMARK,PIN_FAST_BENCHMARK,PIN_LONGTERM_BENCHMARK) and functional correctness testing (GUP_BASIC_TEST,PIN_BASIC_TEST,DUMP_USER_PAGES_TEST). Mixing these in a single binary means functional tests cannot be run or reported individually, andrun_vmtests.shmust invoke the binary multiple times with different flag combinations to cover all configurations. This patch series separates the two concerns:tools/mm/gup_benchfor benchmarking andtools/testing/selftests/mm/gup_testfor functional testing.Patch 1 adds
tools/mm/gup_bench.c, a standalone microbenchmark forGUP_FAST,PIN_FASTandPIN_LONGTERMvia theCONFIG_GUP_TESTdebugfs interface. It runs the same matrix of configurations as the oldrun_gup_matrix()shell function (all three commands, read/write, private/shared, four page counts, THP on/off, hugetlb), but as a standalone C program undertools/mmwith no dependency on kselftest.Quoted 7 lines
Patch 2 rewrites
gup_test.cas a kselftest harness-based selftest. It covers all five GUP kernel functions (get_user_pages,get_user_pages_fast,pin_user_pages,pin_user_pages_fast,pin_user_pageswithFOLL_LONGTERM) plusDUMP_USER_PAGES_TEST, across 12 mapping configurations (THP on, THP off and hugetlb, each across private/shared and read/write variants) and four batch sizes (1, 512, 123, all pages). Results are reported as standard TAP output with no command-line arguments required.
Quoted 3 lines
Thanks. AI review asked a few things which seem fairly minor to me, but probably legitimate:
https://sashiko.dev/#/patchset/[email protected]
Thanks for pointing it out. I'll address the review comments and send a v3.