lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <d5d8db9b-580e-4ede-8949-c8accc725e78@gmail.com>
Date: Tue, 15 Jul 2025 11:01:22 +0100
From: Pavel Begunkov <asml.silence@...il.com>
To: Mina Almasry <almasrymina@...gle.com>
Cc: Byungchul Park <byungchul@...com>, 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,
 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, hannes@...xchg.org, ziy@...dia.com,
 jackmanb@...gle.com
Subject: Re: [PATCH net-next v9 1/8] netmem: introduce struct netmem_desc
 mirroring struct page

On 7/14/25 20:17, Mina Almasry wrote:
> On Mon, Jul 14, 2025 at 4:28 AM Pavel Begunkov <asml.silence@...il.com> wrote:
...>> diff --git a/include/net/netmem.h b/include/net/netmem.h
>> index 535cf17b9134..41f3a3fd6b6c 100644
>> --- a/include/net/netmem.h
>> +++ b/include/net/netmem.h
>> @@ -247,6 +247,8 @@ static inline unsigned long netmem_pfn_trace(netmem_ref netmem)
>>          return page_to_pfn(netmem_to_page(netmem));
>>    }
>>
>> +#define pp_page_to_nmdesc(page)        ((struct netmem_desc *)(page))
>> +
>>    /* __netmem_clear_lsb - convert netmem_ref to struct net_iov * for access to
>>     * common fields.
>>     * @netmem: netmem reference to extract as net_iov.
>> @@ -262,11 +264,18 @@ static inline unsigned long netmem_pfn_trace(netmem_ref netmem)
>>     *
>>     * Return: the netmem_ref cast to net_iov* regardless of its underlying type.
>>     */
>> -static inline struct net_iov *__netmem_clear_lsb(netmem_ref netmem)
>> +static inline struct net_iov *__netmem_to_niov(netmem_ref netmem)
>>    {
>>          return (struct net_iov *)((__force unsigned long)netmem & ~NET_IOV);
>>    }
>>
>> +static inline struct netmem_desc *netmem_to_nmdesc(netmem_ref netmem)
>> +{
>> +       if (netmem_is_net_iov(netmem))
>> +               return &__netmem_to_niov(netmem)->desc;
>> +       return pp_page_to_nmdesc(__netmem_to_page(netmem));
>> +}
>> +
> 
> I think instead of netmem_to_nmdesc, you want __netmem_clear_lsb to
> return a netmem_desc instead of net_iov.

Same thing, the diff just renames __netmem_clear_lsb -> netmem_to_nmdesc
on top.

> __netmem_clear_lsb returning a net_iov was always a bit of a hack. The
> return value of __netmem_clear_lsb is clearly not a net_iov, but we
> needed to access the pp fields, and net_iov encapsulates the pp
> fields.

Right, and netmem_desc nicely solves that. I remember suggesting such
a common type during review to the initial netmem / niov patches as well.

-- 
Pavel Begunkov


Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