[PATCH] io_uring/zcrx: use folio_nr_pages() instead of shift operation

Pedro Demarchi Gomes posted 1 patch 2 months, 2 weeks ago
io_uring/zcrx.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
[PATCH] io_uring/zcrx: use folio_nr_pages() instead of shift operation
Posted by Pedro Demarchi Gomes 2 months, 2 weeks ago
folio_nr_pages() is a faster helper function to get the number of pages when
NR_PAGES_IN_LARGE_FOLIO is enabled.

Signed-off-by: Pedro Demarchi Gomes <pedrodemargomes@gmail.com>
---
 io_uring/zcrx.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/io_uring/zcrx.c b/io_uring/zcrx.c
index e5ff49f3425e..97fda3d65919 100644
--- a/io_uring/zcrx.c
+++ b/io_uring/zcrx.c
@@ -172,7 +172,7 @@ static unsigned long io_count_account_pages(struct page **pages, unsigned nr_pag
 		if (folio == last_folio)
 			continue;
 		last_folio = folio;
-		res += 1UL << folio_order(folio);
+		res += folio_nr_pages(folio);
 	}
 	return res;
 }
-- 
2.39.5
Re: [PATCH] io_uring/zcrx: use folio_nr_pages() instead of shift operation
Posted by Pavel Begunkov 2 months, 1 week ago
On 10/4/25 04:07, Pedro Demarchi Gomes wrote:
> folio_nr_pages() is a faster helper function to get the number of pages when
> NR_PAGES_IN_LARGE_FOLIO is enabled.

Looks straightforward, I'll take it into a branch.

> Signed-off-by: Pedro Demarchi Gomes <pedrodemargomes@gmail.com>
> ---
>   io_uring/zcrx.c | 2 +-
>   1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/io_uring/zcrx.c b/io_uring/zcrx.c
> index e5ff49f3425e..97fda3d65919 100644
> --- a/io_uring/zcrx.c
> +++ b/io_uring/zcrx.c
> @@ -172,7 +172,7 @@ static unsigned long io_count_account_pages(struct page **pages, unsigned nr_pag
>   		if (folio == last_folio)
>   			continue;
>   		last_folio = folio;
> -		res += 1UL << folio_order(folio);
> +		res += folio_nr_pages(folio);
>   	}
>   	return res;
>   }

-- 
Pavel Begunkov