netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH net-next] net: gro: remove obsolete code from skb_gro_receive()
@ 2015-03-04 18:26 Eric Dumazet
  2015-03-05 21:00 ` David Miller
  2015-03-05 21:47 ` [PATCH v2 " Eric Dumazet
  0 siblings, 2 replies; 9+ messages in thread
From: Eric Dumazet @ 2015-03-04 18:26 UTC (permalink / raw)
  To: David Miller; +Cc: netdev, Herbert Xu

From: Eric Dumazet <edumazet@google.com>

Some drivers use copybreak to copy tiny frames into smaller skb,
and this smaller skb might not have skb->head_frag set for various
reasons.

skb_gro_receive() currently doesn't allow to aggregate the smaller skb
into the previous GRO packet if this GRO packet has at least 2 MSS in
it.

Following workload easily demonstrates the problem.

netperf -t TCP_RR -H target -- -r 3000,3000 

(tcpdump shows one GRO packet with 2 MSS, plus one additional packet of
104 bytes that should have been appended.)

It turns out that we can remove code from skb_gro_receive(), because
commit 8a29111c7ca6 ("net: gro: allow to build full sized skb") and its
followups removed the assumption that a GRO packet with a frag_list had
to have an empty head.

Removing this code allows the aggregation of the last (incomplete) frame
in some RPC workloads. Note that tcp_gro_receive() already takes care of
forcing a flush if necessary, including this case.

If we want to avoid using frag_list in the first place (in forwarding
workloads for example, as the outgoing NIC is generally not able to cope
with skbs having a frag_list), we need to address this separately.

Signed-off-by: Eric Dumazet <edumazet@google.com>
Cc: Herbert Xu <herbert@gondor.apana.org.au>
---
 net/core/skbuff.c |   42 ------------------------------------------
 1 file changed, 42 deletions(-)

diff --git a/net/core/skbuff.c b/net/core/skbuff.c
index 913b94a77060..a9bee7ef6397 100644
--- a/net/core/skbuff.c
+++ b/net/core/skbuff.c
@@ -3276,48 +3276,6 @@ int skb_gro_receive(struct sk_buff **head, struct sk_buff *skb)
 		NAPI_GRO_CB(skb)->free = NAPI_GRO_FREE_STOLEN_HEAD;
 		goto done;
 	}
-	/* switch back to head shinfo */
-	pinfo = skb_shinfo(p);
-
-	if (pinfo->frag_list)
-		goto merge;
-	if (skb_gro_len(p) != pinfo->gso_size)
-		return -E2BIG;
-
-	headroom = skb_headroom(p);
-	nskb = alloc_skb(headroom + skb_gro_offset(p), GFP_ATOMIC);
-	if (unlikely(!nskb))
-		return -ENOMEM;
-
-	__copy_skb_header(nskb, p);
-	nskb->mac_len = p->mac_len;
-
-	skb_reserve(nskb, headroom);
-	__skb_put(nskb, skb_gro_offset(p));
-
-	skb_set_mac_header(nskb, skb_mac_header(p) - p->data);
-	skb_set_network_header(nskb, skb_network_offset(p));
-	skb_set_transport_header(nskb, skb_transport_offset(p));
-
-	__skb_pull(p, skb_gro_offset(p));
-	memcpy(skb_mac_header(nskb), skb_mac_header(p),
-	       p->data - skb_mac_header(p));
-
-	skb_shinfo(nskb)->frag_list = p;
-	skb_shinfo(nskb)->gso_size = pinfo->gso_size;
-	pinfo->gso_size = 0;
-	__skb_header_release(p);
-	NAPI_GRO_CB(nskb)->last = p;
-
-	nskb->data_len += p->len;
-	nskb->truesize += p->truesize;
-	nskb->len += p->len;
-
-	*head = nskb;
-	nskb->next = p->next;
-	p->next = NULL;
-
-	p = nskb;
 
 merge:
 	delta_truesize = skb->truesize;

^ permalink raw reply related	[flat|nested] 9+ messages in thread

* Re: [PATCH net-next] net: gro: remove obsolete code from skb_gro_receive()
  2015-03-04 18:26 [PATCH net-next] net: gro: remove obsolete code from skb_gro_receive() Eric Dumazet
