[PATCH net-next v4 01/11] net: Allow const args for of page_to_netmem()

Mark Bloch posted 11 patches 4 months ago
There is a newer version of this series
[PATCH net-next v4 01/11] net: Allow const args for of page_to_netmem()
Posted by Mark Bloch 4 months ago
From: Dragos Tatulea <dtatulea@nvidia.com>

This allows calling page_to_netmem() with a const page * argument.

Signed-off-by: Dragos Tatulea <dtatulea@nvidia.com>
Reviewed-by: Cosmin Ratiu <cratiu@nvidia.com>
Signed-off-by: Mark Bloch <mbloch@nvidia.com>
---
 include/net/netmem.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/include/net/netmem.h b/include/net/netmem.h
index 386164fb9c18..caf2e773c915 100644
--- a/include/net/netmem.h
+++ b/include/net/netmem.h
@@ -143,7 +143,7 @@ static inline netmem_ref net_iov_to_netmem(struct net_iov *niov)
 	return (__force netmem_ref)((unsigned long)niov | NET_IOV);
 }
 
-static inline netmem_ref page_to_netmem(struct page *page)
+static inline netmem_ref page_to_netmem(const struct page *page)
 {
 	return (__force netmem_ref)page;
 }
-- 
2.34.1
Re: [PATCH net-next v4 01/11] net: Allow const args for of page_to_netmem()
Posted by Mina Almasry 4 months ago
On Tue, Jun 10, 2025 at 8:15 AM Mark Bloch <mbloch@nvidia.com> wrote:
>
> From: Dragos Tatulea <dtatulea@nvidia.com>
>
> This allows calling page_to_netmem() with a const page * argument.
>
> Signed-off-by: Dragos Tatulea <dtatulea@nvidia.com>
> Reviewed-by: Cosmin Ratiu <cratiu@nvidia.com>
> Signed-off-by: Mark Bloch <mbloch@nvidia.com>

This is slightly better, it returns a const netmem_ref if const struct page:

https://lore.kernel.org/netdev/20250609043225.77229-6-byungchul@sk.com/

It's probably too much of a hassle to block your series until
Byungchul's change to this helper goes in for you, so this seems fine
to me in the interim.

Reviewed-by: Mina Almasry <almasrymina@google.com>

-- 
Thanks,
Mina
Re: [PATCH net-next v4 01/11] net: Allow const args for of page_to_netmem()y
Posted by Dragos Tatulea 4 months ago
On Wed, Jun 11, 2025 at 09:52:47PM -0700, Mina Almasry wrote:
> On Tue, Jun 10, 2025 at 8:15 AM Mark Bloch <mbloch@nvidia.com> wrote:
> >
> > From: Dragos Tatulea <dtatulea@nvidia.com>
> >
> > This allows calling page_to_netmem() with a const page * argument.
> >
> > Signed-off-by: Dragos Tatulea <dtatulea@nvidia.com>
> > Reviewed-by: Cosmin Ratiu <cratiu@nvidia.com>
> > Signed-off-by: Mark Bloch <mbloch@nvidia.com>
> 
> This is slightly better, it returns a const netmem_ref if const struct page:
> 
> https://lore.kernel.org/netdev/20250609043225.77229-6-byungchul@sk.com/
> 
Agree. Saw it too late though...

> It's probably too much of a hassle to block your series until
> Byungchul's change to this helper goes in for you, so this seems fine
> to me in the interim.
> 
> Reviewed-by: Mina Almasry <almasrymina@google.com>
> 
Thanks for the review!

Dragos