From: Pavel Begunkov <asml.silence@gmail.com>
To: Mina Almasry <almasrymina@google.com>, Byungchul Park <byungchul@sk.com>
Cc: netdev@vger.kernel.org, linux-kernel@vger.kernel.org,
davem@davemloft.net, edumazet@google.com, kuba@kernel.org,
pabeni@redhat.com, horms@kernel.org, hawk@kernel.org,
toke@redhat.com
Subject: Re: [RFC net-next] netmem: replace __netmem_clear_lsb() with netmem_to_nmdesc()
Date: Mon, 28 Jul 2025 19:46:52 +0100 [thread overview]
Message-ID: <b239b40b-0abe-43a5-af41-346283a634f6@gmail.com> (raw)
In-Reply-To: <CAHS8izPv8zmPaxzCSPAnybiCc0KrqjEZA+x5wpFOE8u=_nM1WA@mail.gmail.com>
On 7/28/25 18:44, Mina Almasry wrote:
> On Sun, Jul 27, 2025 at 9:21 PM Byungchul Park <byungchul@sk.com> wrote:
>>
...>> - * Return: the netmem_ref cast to net_iov* regardless of its underlying type.
>> + * Return: the pointer to struct netmem_desc * regardless of its
>> + * underlying type.
>> */
>> -static inline struct net_iov *__netmem_clear_lsb(netmem_ref netmem)
>> +static inline struct netmem_desc *netmem_to_nmdesc(netmem_ref netmem)
>> {
>> - return (struct net_iov *)((__force unsigned long)netmem & ~NET_IOV);
>> + if (netmem_is_net_iov(netmem))
>> + return &((struct net_iov *)((__force unsigned long)netmem &
>> + ~NET_IOV))->desc;
>> +
>> + return __netmem_to_nmdesc(netmem);
>
> The if statement generates overhead. I'd rather avoid it. We can
> implement netmem_to_nmdesc like this, no?
>
> netmem_to_nmdesc(netmem_ref netmem)
> {
> return (struct netmem_desc)((__force unsigned long)netmem & ~NET_IOV);
> }
>
> Because netmem_desc is the first element in both net_iov and page for
> the moment. (yes I know that will change eventually, but we don't have
> to incur overhead of an extra if statement until netmem_desc is
> removed from page, right?)
Same concern, but I think the goal here should be to make enough
info to the compiler to optimise it out without assumptions on
the layouts nor NET_IOV_ASSERT_OFFSET. Currently it's not so bad,
but we should be able to remove this test+cmove.
movq %rdi, %rax # netmem, tmp105
andq $-2, %rax #, tmp105
testb $1, %dil #, netmem
cmove %rdi, %rax # tmp105,, netmem, <retval>
jmp __x86_return_thunk
--
Pavel Begunkov
next prev parent reply other threads:[~2025-07-28 18:45 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-07-28 4:20 [RFC net-next] netmem: replace __netmem_clear_lsb() with netmem_to_nmdesc() Byungchul Park
2025-07-28 5:35 ` Byungchul Park
2025-07-28 17:44 ` Mina Almasry
2025-07-28 18:46 ` Pavel Begunkov [this message]
2025-07-28 18:58 ` Pavel Begunkov
2025-07-29 1:17 ` Byungchul Park
2025-07-29 9:11 ` Pavel Begunkov
2025-07-29 1:10 ` Byungchul Park
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=b239b40b-0abe-43a5-af41-346283a634f6@gmail.com \
--to=asml.silence@gmail.com \
--cc=almasrymina@google.com \
--cc=byungchul@sk.com \
--cc=davem@davemloft.net \
--cc=edumazet@google.com \
--cc=hawk@kernel.org \
--cc=horms@kernel.org \
--cc=kuba@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=netdev@vger.kernel.org \
--cc=pabeni@redhat.com \
--cc=toke@redhat.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).