@ 2015-03-05 21:00 ` David Miller
  2015-03-05 21:04   ` Eric Dumazet
  2015-03-05 21:47 ` [PATCH v2 " Eric Dumazet
  1 sibling, 1 reply; 9+ messages in thread
From: David Miller @ 2015-03-05 21:00 UTC (permalink / raw)
  To: eric.dumazet; +Cc: netdev, herbert

From: Eric Dumazet <eric.dumazet@gmail.com>
Date: Wed, 04 Mar 2015 10:26:40 -0800

> From: Eric Dumazet <edumazet@google.com>
> 
> Some drivers use copybreak to copy tiny frames into smaller skb,
> and this smaller skb might not have skb->head_frag set for various
> reasons.
> 
> skb_gro_receive() currently doesn't allow to aggregate the smaller skb
> into the previous GRO packet if this GRO packet has at least 2 MSS in
> it.
> 
> Following workload easily demonstrates the problem.
> 
> netperf -t TCP_RR -H target -- -r 3000,3000 
> 
> (tcpdump shows one GRO packet with 2 MSS, plus one additional packet of
> 104 bytes that should have been appended.)
> 
> It turns out that we can remove code from skb_gro_receive(), because
> commit 8a29111c7ca6 ("net: gro: allow to build full sized skb") and its
> followups removed the assumption that a GRO packet with a frag_list had
> to have an empty head.
> 
> Removing this code allows the aggregation of the last (incomplete) frame
> in some RPC workloads. Note that tcp_gro_receive() already takes care of
> forcing a flush if necessary, including this case.
> 
> If we want to avoid using frag_list in the first place (in forwarding
> workloads for example, as the outgoing NIC is generally not able to cope
> with skbs having a frag_list), we need to address this separately.
> 
> Signed-off-by: Eric Dumazet <edumazet@google.com>

Please get rid of the local variables that are no made unused by this
change:

net/core/skbuff.c: In function ‘skb_gro_receive’:
net/core/skbuff.c:3212:15: warning: unused variable ‘headroom’ [-Wunused-variable]
net/core/skbuff.c:3209:18: warning: unused variable ‘nskb’ [-Wunused-variable]

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [PATCH net-next] net: gro: remove obsolete code from skb_gro_receive()
  2015-03-05 21:00 ` David Miller
@ 2015-03-05 21:04   ` Eric Dumazet
  0 siblings, 0 replies; 9+ messages in thread
From: Eric Dumazet @ 2015-03-05 21:04 UTC (permalink / raw)
  To: David Miller; +Cc: netdev, herbert

On Thu, 2015-03-05 at 16:00 -0500, David Miller wrote:

> Please get rid of the local variables that are no made unused by this
> change:
> 
> net/core/skbuff.c: In function ‘skb_gro_receive’:
> net/core/skbuff.c:3212:15: warning: unused variable ‘headroom’ [-Wunused-variable]
> net/core/skbuff.c:3209:18: warning: unused variable ‘nskb’ [-Wunused-variable]

Hmpff... I sent the wrong patch it seems. Sorry.

Will fix this after my lunch ;)

^ permalink raw reply	[flat|nested] 9+ messages in thread

* [PATCH v2 net-next] net: gro: remove obsolete code from skb_gro_receive()
  2015-03-04 18:26 [PATCH net-next] net: gro: remove obsolete code from skb_gro_receive() Eric Dumazet
  2015-03-05 21:00 ` David Miller
@ 2015-03-05 21:47 ` Eric Dumazet
  2015-03-06  6:04   ` David Miller
  1 sibling, 1 reply; 9+ messages in thread
From: Eric Dumazet @ 2015-03-05 21:47 UTC (permalink / raw)
  To: David Miller; +Cc: netdev, Herbert Xu

From: Eric Dumazet <edumazet@google.com>

Some drivers use copybreak to copy tiny frames into smaller skb,
and this smaller skb might not have skb->head_frag set for various
reasons.

skb_gro_receive() currently doesn't allow to aggregate the smaller skb
into the previous GRO packet if this GRO packet has at least 2 MSS in
it.

Following workload easily demonstrates the problem.

netperf -t TCP_RR -H target -- -r 3000,3000 

(tcpdump shows one GRO packet with 2 MSS, plus one additional packet of
104 bytes that should have been appended.)

It turns out that we can remove code from skb_gro_receive(), because
commit 8a29111c7ca6 ("net: gro: allow to build full sized skb") and its
followups removed the assumption that a GRO packet with a frag_list had
to have an empty head.

Removing this code allows the aggregation of the last (incomplete) frame
in some RPC workloads. Note that tcp_gro_receive() already takes care of
forcing a flush if necessary, including this case.

If we want to avoid using frag_list in the first place (in forwarding
workloads for example, as the outgoing NIC is generally not able to cope
with skbs having a frag_list), we need to address this separately.

Signed-off-by: Eric Dumazet <edumazet@google.com>
Cc: Herbert Xu <herbert@gondor.apana.org.au>
---
v2: removed headroom & nskb variables, no longer needed.

 net/core/skbuff.c |   45 --------------------------------------------
 1 file changed, 1 insertion(+), 44 deletions(-)
