kvm.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] vfio/type1: Absorb num_pages_contiguous()
@ 2025-08-05  1:24 Alex Williamson
  2025-08-05 13:27 ` David Hildenbrand
  2025-08-06 12:35 ` David Hildenbrand
  0 siblings, 2 replies; 11+ messages in thread
From: Alex Williamson @ 2025-08-05  1:24 UTC (permalink / raw)
  To: alex.williamson, kvm; +Cc: David Hildenbrand, Jason Gunthorpe, Li Zhe

Objections were raised to adding this helper to common code with only a
single user and dubious generalism.  Pull it back into subsystem code.

Link: https://lore.kernel.org/all/CAHk-=whhYRMS7Xc9k_JBdrGvp++JLmU0T2xXEgn046hWrj7q8Q@mail.gmail.com/
Cc: David Hildenbrand <david@redhat.com>
Cc: Jason Gunthorpe <jgg@nvidia.com>
Cc: Li Zhe <lizhe.67@bytedance.com>
Signed-off-by: Alex Williamson <alex.williamson@redhat.com>
---
 drivers/vfio/vfio_iommu_type1.c | 22 ++++++++++++++++++++++
 include/linux/mm.h              | 23 -----------------------
 2 files changed, 22 insertions(+), 23 deletions(-)

diff --git a/drivers/vfio/vfio_iommu_type1.c b/drivers/vfio/vfio_iommu_type1.c
index 33384a8c152d..3f06a8d937fa 100644
--- a/drivers/vfio/vfio_iommu_type1.c
+++ b/drivers/vfio/vfio_iommu_type1.c
@@ -659,6 +659,28 @@ static long vpfn_pages(struct vfio_dma *dma,
 	return ret;
 }
 
+/*
+ * num_pages_contiguous() - determine the number of contiguous pages
+ * starting from the first page.
+ *
+ * Pages are contiguous if they represent contiguous PFNs. Depending on
+ * the memory model, this can mean that the addresses of the "struct page"s
+ * are not contiguous.
+ *
+ * @pages: an array of page pointers
+ * @nr_pages: length of the array
+ */
+static unsigned long num_pages_contiguous(struct page **pages, size_t nr_pages)
+{
+	size_t i;
+
+	for (i = 1; i < nr_pages; i++)
+		if (pages[i] != nth_page(pages[0], i))
+			break;
+
+	return i;
+}
+
 /*
  * Attempt to pin pages.  We really don't want to track all the pfns and
  * the iommu can only map chunks of consecutive pfns anyway, so get the
diff --git a/include/linux/mm.h b/include/linux/mm.h
index fae82df6d7d7..0ef2ba0c667a 100644
--- a/include/linux/mm.h
+++ b/include/linux/mm.h
@@ -1761,29 +1761,6 @@ static inline unsigned long page_to_section(const struct page *page)
 }
 #endif
 
-/*
- * num_pages_contiguous() - determine the number of contiguous pages
- * starting from the first page.
- *
- * Pages are contiguous if they represent contiguous PFNs. Depending on
- * the memory model, this can mean that the addresses of the "struct page"s
- * are not contiguous.
- *
- * @pages: an array of page pointers
- * @nr_pages: length of the array
- */
-static inline unsigned long num_pages_contiguous(struct page **pages,
-						 size_t nr_pages)
-{
-	size_t i;
-
-	for (i = 1; i < nr_pages; i++)
-		if (pages[i] != nth_page(pages[0], i))
-			break;
-
-	return i;
-}
-
 /**
  * folio_pfn - Return the Page Frame Number of a folio.
  * @folio: The folio.
-- 
2.50.1


^ permalink raw reply related	[flat|nested] 11+ messages in thread

end of thread, other threads:[~2025-08-08  3:11 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-08-05  1:24 [PATCH] vfio/type1: Absorb num_pages_contiguous() Alex Williamson
2025-08-05 13:27 ` David Hildenbrand
2025-08-05 13:56   ` Alex Williamson
2025-08-05 18:15     ` Alex Williamson
2025-08-05 22:10       ` Alex Williamson
2025-08-06 12:35 ` David Hildenbrand
2025-08-06 13:16   ` Jason Gunthorpe
2025-08-06 13:23     ` David Hildenbrand
2025-08-07  4:14   ` lizhe.67
2025-08-07 19:54     ` Alex Williamson
2025-08-08  3:11       ` lizhe.67

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).