From: Paolo Abeni <pabeni@redhat.com>
To: Eric Dumazet <edumazet@google.com>
Cc: netdev@vger.kernel.org, "David S. Miller" <davem@davemloft.net>,
Jakub Kicinski <kuba@kernel.org>, Simon Horman <horms@kernel.org>,
Neal Cardwell <ncardwell@google.com>,
Kuniyuki Iwashima <kuniyu@google.com>,
David Ahern <dsahern@kernel.org>
Subject: Re: [RFC PATCH 1/2] net: gro: avoid relaying on skb->transport_header at receive time
Date: Fri, 5 Dec 2025 16:22:55 +0100 [thread overview]
Message-ID: <bb866d37-6e89-460f-a411-e9f26b0fa4e4@redhat.com> (raw)
In-Reply-To: <CANn89iL3hp4Of_U+Yc34OrwVnTwn5j4j=WTq-yckGVcpptxcUg@mail.gmail.com>
On 12/5/25 3:37 PM, Eric Dumazet wrote:
> On Fri, Dec 5, 2025 at 6:04 AM Paolo Abeni <pabeni@redhat.com> wrote:
>>
>> Currently {tcp,udp}_gro_receive relay on the gro network stage setting
>
> rely :)
>
>> the correct transport header offset for all the skbs held by the GRO
>> engine.
>>
>> Such assumption is not necessary, as the code can instead leverage the
>> offset already available for the currently processed skb. Add a couple
>> of helpers to for readabilty' sake.
>>
>> As skb->transport_header lays on a different cacheline wrt skb->data,
>> this should save a cacheline access for each packet aggregation.
>> Additionally this will make the next patch possible.
>>
>> Note that the compiler (gcc 15.2.1) does inline the tcp_gro_lookup()
>> call in tcp_gro_receive(), so the additional argument is only relevant
>> for the fraglist case.
>>
>> Signed-off-by: Paolo Abeni <pabeni@redhat.com>
>> ---
>> include/net/gro.h | 26 ++++++++++++++++++++++++++
>> include/net/tcp.h | 3 ++-
>> net/ipv4/tcp_offload.c | 15 ++++++++-------
>> net/ipv4/udp_offload.c | 4 ++--
>> net/ipv6/tcpv6_offload.c | 2 +-
>> 5 files changed, 39 insertions(+), 11 deletions(-)
>>
>> diff --git a/include/net/gro.h b/include/net/gro.h
>> index b65f631c521d..fdb9285ab117 100644
>> --- a/include/net/gro.h
>> +++ b/include/net/gro.h
>> @@ -420,6 +420,18 @@ struct sk_buff *udp_gro_receive(struct list_head *head, struct sk_buff *skb,
>> struct udphdr *uh, struct sock *sk);
>> int udp_gro_complete(struct sk_buff *skb, int nhoff, udp_lookup_t lookup);
>>
>> +/* Return the skb hdr corresponding to the specified skb2 hdr.
>> + * skb2 is held in the gro engine, i.e. its headers are in the linear part.
>> + */
>> +static inline const void *
>> +skb_gro_header_from(const struct sk_buff *skb, const struct sk_buff *skb2,
>> + const void *hdr2)
>> +{
>> + size_t offset = (unsigned char *)hdr2 - skb2->data;
>> +
>> + return skb->data + offset;
>> +}
>
> I would rather switch gro to pass an @offset instead of a header pointer ?
>
> Rebuilding one header pointer from offset is fast : skb->data + offset
> ( offset : network header, transport header, ...)
I considered such option and opted for the above for a very small
reason: it produces a little more compact (C) code in the caller.
I'll switch to offset in next revisions.
> As a matter of fact, some GRO state variables could be onstack, instead
> of being stored in NAPI_GRO_CB()
Do you mean the network offsets? In any case, I hope we can keep such
work separate from this one?
> This would avoid some stalls because skb->cb[] has been cleared with
> memset() with long words, while GRO is using smaller fields.Whoops, I never considered store forwarding induced stalls. Something to
ponder about for me.
Many thanks!
Paolo
next prev parent reply other threads:[~2025-12-05 15:23 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-12-05 14:03 [RFC PATCH 0/2] net: gro: avoid touching transport header Paolo Abeni
2025-12-05 14:03 ` [RFC PATCH 1/2] net: gro: avoid relaying on skb->transport_header at receive time Paolo Abeni
2025-12-05 14:37 ` Eric Dumazet
2025-12-05 15:22 ` Paolo Abeni [this message]
2025-12-05 15:36 ` Eric Dumazet
2025-12-06 21:26 ` Willem de Bruijn
2025-12-05 14:03 ` [RFC PATCH 2/2] net: gro: set the transport header later Paolo Abeni
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=bb866d37-6e89-460f-a411-e9f26b0fa4e4@redhat.com \
--to=pabeni@redhat.com \
--cc=davem@davemloft.net \
--cc=dsahern@kernel.org \
--cc=edumazet@google.com \
--cc=horms@kernel.org \
--cc=kuba@kernel.org \
--cc=kuniyu@google.com \
--cc=ncardwell@google.com \
--cc=netdev@vger.kernel.org \
/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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.