netdev.vger.kernel.org archive mirror
 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: Thu, 29 Feb 2024 14:22:16 +0100	[thread overview]
Message-ID: <a10b6d19-232c-4b6d-bd71-eb3451675f64@gmail.com> (raw)
In-Reply-To: <CANn89iJxCT0Bcmqjdd1kp4VCf5i3Me7yATsZXO7SkYTPQ9BOAA@mail.gmail.com>



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);
    }
 
And for the conditionals in {inet,ipv6}_gro_receive I thought about two
ideas. The first is to move set_inner_network_header to encapsulation gro
functions like ipip_gro_receive, this way there's one less write (in
comparison to main) in these functions:

    static struct sk_buff *ipip_gro_receive(struct list_head *head,
                        struct sk_buff *skb)
    {
        ...
 
        NAPI_GRO_CB(skb)->encap_mark = 1;
        skb_set_inner_network_header(skb, skb_gro_offset(skb));
 
The second way is to always write to inner_network_header:

    INDIRECT_CALLABLE_SCOPE struct sk_buff *ipv6_gro_receive(struct list_head *head,
                                struct sk_buff *skb)
    {
        ...
        skb_set_inner_network_header(skb, off);
        ...
 
What do you think is better? I think the 1st is more beneficial for the
fast path.

We could then use the {inner_}network_header separation to optimise the
receive path, such as in the 3rd commit in this patch series.
 
Regards,
Richard

  reply	other threads:[~2024-02-29 13:22 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 [this message]
2024-02-29 20:15       ` Eric Dumazet
2024-03-01 15:02         ` Richard Gobert
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=a10b6d19-232c-4b6d-bd71-eb3451675f64@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;
as well as URLs for NNTP newsgroup(s).