diff --git a/net/core/skbuff.c b/net/core/skbuff.c
index 913b94a77060a04197f6e98df8cb2700d3263136..47c32413d5b94c4911939f98772a8ab1d98c3740 100644
--- a/net/core/skbuff.c
+++ b/net/core/skbuff.c
@@ -3206,10 +3206,9 @@ int skb_gro_receive(struct sk_buff **head, struct sk_buff *skb)
 	struct skb_shared_info *pinfo, *skbinfo = skb_shinfo(skb);
 	unsigned int offset = skb_gro_offset(skb);
 	unsigned int headlen = skb_headlen(skb);
-	struct sk_buff *nskb, *lp, *p = *head;
 	unsigned int len = skb_gro_len(skb);
+	struct sk_buff *lp, *p = *head;
 	unsigned int delta_truesize;
-	unsigned int headroom;
 
 	if (unlikely(p->len + len >= 65536))
 		return -E2BIG;
@@ -3276,48 +3275,6 @@ int skb_gro_receive(struct sk_buff **head, struct sk_buff *skb)
 		NAPI_GRO_CB(skb)->free = NAPI_GRO_FREE_STOLEN_HEAD;
 		goto done;
 	}
-	/* switch back to head shinfo */
-	pinfo = skb_shinfo(p);
-
-	if (pinfo->frag_list)
-		goto merge;
-	if (skb_gro_len(p) != pinfo->gso_size)
-		return -E2BIG;
-
-	headroom = skb_headroom(p);
-	nskb = alloc_skb(headroom + skb_gro_offset(p), GFP_ATOMIC);
-	if (unlikely(!nskb))
-		return -ENOMEM;
-
-	__copy_skb_header(nskb, p);
-	nskb->mac_len = p->mac_len;
-
-	skb_reserve(nskb, headroom);
-	__skb_put(nskb, skb_gro_offset(p));
-
-	skb_set_mac_header(nskb, skb_mac_header(p) - p->data);
-	skb_set_network_header(nskb, skb_network_offset(p));
-	skb_set_transport_header(nskb, skb_transport_offset(p));
-
-	__skb_pull(p, skb_gro_offset(p));
-	memcpy(skb_mac_header(nskb), skb_mac_header(p),
-	       p->data - skb_mac_header(p));
-
-	skb_shinfo(nskb)->frag_list = p;
-	skb_shinfo(nskb)->gso_size = pinfo->gso_size;
-	pinfo->gso_size = 0;
-	__skb_header_release(p);
-	NAPI_GRO_CB(nskb)->last = p;
-
-	nskb->data_len += p->len;
-	nskb->truesize += p->truesize;
-	nskb->len += p->len;
-
-	*head = nskb;
-	nskb->next = p->next;
-	p->next = NULL;
-
-	p = nskb;
 
 merge:
 	delta_truesize = skb->truesize;

^ permalink raw reply related	[flat|nested] 9+ messages in thread

* Re: [PATCH v2 net-next] net: gro: remove obsolete code from skb_gro_receive()
  2015-03-05 21:47 ` [PATCH v2 " Eric Dumazet
@ 2015-03-06  6:04   ` David Miller
  2015-03-06 20:39     ` Eric Dumazet
  0 siblings, 1 reply; 9+ messages in thread
From: David Miller @ 2015-03-06  6:04 UTC (permalink / raw)
  To: eric.dumazet; +Cc: netdev, herbert

From: Eric Dumazet <eric.dumazet@gmail.com>
Date: Thu, 05 Mar 2015 13:47:48 -0800

> From: Eric Dumazet <edumazet@google.com>
> 
> Some drivers use copybreak to copy tiny frames into smaller skb,
> and this smaller skb might not have skb->head_frag set for various
> reasons.
> 
> skb_gro_receive() currently doesn't allow to aggregate the smaller skb
> into the previous GRO packet if this GRO packet has at least 2 MSS in
> it.
> 
> Following workload easily demonstrates the problem.
> 
> netperf -t TCP_RR -H target -- -r 3000,3000 
> 
> (tcpdump shows one GRO packet with 2 MSS, plus one additional packet of
> 104 bytes that should have been appended.)
> 
> It turns out that we can remove code from skb_gro_receive(), because
> commit 8a29111c7ca6 ("net: gro: allow to build full sized skb") and its
> followups removed the assumption that a GRO packet with a frag_list had
> to have an empty head.
> 
> Removing this code allows the aggregation of the last (incomplete) frame
> in some RPC workloads. Note that tcp_gro_receive() already takes care of
> forcing a flush if necessary, including this case.
> 
> If we want to avoid using frag_list in the first place (in forwarding
> workloads for example, as the outgoing NIC is generally not able to cope
> with skbs having a frag_list), we need to address this separately.
> 
> Signed-off-by: Eric Dumazet <edumazet@google.com>
> Cc: Herbert Xu <herbert@gondor.apana.org.au>
> ---
> v2: removed headroom & nskb variables, no longer needed.

Looks good, applied, thanks!

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [PATCH v2 net-next] net: gro: remove obsolete code from skb_gro_receive()
  2015-03-06  6:04   ` David Miller
