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

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Add test that pages have the exclusive pin bias when providing
FOLL_EXCLUSIVE.

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

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);
 

-- 
2.34.1





[Index of Archives]     [Linux ARM Kernel]     [Linux ARM]     [Linux Omap]     [Fedora ARM]     [Linux for Sparc]     [IETF Annouce]     [Security]     [Bugtraq]     [Linux MIPS]     [ECOS]     [Asterisk Internet PBX]     [Linux API]

  Powered by Linux