public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Richard Gobert <richardbgobert@gmail.com>
To: Eric Dumazet <edumazet@google.com>
Cc: davem@davemloft.net, kuba@kernel.org, pabeni@redhat.com,
	dsahern@kernel.org, shuah@kernel.org, liujian56@huawei.com,
	horms@kernel.org, aleksander.lobakin@intel.com,
	linyunsheng@huawei.com, therbert@google.com,
	netdev@vger.kernel.org, linux-kernel@vger.kernel.org,
	linux-kselftest@vger.kernel.org
Subject: Re: [PATCH net-next 1/3] net: gro: set {inner_,}network_header in receive phase
Date: Fri, 1 Mar 2024 16:02:26 +0100	[thread overview]
Message-ID: <e803766b-6a3d-4eab-8335-d415518392e0@gmail.com> (raw)
In-Reply-To: <CANn89iK8rDOc14HMGMq=sw0zECcg88Mb=67044r_OA=mSh=xtQ@mail.gmail.com>



Eric Dumazet wrote:
> On Thu, Feb 29, 2024 at 2:22 PM Richard Gobert <richardbgobert@gmail.com> wrote:
>>
>>
>>
>> Eric Dumazet wrote:
>>>
>>> My intuition is that this patch has a high cost for normal GRO processing.
>>> SW-GRO is already a bottleneck on ARM cores in smart NICS.
>>>
>>> I would suggest instead using parameters to give both the nhoff and thoff values
>>> this would avoid many conditionals in the fast path.
>>>
>>> ->
>>>
>>> INDIRECT_CALLABLE_SCOPE int udp6_gro_complete(struct sk_buff *skb, int
>>> nhoff, int thoff)
>>> {
>>>  const struct ipv6hdr *ipv6h = (const struct ipv6hdr *)(skb->data + nhoff);
>>>  struct udphdr *uh = (struct udphdr *)(skb->data + thoff);
>>> ...
>>> }
>>>
>>> INDIRECT_CALLABLE_SCOPE int tcp6_gro_complete(struct sk_buff *skb, int
>>> nhoff, int thoff)
>>> {
>>>        const struct ipv6hdr *iph =  (const struct ipv6hdr *)(skb->data + nhoff);
>>>        struct tcphdr *th = (struct tcphdr *)(skb->data + thoff);
>>>
>>> Why storing in skb fields things that really could be propagated more
>>> efficiently as function parameters ?
>>
>> Hi Eric,
>> Thanks for the review!
>>
>> I agree, the conditionals could be a problem and are actually not needed.
>> The third commit in this patch series introduces an optimisation for
>> ipv6/ipv4 using the correct {inner_}network_header. We can remove the
>> conditionals; I thought about multiple ways to do so. First, remove the
>> conditional in skb_gro_network_offset:
>>
>>     static inline int skb_gro_network_offset(const struct sk_buff *skb)
>>     {
>>         const u32 mask = NAPI_GRO_CB(skb)->encap_mark - 1;
>>         return (skb_network_offset(skb) & mask) | (skb_inner_network_offset(skb) & ~mask);
>>     }
> 
> I was trying to say that we do not need all these helpers, storing
> state in NAPI_GRO_CB(skb),
> dirtying cache lines...
> 
> Ideally, the skb network/transport/... headers could be set at the
> last stage, in gro_complete(big_gro_skb),
> instead of doing this for each segment.
> 
> All the gro_receive() could be much faster by using additional
> parameters (nhoff, thoff)
> 
> skb_gro_offset() could be replaced by the current offset (nhoff or
> other name), passed as a parameter.
> 
> Here is a WIP for gro_complete() step, this looks large but this is
> only adding a 2nd 'offset' parameter
> 
> Prior offset (typically network offset), called p_off
> Old argument nhoff, (renamed thoff if that makes sense), pointing to
> the current offset.
> 

You're right, it seemed to me like a broad change but it is mainly
cosmetic. I'll finish your version and submit it to fix the bug.

I still believe that setting inner_network_header is a valuable change.
For example, although skb_gro_network_offset is used - setting it in
encapsulation protocol functions (such as ipip_gro_receive) allow us to
remove conditionals from {ipv6,inet}_gro_receive gro_list loop and remove
flush_id from napi_gro_cb as written in the 3rd commit.
What are your thoughts about it as a separate patch?

  reply	other threads:[~2024-03-01 15:02 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-02-22 21:00 [PATCH net-next 0/3] net: gro: encapsulation bug fix and flush checks improvements Richard Gobert
2024-02-22 21:05 ` [PATCH net-next 1/3] net: gro: set {inner_,}network_header in receive phase Richard Gobert
2024-02-22 21:25   ` Eric Dumazet
2024-02-29 13:22     ` Richard Gobert
2024-02-29 20:15       ` Eric Dumazet
2024-03-01 15:02         ` Richard Gobert [this message]
2024-02-22 21:07 ` [PATCH net-next 2/3] selftests/net: add local address bind in vxlan selftest Richard Gobert
2024-02-22 21:12 ` [PATCH net-next 3/3] net: gro: move L3 flush checks to tcp_gro_receive Richard Gobert

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=e803766b-6a3d-4eab-8335-d415518392e0@gmail.com \
    --to=richardbgobert@gmail.com \
    --cc=aleksander.lobakin@intel.com \
    --cc=davem@davemloft.net \
    --cc=dsahern@kernel.org \
    --cc=edumazet@google.com \
    --cc=horms@kernel.org \
    --cc=kuba@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-kselftest@vger.kernel.org \
    --cc=linyunsheng@huawei.com \
    --cc=liujian56@huawei.com \
    --cc=netdev@vger.kernel.org \
    --cc=pabeni@redhat.com \
    --cc=shuah@kernel.org \
    --cc=therbert@google.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