Commit 8dc1c444 authored by Eric Dumazet's avatar Eric Dumazet Committed by Jakub Kicinski

net: gro: do not keep too many GRO packets in napi->rx_list

Commit c8079432 ("net: Fix packet reordering caused by GRO and
listified RX cooperation") had the unfortunate effect of adding
latencies in common workloads.

Before the patch, GRO packets were immediately passed to
upper stacks.

After the patch, we can accumulate quite a lot of GRO
packets (depdending on NAPI budget).

My fix is counting in napi->rx_count number of segments
instead of number of logical packets.

Fixes: c8079432 ("net: Fix packet reordering caused by GRO and listified RX cooperation")
Signed-off-by: default avatarEric Dumazet <edumazet@google.com>
Bisected-by: default avatarJohn Sperbeck <jsperbeck@google.com>
Tested-by: default avatarJian Yang <jianyang@google.com>
Cc: Maxim Mikityanskiy <maximmi@mellanox.com>
Reviewed-by: default avatarSaeed Mahameed <saeedm@nvidia.com>
Reviewed-by: default avatarEdward Cree <ecree.xilinx@gmail.com>
Reviewed-by: default avatarAlexander Lobakin <alobakin@pm.me>
Link: https://lore.kernel.org/r/20210204213146.4192368-1-eric.dumazet@gmail.comSigned-off-by: default avatarJakub Kicinski <kuba@kernel.org>
parent b3d2c7b8
...@@ -5735,10 +5735,11 @@ static void gro_normal_list(struct napi_struct *napi) ...@@ -5735,10 +5735,11 @@ static void gro_normal_list(struct napi_struct *napi)
/* Queue one GRO_NORMAL SKB up for list processing. If batch size exceeded, /* Queue one GRO_NORMAL SKB up for list processing. If batch size exceeded,
* pass the whole batch up to the stack. * pass the whole batch up to the stack.
*/ */
static void gro_normal_one(struct napi_struct *napi, struct sk_buff *skb) static void gro_normal_one(struct napi_struct *napi, struct sk_buff *skb, int segs)
{ {
list_add_tail(&skb->list, &napi->rx_list); list_add_tail(&skb->list, &napi->rx_list);
if (++napi->rx_count >= gro_normal_batch) napi->rx_count += segs;
if (napi->rx_count >= gro_normal_batch)
gro_normal_list(napi); gro_normal_list(napi);
} }
...@@ -5777,7 +5778,7 @@ static int napi_gro_complete(struct napi_struct *napi, struct sk_buff *skb) ...@@ -5777,7 +5778,7 @@ static int napi_gro_complete(struct napi_struct *napi, struct sk_buff *skb)
} }
out: out:
gro_normal_one(napi, skb); gro_normal_one(napi, skb, NAPI_GRO_CB(skb)->count);
return NET_RX_SUCCESS; return NET_RX_SUCCESS;
} }
...@@ -6067,7 +6068,7 @@ static gro_result_t napi_skb_finish(struct napi_struct *napi, ...@@ -6067,7 +6068,7 @@ static gro_result_t napi_skb_finish(struct napi_struct *napi,
{ {
switch (ret) { switch (ret) {
case GRO_NORMAL: case GRO_NORMAL:
gro_normal_one(napi, skb); gro_normal_one(napi, skb, 1);
break; break;
case GRO_DROP: case GRO_DROP:
...@@ -6155,7 +6156,7 @@ static gro_result_t napi_frags_finish(struct napi_struct *napi, ...@@ -6155,7 +6156,7 @@ static gro_result_t napi_frags_finish(struct napi_struct *napi,
__skb_push(skb, ETH_HLEN); __skb_push(skb, ETH_HLEN);
skb->protocol = eth_type_trans(skb, skb->dev); skb->protocol = eth_type_trans(skb, skb->dev);
if (ret == GRO_NORMAL) if (ret == GRO_NORMAL)
gro_normal_one(napi, skb); gro_normal_one(napi, skb, 1);
break; break;
case GRO_DROP: case GRO_DROP:
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment