path: root/mm
diff options
authorPavel Tatashin <>2021-05-04 18:39:27 -0700
committerLinus Torvalds <>2021-05-05 11:27:26 -0700
commite44605a8b1aa13d892addc59ec3d416cb186c77b (patch)
tree7de4af91e0ed03cb42404622874128a037afb444 /mm
parent79dbf135e2481eaa77b172d88c343bf85e021545 (diff)
selftests/vm: gup_test: test faulting in kernel, and verify pinnable pages
When pages are pinned they can be faulted in userland and migrated, and they can be faulted right in kernel without migration. In either case, the pinned pages must end-up being pinnable (not movable). Add a new test to gup_test, to help verify that the gup/pup (get_user_pages() / pin_user_pages()) behavior with respect to pinnable and movable pages is reasonable and correct. Specifically, provide a way to: 1) Verify that only "pinnable" pages are pinned. This is checked automatically for you. 2) Verify that gup/pup performance is reasonable. This requires comparing benchmarks between doing gup/pup on pages that have been pre-faulted in from user space, vs. doing gup/pup on pages that are not faulted in until gup/pup time (via FOLL_TOUCH). This decision is controlled with the new -z command line option. Link: Signed-off-by: Pavel Tatashin <> Reviewed-by: John Hubbard <> Cc: Dan Williams <> Cc: David Hildenbrand <> Cc: David Rientjes <> Cc: Ingo Molnar <> Cc: Ira Weiny <> Cc: James Morris <> Cc: Jason Gunthorpe <> Cc: Jason Gunthorpe <> Cc: Joonsoo Kim <> Cc: Matthew Wilcox <> Cc: Mel Gorman <> Cc: Michal Hocko <> Cc: Michal Hocko <> Cc: Mike Kravetz <> Cc: Oscar Salvador <> Cc: Peter Zijlstra <> Cc: Sasha Levin <> Cc: Steven Rostedt (VMware) <> Cc: Tyler Hicks <> Cc: Vlastimil Babka <> Signed-off-by: Andrew Morton <> Signed-off-by: Linus Torvalds <>
Diffstat (limited to 'mm')
1 files changed, 6 insertions, 0 deletions
diff --git a/mm/gup_test.c b/mm/gup_test.c
index a6ed1c877679..d974dec19e1c 100644
--- a/mm/gup_test.c
+++ b/mm/gup_test.c
@@ -52,6 +52,12 @@ static void verify_dma_pinned(unsigned int cmd, struct page **pages,
dump_page(page, "gup_test failure");
+ } else if (cmd == PIN_LONGTERM_BENCHMARK &&
+ WARN(!is_pinnable_page(page),
+ "pages[%lu] is NOT pinnable but pinned\n",
+ i)) {
+ dump_page(page, "gup_test failure");
+ break;