Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

selftests/mm: gup_tests: option to GUP all pages in a single call

We recently missed detecting an issue during early testing because the
default (!all) tests would not trigger it and even when running "all"
tests it only would happen sometimes because of races.

So let's allow for an easy way to specify "GUP all pages in a single
call", extend the test matrix and extend our default (!all) tests.

By GUP'ing all pages in a single call, with the default size of 128MiB
we'll cover multiple leaf page tables / PMDs on architectures with sane
THP sizes.

Link: https://lkml.kernel.org/r/20250910093051.1693097-1-david@redhat.com
Signed-off-by: David Hildenbrand <david@redhat.com>
Cc: Jason Gunthorpe <jgg@ziepe.ca>
Cc: John Hubbard <jhubbard@nvidia.com>
Cc: Peter Xu <peterx@redhat.com>
Cc: Lorenzo Stoakes <lorenzo.stoakes@oracle.com>
Cc: "Liam R. Howlett" <Liam.Howlett@oracle.com>
Cc: Vlastimil Babka <vbabka@suse.cz>
Cc: Mike Rapoport <rppt@kernel.org>
Cc: Suren Baghdasaryan <surenb@google.com>
Cc: Michal Hocko <mhocko@suse.com>
Cc: Shuah Khan <shuah@kernel.org>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>

authored by

David Hildenbrand and committed by
Andrew Morton
a5883fa9 9d003dec

+7 -3
+2
tools/testing/selftests/mm/gup_test.c
··· 139 139 break; 140 140 case 'n': 141 141 nr_pages = atoi(optarg); 142 + if (nr_pages < 0) 143 + nr_pages = size / psize(); 142 144 break; 143 145 case 't': 144 146 thp = 1;
+5 -3
tools/testing/selftests/mm/run_vmtests.sh
··· 138 138 # -n: How many pages to fetch together? 512 is special 139 139 # because it's default thp size (or 2M on x86), 123 to 140 140 # just test partial gup when hit a huge in whatever form 141 - for num in "-n 1" "-n 512" "-n 123"; do 141 + for num in "-n 1" "-n 512" "-n 123" "-n -1"; do 142 142 CATEGORY="gup_test" run_test ./gup_test \ 143 143 $huge $test_cmd $write $share $num 144 144 done ··· 314 314 run_gup_matrix 315 315 else 316 316 # get_user_pages_fast() benchmark 317 - CATEGORY="gup_test" run_test ./gup_test -u 317 + CATEGORY="gup_test" run_test ./gup_test -u -n 1 318 + CATEGORY="gup_test" run_test ./gup_test -u -n -1 318 319 # pin_user_pages_fast() benchmark 319 - CATEGORY="gup_test" run_test ./gup_test -a 320 + CATEGORY="gup_test" run_test ./gup_test -a -n 1 321 + CATEGORY="gup_test" run_test ./gup_test -a -n -1 320 322 fi 321 323 # Dump pages 0, 19, and 4096, using pin_user_pages: 322 324 CATEGORY="gup_test" run_test ./gup_test -ct -F 0x1 0 19 0x1000