diff mbox series

[3/5] mm/gup_test.c: Convert verify_dma_pinned() to us folios

Message ID 20230613201827.9441-4-vishal.moola@gmail.com (mailing list archive)
State New
Headers show
Series Replace is_longterm_pinnable_page() | expand

Commit Message

Vishal Moola June 13, 2023, 8:18 p.m. UTC
verify_dma_pinned() checks that pages are dma-pinned. We can convert
this to use folios.

Signed-off-by: Vishal Moola (Oracle) <vishal.moola@gmail.com>
---
 mm/gup_test.c | 13 +++++++------
 1 file changed, 7 insertions(+), 6 deletions(-)

Comments

Matthew Wilcox June 13, 2023, 8:54 p.m. UTC | #1
On Tue, Jun 13, 2023 at 01:18:25PM -0700, Vishal Moola (Oracle) wrote:
> verify_dma_pinned() checks that pages are dma-pinned. We can convert
> this to use folios.
> 
> Signed-off-by: Vishal Moola (Oracle) <vishal.moola@gmail.com>

Reviewed-by: Matthew Wilcox (Oracle) <willy@infradead.org>
Lorenzo Stoakes June 17, 2023, 7:29 p.m. UTC | #2
On Tue, 13 Jun 2023 at 21:18, Vishal Moola (Oracle)
<vishal.moola@gmail.com> wrote:
>
> verify_dma_pinned() checks that pages are dma-pinned. We can convert
> this to use folios.
>
> Signed-off-by: Vishal Moola (Oracle) <vishal.moola@gmail.com>
> ---
>  mm/gup_test.c | 13 +++++++------
>  1 file changed, 7 insertions(+), 6 deletions(-)
>
> diff --git a/mm/gup_test.c b/mm/gup_test.c
> index 8ae7307a1bb6..860b093b4b3e 100644
> --- a/mm/gup_test.c
> +++ b/mm/gup_test.c
> @@ -40,24 +40,25 @@ static void verify_dma_pinned(unsigned int cmd, struct page **pages,
>                               unsigned long nr_pages)
>  {
>         unsigned long i;
> -       struct page *page;
> +       struct folio *folio;
>
>         switch (cmd) {
>         case PIN_FAST_BENCHMARK:
>         case PIN_BASIC_TEST:
>         case PIN_LONGTERM_BENCHMARK:
>                 for (i = 0; i < nr_pages; i++) {
> -                       page = pages[i];
> -                       if (WARN(!page_maybe_dma_pinned(page),
> +                       folio = page_folio(pages[i]);
> +
> +                       if (WARN(!folio_maybe_dma_pinned(folio),
>                                  "pages[%lu] is NOT dma-pinned\n", i)) {
>
> -                               dump_page(page, "gup_test failure");
> +                               dump_page(&folio->page, "gup_test failure");
>                                 break;
>                         } else if (cmd == PIN_LONGTERM_BENCHMARK &&
> -                               WARN(!is_longterm_pinnable_page(page),
> +                               WARN(!folio_is_longterm_pinnable(folio),
>                                      "pages[%lu] is NOT pinnable but pinned\n",
>                                      i)) {
> -                               dump_page(page, "gup_test failure");
> +                               dump_page(&folio->page, "gup_test failure");
>                                 break;
>                         }
>                 }
> --
> 2.40.1
>
>

(Hope you don't mind me taking a look, GUP is of interest to me :)

Reviewed-by: Lorenzo Stoakes <lstoakes@gmail.com>
diff mbox series

Patch

diff --git a/mm/gup_test.c b/mm/gup_test.c
index 8ae7307a1bb6..860b093b4b3e 100644
--- a/mm/gup_test.c
+++ b/mm/gup_test.c
@@ -40,24 +40,25 @@  static void verify_dma_pinned(unsigned int cmd, struct page **pages,
 			      unsigned long nr_pages)
 {
 	unsigned long i;
-	struct page *page;
+	struct folio *folio;
 
 	switch (cmd) {
 	case PIN_FAST_BENCHMARK:
 	case PIN_BASIC_TEST:
 	case PIN_LONGTERM_BENCHMARK:
 		for (i = 0; i < nr_pages; i++) {
-			page = pages[i];
-			if (WARN(!page_maybe_dma_pinned(page),
+			folio = page_folio(pages[i]);
+
+			if (WARN(!folio_maybe_dma_pinned(folio),
 				 "pages[%lu] is NOT dma-pinned\n", i)) {
 
-				dump_page(page, "gup_test failure");
+				dump_page(&folio->page, "gup_test failure");
 				break;
 			} else if (cmd == PIN_LONGTERM_BENCHMARK &&
-				WARN(!is_longterm_pinnable_page(page),
+				WARN(!folio_is_longterm_pinnable(folio),
 				     "pages[%lu] is NOT pinnable but pinned\n",
 				     i)) {
-				dump_page(page, "gup_test failure");
+				dump_page(&folio->page, "gup_test failure");
 				break;
 			}
 		}