@ 2015-03-06 20:39     ` Eric Dumazet
  2015-03-06 20:59       ` David Miller
  0 siblings, 1 reply; 9+ messages in thread
From: Eric Dumazet @ 2015-03-06 20:39 UTC (permalink / raw)
  To: David Miller; +Cc: netdev, herbert

On Fri, 2015-03-06 at 01:04 -0500, David Miller wrote:
> From: Eric Dumazet <eric.dumazet@gmail.com>

> > v2: removed headroom & nskb variables, no longer needed.
> 
> Looks good, applied, thanks!

Strange, I do not see it on net-next ?

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [PATCH v2 net-next] net: gro: remove obsolete code from skb_gro_receive()
  2015-03-06 20:39     ` Eric Dumazet
@ 2015-03-06 20:59       ` David Miller
  2015-03-06 23:56         ` Eric Dumazet
  0 siblings, 1 reply; 9+ messages in thread
From: David Miller @ 2015-03-06 20:59 UTC (permalink / raw)
  To: eric.dumazet; +Cc: netdev, herbert

From: Eric Dumazet <eric.dumazet@gmail.com>
Date: Fri, 06 Mar 2015 12:39:48 -0800

> On Fri, 2015-03-06 at 01:04 -0500, David Miller wrote:
>> From: Eric Dumazet <eric.dumazet@gmail.com>
> 
>> > v2: removed headroom & nskb variables, no longer needed.
>> 
>> Looks good, applied, thanks!
> 
> Strange, I do not see it on net-next ?

I left changes on my workstation at home before going to the office today,
will fix things up tonight.

I suggested to Daniel, also effect by this brain-o, that I should setup
my workstations to deliver an electric shock to me if I leave unpushed
GIT changes around.

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [PATCH v2 net-next] net: gro: remove obsolete code from skb_gro_receive()
  2015-03-06 20:59       ` David Miller
@ 2015-03-06 23:56         ` Eric Dumazet
  2015-03-07  3:02           ` David Miller
  0 siblings, 1 reply; 9+ messages in thread
From: Eric Dumazet @ 2015-03-06 23:56 UTC (permalink / raw)
  To: David Miller; +Cc: netdev, herbert

On Fri, 2015-03-06 at 15:59 -0500, David Miller wrote:

> I left changes on my workstation at home before going to the office today,
> will fix things up tonight.
> 
> I suggested to Daniel, also effect by this brain-o, that I should setup
> my workstations to deliver an electric shock to me if I leave unpushed
> GIT changes around.

Ah OK, thanks David, no worries ;)

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [PATCH v2 net-next] net: gro: remove obsolete code from skb_gro_receive()
  2015-03-06 23:56         ` Eric Dumazet
@ 2015-03-07  3:02           ` David Miller
  0 siblings, 0 replies; 9+ messages in thread
From: David Miller @ 2015-03-07  3:02 UTC (permalink / raw)
  To: eric.dumazet; +Cc: netdev, herbert

From: Eric Dumazet <eric.dumazet@gmail.com>
Date: Fri, 06 Mar 2015 15:56:50 -0800

> On Fri, 2015-03-06 at 15:59 -0500, David Miller wrote:
> 
>> I left changes on my workstation at home before going to the office today,
>> will fix things up tonight.
>> 
>> I suggested to Daniel, also effect by this brain-o, that I should setup
>> my workstations to deliver an electric shock to me if I leave unpushed
>> GIT changes around.
> 
> Ah OK, thanks David, no worries ;)

Now pushed.

^ permalink raw reply	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2015-03-07  3:02 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-03-04 18:26 [PATCH net-next] net: gro: remove obsolete code from skb_gro_receive() Eric Dumazet
2015-03-05 21:00 ` David Miller
2015-03-05 21:04   ` Eric Dumazet
2015-03-05 21:47 ` [PATCH v2 " Eric Dumazet
2015-03-06  6:04   ` David Miller
2015-03-06 20:39     ` Eric Dumazet
2015-03-06 20:59       ` David Miller
2015-03-06 23:56         ` Eric Dumazet
2015-03-07  3:02           ` David Miller

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).