net: Make gro complete function to return void
Subsystems (3)
PATCH 1/1 net: Make gro complete function to return void
tcp_gro_complete() function only updates the skb fields related to GRO and it always returns zero. All the 3 drivers which are using it do not check for the return value either.
Change it to return void instead which simplifies its callers as error handing becomes unnecessary.
--- include/net/tcp.h | 2 +- net/ipv4/tcp_offload.c | 7 +++---- net/ipv6/tcpv6_offload.c | 3 ++- 3 files changed, 6 insertions(+), 6 deletions(-)
include/net/tcp.h +1 -1
@@ -2041,7 +2041,7 @@ INDIRECT_CALLABLE_DECLARE(int tcp4_gro_complete(struct sk_buff *skb, int thoff)) INDIRECT_CALLABLE_DECLARE(struct sk_buff *tcp4_gro_receive(struct list_head *head, struct sk_buff *skb)); INDIRECT_CALLABLE_DECLARE(int tcp6_gro_complete(struct sk_buff *skb, int thoff)); INDIRECT_CALLABLE_DECLARE(struct sk_buff *tcp6_gro_receive(struct list_head *head, struct sk_buff *skb)); -int tcp_gro_complete (struct sk_buff *skb); +void tcp_gro_complete (struct sk_buff *skb);void __tcp_v4_send_check (struct sk_buff *skb,__be32 saddr,__be32 daddr);
net/ipv4/tcp_offload.c +3 -4
@@ -296,7 +296,7 @@ struct sk_buff *tcp_gro_receive(struct list_head *head, struct sk_buff *skb)return pp; } -int tcp_gro_complete (struct sk_buff *skb) +void tcp_gro_complete (struct sk_buff *skb) {struct tcphdr *th =tcp_hdr (skb);
@@ -311,8 +311,6 @@ int tcp_gro_complete(struct sk_buff *skb)if (skb->encapsulation) skb->inner_transport_header = skb->transport_header; - -return 0 ; }EXPORT_SYMBOL (tcp_gro_complete);
@@ -342,7 +340,8 @@ INDIRECT_CALLABLE_SCOPE int tcp4_gro_complete(struct sk_buff *skb, int thoff)if (NAPI_GRO_CB (skb)->is_atomic)skb_shinfo (skb)->gso_type |=SKB_GSO_TCP_FIXEDID ; -return tcp_gro_complete (skb); +tcp_gro_complete (skb); +return 0 ; }static const struct net_offload tcpv4_offload = {
net/ipv6/tcpv6_offload.c +2 -1
@@ -36,7 +36,8 @@ INDIRECT_CALLABLE_SCOPE int tcp6_gro_complete(struct sk_buff *skb, int thoff) &iph->daddr, 0);skb_shinfo (skb)->gso_type |=SKB_GSO_TCPV6 ; -return tcp_gro_complete (skb); +tcp_gro_complete (skb); +return 0 ; } static struct sk_buff *tcp6_gso_segment(struct sk_buff *skb,
Signature · 1 line
2.26.2
Quoted 8 lines · Parav Pandit
tcp_gro_complete()function only updates the skb fields related to GRO and it always returns zero. All the 3 drivers which are using it do not check for the return value either.Change it to return void instead which simplifies its callers as error handing becomes unnecessary.
Signed-off-by Parav Pandit <[email protected]>
Quoted 14 lines · Parav Pandit
net/ipv4/tcp_offload.c +1
-1@@ -296,7 +296,7 @@ struct sk_buff *tcp_gro_receive(struct list_head *head, struct sk_buff *skb)return pp; } -int tcp_gro_complete (struct sk_buff *skb) +void tcp_gro_complete (struct sk_buff *skb) {struct tcphdr *th =tcp_hdr (skb);
net/ipv4/tcp_offload.c int tcp_gro_complete(struct sk_buff *skb) · line 315
Quoted 7 lines
net/ipv4/tcp_offload.c +0
-2@@ -311,8 +311,6 @@ int tcp_gro_complete(struct sk_buff *skb)if (skb->encapsulation) skb->inner_transport_header = skb->transport_header; - -return 0 ; }EXPORT_SYMBOL (tcp_gro_complete);
tcp_gro_complete seems fairly trivial. Any reason not to make it an inline and avoid another function call in the datapath?
Quoted 10 lines
net/ipv4/tcp_offload.c +2
-1@@ -342,7 +340,8 @@ INDIRECT_CALLABLE_SCOPE int tcp4_gro_complete(struct sk_buff *skb, int thoff)if (NAPI_GRO_CB (skb)->is_atomic)skb_shinfo (skb)->gso_type |=SKB_GSO_TCP_FIXEDID ; -return tcp_gro_complete (skb); +tcp_gro_complete (skb); +return 0 ; }
Quoted 20 lines
From: David Ahern <[email protected]>
Sent: Tuesday, May 30, 2023 11:26 AMnet/ipv4/tcp_offload.c struct sk_buff *tcp_gro_receive(struct list_head
Quoted 5 lines · Parav Pandit
net/ipv4/tcp_offload.c index renamed from net/ipv4/tcp_offload.c +0
-0
45dda7889387..88f9b0081ee7100644net/ipv4/tcp_offload.c +0
-0@@ -296,7 +296,7 @@ struct sk_buff *tcp_gro_receive(struct list_head*head, struct
sk_buff*skb)Quoted 10 lines
net/ipv4/tcp_offload.c +1
-1return pp; } -int tcp_gro_complete (struct sk_buff *skb) +void tcp_gro_complete (struct sk_buff *skb) {struct tcphdr *th =tcp_hdr (skb);@@ -311,8 +311,6 @@ int tcp_gro_complete(struct sk_buff *skb)
Quoted 10 lines
net/ipv4/tcp_offload.c int tcp_gro_complete(struct sk_buff *skb) · line 315
Quoted 6 lines
net/ipv4/tcp_offload.c +0
-2if (skb->encapsulation) skb->inner_transport_header = skb->transport_header; - -return 0 ; }EXPORT_SYMBOL (tcp_gro_complete);
tcp_gro_completeseems fairly trivial. Any reason not to make it an inline and avoid another function call in the datapath?
Sounds good to me.
With inline it should mostly improve the perf, but I do not have any of the 3 adapters which are calling this API to show perf results.
Since, it is a different change touching the performance, I prefer to do follow up patch that bnx owners can test. Is that ok?
Quoted 17 lines · David Ahern
Quoted 15 lines · Parav Pandit
net/ipv4/tcp_offload.c +1
-1@@ -296,7 +296,7 @@ struct sk_buff *tcp_gro_receive(struct list_head *head, struct sk_buff *skb)return pp; } -int tcp_gro_complete (struct sk_buff *skb) +void tcp_gro_complete (struct sk_buff *skb) {struct tcphdr *th =tcp_hdr (skb);@@ -311,8 +311,6 @@ int tcp_gro_complete(struct sk_buff *skb)
Quoted 9 lines
net/ipv4/tcp_offload.c int tcp_gro_complete(struct sk_buff *skb) · line 315
Quoted 6 lines
net/ipv4/tcp_offload.c +0
-2if (skb->encapsulation) skb->inner_transport_header = skb->transport_header; - -return 0 ; }EXPORT_SYMBOL (tcp_gro_complete);
tcp_gro_completeseems fairly trivial. Any reason not to make it an inline and avoid another function call in the datapath?
Probably, although it is a regular function call, not an indirect one.
In the grand total of driver rx napi + GRO cost, saving a few cycles per GRO completed packet is quite small.
Quoted 30 lines · Parav Pandit
Quoted 20 lines
From: David Ahern <[email protected]>
Sent: Tuesday, May 30, 2023 11:26 AMnet/ipv4/tcp_offload.c struct sk_buff *tcp_gro_receive(struct list_head
Quoted 5 lines · Parav Pandit
net/ipv4/tcp_offload.c index renamed from net/ipv4/tcp_offload.c +0
-0
45dda7889387..88f9b0081ee7100644net/ipv4/tcp_offload.c +0
-0@@ -296,7 +296,7 @@ struct sk_buff *tcp_gro_receive(struct list_head*head, struct
sk_buff*skb)Quoted 10 lines
net/ipv4/tcp_offload.c +1
-1return pp; } -int tcp_gro_complete (struct sk_buff *skb) +void tcp_gro_complete (struct sk_buff *skb) {struct tcphdr *th =tcp_hdr (skb);@@ -311,8 +311,6 @@ int tcp_gro_complete(struct sk_buff *skb)Quoted 10 lines
net/ipv4/tcp_offload.c int tcp_gro_complete(struct sk_buff *skb) · line 315
Quoted 6 lines
net/ipv4/tcp_offload.c +0
-2if (skb->encapsulation) skb->inner_transport_header = skb->transport_header; - -return 0 ; }EXPORT_SYMBOL (tcp_gro_complete);
tcp_gro_completeseems fairly trivial. Any reason not to make it an inline and avoid another function call in the datapath?
Quoted 5 lines
Sounds good to me.
With inline it should mostly improve the perf, but I do not have any of the 3 adapters which are calling this API to show perf results.Since, it is a different change touching the performance, I prefer to do follow up patch that bnx owners can test. Is that ok?
sure.
Jakub Kicinski
maintainerQuoted 7 lines · On Tue, 30 May 2023 17:48:22 +0200 Eric Dumazet wrote:
Quoted 2 lines
tcp_gro_completeseems fairly trivial. Any reason not to make it an inline and avoid another function call in the datapath?Probably, although it is a regular function call, not an indirect one.
In the grand total of driver rx napi + GRO cost, saving a few cycles per GRO completed packet is quite small.
IOW please make sure you include the performance analysis quantifying the win, if you want to make this a static inline. Or let us know if the patch is good as is, I'm keeping it in pw for now.
Quoted 4 lines · Jakub Kicinski
Quoted 3 lines · On Tue, 30 May 2023 17:48:22 +0200 Eric Dumazet wrote:
Quoted 2 lines
tcp_gro_completeseems fairly trivial. Any reason not to make it an inline and avoid another function call in the datapath?
Quoted 8 lines
Quoted 4 lines
Probably, although it is a regular function call, not an indirect one.
In the grand total of driver rx napi + GRO cost, saving a few cycles per GRO completed packet is quite small.
IOW please make sure you include the performance analysis quantifying the win, if you want to make this a static inline. Or let us know if the patch is good as is, I'm keeping it in pw for now.
I am not suggesting holding up this patch; just constantly looking for these little savings here and there to keep lowering the overhead.
100G, 1500 MTU, line rate is 8.3M pps so GRO wise that would be ~180k fewer function calls.
Quoted 15 lines · David Ahern
Quoted 4 lines · Jakub Kicinski
Quoted 3 lines · On Tue, 30 May 2023 17:48:22 +0200 Eric Dumazet wrote:
Quoted 2 lines
tcp_gro_completeseems fairly trivial. Any reason not to make it an inline and avoid another function call in the datapath?Quoted 8 lines
Quoted 4 lines
Probably, although it is a regular function call, not an indirect one.
In the grand total of driver rx napi + GRO cost, saving a few cycles per GRO completed packet is quite small.
IOW please make sure you include the performance analysis quantifying the win, if you want to make this a static inline. Or let us know if the patch is good as is, I'm keeping it in pw for now.
Quoted 5 lines
I am not suggesting holding up this patch; just constantly looking for these little savings here and there to keep lowering the overhead.
100G, 1500 MTU, line rate is 8.3M pps so GRO wise that would be ~180k fewer function calls.
Here with 4K MTU, this is called 67k per second
An __skb_put() instead of skb_put() in a driver (eg mlx5e_build_linear_skb()) would have 45x more impact, and would still be noise.
This patch was applied to netdev/net-next.git (main) by David S. Miller <[email protected]>:
Hello:
This patch was applied to netdev/net-next.git (main) by David S. Miller <[email protected]>:
Quoted 8 lines · On Mon, 29 May 2023 16:44:30 +0300 you wrote:
tcp_gro_complete()function only updates the skb fields related to GRO and it always returns zero. All the 3 drivers which are using it do not check for the return value either.Change it to return void instead which simplifies its callers as error handing becomes unnecessary.
[...]
Here is the summary with links:
- [net-next] net: Make gro complete function to return void
https://git.kernel.org/netdev/net-next/c/b1f2abcf817d
You are awesome, thank you!
Signature · 2 lines
Deet-doot-dot, I am a bot. https://korg.docs.kernel.org/patchwork/pwbot.html
Quoted 23 lines
From: Eric Dumazet <[email protected]>
Sent: Wednesday, May 31, 2023 12:39 AMQuoted 18 lines · David Ahern
Quoted 4 lines · Jakub Kicinski
Quoted 3 lines · On Tue, 30 May 2023 17:48:22 +0200 Eric Dumazet wrote:
Quoted 2 lines
tcp_gro_completeseems fairly trivial. Any reason not to make it an inline and avoid another function call in the datapath?Quoted 8 lines
Quoted 4 lines
Probably, although it is a regular function call, not an indirect one.
In the grand total of driver rx napi + GRO cost, saving a few cycles per GRO completed packet is quite small.
IOW please make sure you include the performance analysis quantifying the win, if you want to make this a static inline. Or let us know if the patch is good as is, I'm keeping it in pw for now.
I am not suggesting holding up this patch; just constantly looking for these little savings here and there to keep lowering the overhead.
Quoted 7 lines
Quoted 2 lines
100G, 1500 MTU, line rate is 8.3M pps so GRO wise that would be ~180k fewer function calls.
Here with 4K MTU, this is called 67k per second
An
__skb_put()instead ofskb_put()in a driver (egmlx5e_build_linear_skb()) would have 45x more impact, and would still be noise.
Thanks, Eric, for the suggestion, will evaluate with Tariq to use __skb_put().