diff options
author | Paolo Abeni <pabeni@redhat.com> | 2024-03-05 13:30:15 +0100 |
---|---|---|
committer | Paolo Abeni <pabeni@redhat.com> | 2024-03-05 13:30:16 +0100 |
commit | d35c9659e56edd9e629b54da8ceca062517d3d6c (patch) | |
tree | de9c27dd1b0accf927ed319cde55e2c130fe0060 /net/core/gro.c | |
parent | 9452c8b459f4641156a09c2212a835a6df2a137e (diff) | |
parent | 8f78010b701d8fdc290063f29fefc09aaaca4085 (diff) |
Merge branch 'net-gro-cleanups-and-fast-path-refinement'
Eric Dumazet says:
====================
net: gro: cleanups and fast path refinement
Current GRO stack has a 'fast path' for a subset of drivers,
users of napi_frags_skb().
With TCP zerocopy/direct uses, header split at receive is becoming
more important, and GRO fast path is disabled.
This series makes GRO (a bit) more efficient for almost all use cases.
====================
Link: https://lore.kernel.org/r/20240301193740.3436871-1-edumazet@google.com
Signed-off-by: Paolo Abeni <pabeni@redhat.com>
Diffstat (limited to 'net/core/gro.c')
-rw-r--r-- | net/core/gro.c | 25 |
1 files changed, 17 insertions, 8 deletions
diff --git a/net/core/gro.c b/net/core/gro.c index 0759277dc14e..6a0edbd826a1 100644 --- a/net/core/gro.c +++ b/net/core/gro.c @@ -369,15 +369,21 @@ static void gro_list_prepare(const struct list_head *head, static inline void skb_gro_reset_offset(struct sk_buff *skb, u32 nhoff) { - const struct skb_shared_info *pinfo = skb_shinfo(skb); - const skb_frag_t *frag0 = &pinfo->frags[0]; + const struct skb_shared_info *pinfo; + const skb_frag_t *frag0; + unsigned int headlen; NAPI_GRO_CB(skb)->data_offset = 0; - NAPI_GRO_CB(skb)->frag0 = NULL; - NAPI_GRO_CB(skb)->frag0_len = 0; + headlen = skb_headlen(skb); + NAPI_GRO_CB(skb)->frag0 = skb->data; + NAPI_GRO_CB(skb)->frag0_len = headlen; + if (headlen) + return; + + pinfo = skb_shinfo(skb); + frag0 = &pinfo->frags[0]; - if (!skb_headlen(skb) && pinfo->nr_frags && - !PageHighMem(skb_frag_page(frag0)) && + if (pinfo->nr_frags && !PageHighMem(skb_frag_page(frag0)) && (!NET_IP_ALIGN || !((skb_frag_off(frag0) + nhoff) & 3))) { NAPI_GRO_CB(skb)->frag0 = skb_frag_address(frag0); NAPI_GRO_CB(skb)->frag0_len = min_t(unsigned int, @@ -700,7 +706,7 @@ static struct sk_buff *napi_frags_skb(struct napi_struct *napi) skb_reset_mac_header(skb); skb_gro_reset_offset(skb, hlen); - if (unlikely(skb_gro_header_hard(skb, hlen))) { + if (unlikely(!skb_gro_may_pull(skb, hlen))) { eth = skb_gro_header_slow(skb, hlen, 0); if (unlikely(!eth)) { net_warn_ratelimited("%s: dropping impossible skb from %s\n", @@ -710,7 +716,10 @@ static struct sk_buff *napi_frags_skb(struct napi_struct *napi) } } else { eth = (const struct ethhdr *)skb->data; - gro_pull_from_frag0(skb, hlen); + + if (NAPI_GRO_CB(skb)->frag0 != skb->data) + gro_pull_from_frag0(skb, hlen); + NAPI_GRO_CB(skb)->frag0 += hlen; NAPI_GRO_CB(skb)->frag0_len -= hlen; } |