diff mbox series

[RFC,4/5] mm/gup-test: Verify exclusive pinned

Message ID 20240618-exclusive-gup-v1-4-30472a19c5d1@quicinc.com (mailing list archive)
State Not Applicable
Headers show
Series mm/gup: Introduce exclusive GUP pinning | expand

Commit Message

Elliot Berman June 19, 2024, 12:05 a.m. UTC
Add test that pages have the exclusive pin bias when providing
FOLL_EXCLUSIVE.

Signed-off-by: Elliot Berman <quic_eberman@quicinc.com>
---
 mm/gup_test.c | 22 ++++++++++++++++++++++
 1 file changed, 22 insertions(+)
diff mbox series

Patch

diff --git a/mm/gup_test.c b/mm/gup_test.c
index eeb3f4d87c510..9c6b8c93e44a7 100644
--- a/mm/gup_test.c
+++ b/mm/gup_test.c
@@ -66,6 +66,26 @@  static void verify_dma_pinned(unsigned int cmd, struct page **pages,
 	}
 }
 
+static void verify_exclusive_pinned(unsigned int gup_flags, struct page **pages,
+				    unsigned long nr_pages)
+{
+	unsigned long i;
+	const struct folio *folio;
+
+	if (!(gup_flags & FOLL_EXCLUSIVE))
+		return;
+
+	for (i = 0; i < nr_pages; i++) {
+		folio = page_folio(pages[i]);
+
+		if (WARN(!folio_maybe_exclusive_pinned(folio),
+			 "pages[%lu] is not exclusive pinned\n", i)) {
+			dump_page(&folio->page, "gup_test failure");
+			break;
+		}
+	}
+}
+
 static void dump_pages_test(struct gup_test *gup, struct page **pages,
 			    unsigned long nr_pages)
 {
@@ -185,6 +205,8 @@  static int __gup_test_ioctl(unsigned int cmd,
 	 */
 	verify_dma_pinned(cmd, pages, nr_pages);
 
+	verify_exclusive_pinned(gup->gup_flags, pages, nr_pages);
+
 	if (cmd == DUMP_USER_PAGES_TEST)
 		dump_pages_test(gup, pages, nr_pages);