All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 0/2] gro: optimise redundant parsing of packets
@ 2023-01-30 13:00 Richard Gobert
  2023-01-30 13:05 ` [PATCH 1/2] gro: decrease size of CB Richard Gobert
  2023-01-30 13:07 ` [PATCH 2/2] gro: optimise redundant parsing of packets Richard Gobert
  0 siblings, 2 replies; 8+ messages in thread
From: Richard Gobert @ 2023-01-30 13:00 UTC (permalink / raw)
  To: davem, edumazet, kuba, pabeni, yoshfuji, dsahern,
	steffen.klassert, lixiaoyan, alexanderduyck, leon, ye.xingchen,
	iwienand, netdev, linux-kernel

Currently, the IPv6 extension headers are parsed twice: first in
ipv6_gro_receive, and then again in ipv6_gro_complete.

The field NAPI_GRO_CB(skb)->proto is used by GRO to hold the layer 4
protocol type that comes after the IPv6 layer. I noticed that it is set
in ipv6_gro_receive, but isn't used anywhere. By using this field, and
also storing the size of the network header, we can avoid parsing
extension headers a second time in ipv6_gro_complete.

The first commit frees up space in the GRO CB. The second commit reduces
the redundant parsing during the complete phase, using the freed CB
space.

I've applied this optimisation to all base protocols (IPv6, IPv4,
Ethernet). Then, I benchmarked this patch on my machine, using ftrace to
measure ipv6_gro_complete's performance, and there was an improvement.

Richard Gobert (2):
  gro: decrease size of CB
  gro: optimise redundant parsing of packets

 include/net/gro.h      | 32 +++++++++++++++++++++-----------
 net/core/gro.c         | 18 +++++++++++-------
 net/ethernet/eth.c     | 11 +++++++++--
 net/ipv4/af_inet.c     |  8 +++++++-
 net/ipv6/ip6_offload.c | 15 ++++++++++++---
 5 files changed, 60 insertions(+), 24 deletions(-)

-- 
2.36.1


^ permalink raw reply	[flat|nested] 8+ messages in thread
* Re: [PATCH 2/2] gro: optimise redundant parsing of packets
@ 2023-02-02 23:43 kernel test robot
  0 siblings, 0 replies; 8+ messages in thread
From: kernel test robot @ 2023-02-02 23:43 UTC (permalink / raw)
  To: oe-kbuild; +Cc: lkp, Dan Carpenter

BCC: lkp@intel.com
CC: oe-kbuild-all@lists.linux.dev
In-Reply-To: <20230130130752.GA8015@debian>
References: <20230130130752.GA8015@debian>
TO: Richard Gobert <richardbgobert@gmail.com>
TO: davem@davemloft.net
TO: edumazet@google.com
TO: kuba@kernel.org
TO: pabeni@redhat.com
TO: yoshfuji@linux-ipv6.org
TO: dsahern@kernel.org
TO: steffen.klassert@secunet.com
TO: lixiaoyan@google.com
TO: alexanderduyck@fb.com
TO: leon@kernel.org
TO: ye.xingchen@zte.com.cn
TO: iwienand@redhat.com
TO: netdev@vger.kernel.org
TO: linux-kernel@vger.kernel.org

Hi Richard,

Thank you for the patch! Perhaps something to improve:

