[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <CAHS8izMRDixoLC5p1+h4oxrfVvErXcokR6qC_zuOqBredBBMbA@mail.gmail.com>
Date: Fri, 23 May 2025 10:14:54 -0700
From: Mina Almasry <almasrymina@...gle.com>
To: Byungchul Park <byungchul@...com>
Cc: willy@...radead.org, netdev@...r.kernel.org, linux-kernel@...r.kernel.org,
linux-mm@...ck.org, kernel_team@...ynix.com, kuba@...nel.org,
ilias.apalodimas@...aro.org, harry.yoo@...cle.com, hawk@...nel.org,
akpm@...ux-foundation.org, davem@...emloft.net, john.fastabend@...il.com,
andrew+netdev@...n.ch, asml.silence@...il.com, toke@...hat.com,
tariqt@...dia.com, edumazet@...gle.com, pabeni@...hat.com, saeedm@...dia.com,
leon@...nel.org, ast@...nel.org, daniel@...earbox.net, david@...hat.com,
lorenzo.stoakes@...cle.com, Liam.Howlett@...cle.com, vbabka@...e.cz,
rppt@...nel.org, surenb@...gle.com, mhocko@...e.com, horms@...nel.org,
linux-rdma@...r.kernel.org, bpf@...r.kernel.org, vishal.moola@...il.com
Subject: Re: [PATCH 14/18] netmem: use _Generic to cover const casting for page_to_netmem()
On Thu, May 22, 2025 at 8:26 PM Byungchul Park <byungchul@...com> wrote:
>
> The current page_to_netmem() doesn't cover const casting resulting in
> trying to cast const struct page * to const netmem_ref fails.
>
> To cover the case, change page_to_netmem() to use macro and _Generic.
>
> Signed-off-by: Byungchul Park <byungchul@...com>
Reviewed-by: Mina Almasry <almasrymina@...gle.com>
> ---
> include/net/netmem.h | 7 +++----
> 1 file changed, 3 insertions(+), 4 deletions(-)
>
> diff --git a/include/net/netmem.h b/include/net/netmem.h
> index 29c005d70c4f..c2eb121181c2 100644
> --- a/include/net/netmem.h
> +++ b/include/net/netmem.h
> @@ -172,10 +172,9 @@ 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)
> -{
> - return (__force netmem_ref)page;
> -}
> +#define page_to_netmem(p) (_Generic((p), \
> + const struct page *: (__force const netmem_ref)(p), \
> + struct page *: (__force netmem_ref)(p)))
>
> static inline netmem_ref alloc_netmems_node(int nid, gfp_t gfp_mask,
> unsigned int order)
> --
> 2.17.1
>
--
Thanks,
Mina
Powered by blists - more mailing lists