[auto build test WARNING on net-next/master]
[also build test WARNING on net/master horms-ipvs/master linus/master v6.2-rc6 next-20230202]
[If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch#_base_tree_information]

url:    https://github.com/intel-lab-lkp/linux/commits/Richard-Gobert/gro-decrease-size-of-CB/20230130-211021
patch link:    https://lore.kernel.org/r/20230130130752.GA8015%40debian
patch subject: [PATCH 2/2] gro: optimise redundant parsing of packets
:::::: branch date: 3 days ago
:::::: commit date: 3 days ago
config: x86_64-randconfig-m001 (https://download.01.org/0day-ci/archive/20230203/202302030719.VvvUWPzr-lkp@intel.com/config)
compiler: gcc-11 (Debian 11.3.0-8) 11.3.0

If you fix the issue, kindly add following tag where applicable
| Reported-by: kernel test robot <lkp@intel.com>
| Reported-by: Dan Carpenter <error27@gmail.com>

smatch warnings:
net/ipv4/af_inet.c:1641 inet_gro_complete() warn: potential spectre issue 'inet_offloads' [w]

vim +/inet_offloads +1641 net/ipv4/af_inet.c

f4713a3dfad045 Willem de Bruijn 2014-11-26  1621  
b8921ca83eed24 Tom Herbert      2016-05-18  1622  int inet_gro_complete(struct sk_buff *skb, int nhoff)
73cc19f1556b95 Herbert Xu       2008-12-15  1623  {
299603e8370a93 Jerry Chu        2013-12-11  1624  	__be16 newlen = htons(skb->len - nhoff);
299603e8370a93 Jerry Chu        2013-12-11  1625  	struct iphdr *iph = (struct iphdr *)(skb->data + nhoff);
bca49f843eac59 Vlad Yasevich    2012-11-15  1626  	const struct net_offload *ops;
5eba599d4a8c3c Richard Gobert   2023-01-30  1627  	int proto;
73cc19f1556b95 Herbert Xu       2008-12-15  1628  	int err = -ENOSYS;
73cc19f1556b95 Herbert Xu       2008-12-15  1629  
294acf1c01bace Paolo Abeni      2017-03-07  1630  	if (skb->encapsulation) {
294acf1c01bace Paolo Abeni      2017-03-07  1631  		skb_set_inner_protocol(skb, cpu_to_be16(ETH_P_IP));
c3caf1192f904d Jerry Chu        2014-07-14  1632  		skb_set_inner_network_header(skb, nhoff);
5eba599d4a8c3c Richard Gobert   2023-01-30  1633  		proto = iph->protocol;
5eba599d4a8c3c Richard Gobert   2023-01-30  1634  	} else {
5eba599d4a8c3c Richard Gobert   2023-01-30  1635  		proto = NAPI_GRO_CB(skb)->transport_proto;
294acf1c01bace Paolo Abeni      2017-03-07  1636  	}
c3caf1192f904d Jerry Chu        2014-07-14  1637  
73cc19f1556b95 Herbert Xu       2008-12-15  1638  	csum_replace2(&iph->check, iph->tot_len, newlen);
73cc19f1556b95 Herbert Xu       2008-12-15  1639  	iph->tot_len = newlen;
73cc19f1556b95 Herbert Xu       2008-12-15  1640  
bca49f843eac59 Vlad Yasevich    2012-11-15 @1641  	ops = rcu_dereference(inet_offloads[proto]);
f191a1d17f2270 Vlad Yasevich    2012-11-15  1642  	if (WARN_ON(!ops || !ops->callbacks.gro_complete))
627b94f75b82d1 Eric Dumazet     2021-11-23  1643  		goto out;
73cc19f1556b95 Herbert Xu       2008-12-15  1644  
299603e8370a93 Jerry Chu        2013-12-11  1645  	/* Only need to add sizeof(*iph) to get to the next hdr below
299603e8370a93 Jerry Chu        2013-12-11  1646  	 * because any hdr with option will have been flushed in
299603e8370a93 Jerry Chu        2013-12-11  1647  	 * inet_gro_receive().
299603e8370a93 Jerry Chu        2013-12-11  1648  	 */
028e0a4766844e Paolo Abeni      2018-12-14  1649  	err = INDIRECT_CALL_2(ops->callbacks.gro_complete,
028e0a4766844e Paolo Abeni      2018-12-14  1650  			      tcp4_gro_complete, udp4_gro_complete,
028e0a4766844e Paolo Abeni      2018-12-14  1651  			      skb, nhoff + sizeof(*iph));
73cc19f1556b95 Herbert Xu       2008-12-15  1652  
627b94f75b82d1 Eric Dumazet     2021-11-23  1653  out:
73cc19f1556b95 Herbert Xu       2008-12-15  1654  	return err;
73cc19f1556b95 Herbert Xu       2008-12-15  1655  }
73cc19f1556b95 Herbert Xu       2008-12-15  1656  

-- 
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests

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

end of thread, other threads:[~2023-02-22 14:49 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-01-30 13:00 [PATCH 0/2] gro: optimise redundant parsing of packets Richard Gobert
2023-01-30 13:05 ` [PATCH 1/2] gro: decrease size of CB Richard Gobert
2023-01-30 13:07 ` [PATCH 2/2] gro: optimise redundant parsing of packets Richard Gobert
2023-01-30 15:40   ` Alexander Lobakin
2023-02-22 14:47     ` Richard Gobert
2023-01-30 17:39   ` Eric Dumazet
2023-02-22 14:35     ` Richard Gobert
  -- strict thread matches above, loose matches on Subject: below --
2023-02-02 23:43 kernel test robot

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.