net: group together hot data
Subsystems (18)
cover net: group together hot data
While our recent structure reorganizations were focused on increasing max throughput, there is still an area where improvements are much needed.
In many cases, a cpu handles one packet at a time, instead of a nice batch.
Hardware interrupt.
-> Software interrupt.
-> Network/Protocol stacks.
If the cpu was idle or busy in other layers, it has to pull many cache lines.
This series adds a new net_hotdata structure, where some critical (and read-mostly) data used in
rx and tx path is packed in a small number of cache lines.
Synthetic benchmarks will not see much difference, but latency of single packet should improve.
net_hodata current size on 64bit is 416 bytes, but might grow in the future.
Also move RPS definitions to a new include file.
Eric Dumazet (18):
net: introduce struct net_hotdata
net: move netdev_budget and netdev_budget to net_hotdata
net: move netdev_tstamp_prequeue into net_hotdata
net: move ptype_all into net_hotdata
net: move netdev_max_backlog to net_hotdata
net: move ip_packet_offload and ipv6_packet_offload to net_hotdata
net: move tcpv4_offload and tcpv6_offload to net_hotdata
net: move dev_tx_weight to net_hotdata
net: move dev_rx_weight to net_hotdata
net: move skbuff_cache(s) to net_hotdata
udp: move udpv4_offload and udpv6_offload to net_hotdata
ipv6: move tcpv6_protocol and udpv6_protocol to net_hotdata
inet: move tcp_protocol and udp_protocol to net_hotdata
inet: move inet_ehash_secret and udp_ehash_secret into net_hotdata
ipv6: move inet6_ehash_secret and udp6_ehash_secret into net_hotdata
ipv6: move tcp_ipv6_hash_secret and udp_ipv6_hash_secret to
net_hotdata
net: introduce include/net/rps.h
net: move rps_sock_flow_table to net_hotdata
drivers/net/ethernet/intel/ice/ice_arfs.c | 1 + .../net/ethernet/mellanox/mlx4/en_netdev.c | 1 + .../net/ethernet/mellanox/mlx5/core/en_arfs.c | 1 + drivers/net/ethernet/sfc/rx_common.c | 1 + drivers/net/ethernet/sfc/siena/rx_common.c | 1 + drivers/net/tun.c | 1 + include/linux/netdevice.h | 88 ------------ include/linux/skbuff.h | 1 - include/net/gro.h | 5 +- include/net/hotdata.h | 52 ++++++++ include/net/protocol.h | 3 + include/net/rps.h | 125 ++++++++++++++++++ include/net/sock.h | 35 ----- kernel/bpf/cpumap.c | 4 +- net/bpf/test_run.c | 4 +- net/core/Makefile | 1 + net/core/dev.c | 58 +++----- net/core/dev.h | 3 - net/core/gro.c | 15 +-- net/core/gro_cells.c | 3 +- net/core/gso.c | 4 +- net/core/hotdata.c | 22 +++ net/core/net-procfs.c | 7 +- net/core/net-sysfs.c | 1 + net/core/skbuff.c | 44 +++--- net/core/sysctl_net_core.c | 25 ++-- net/core/xdp.c | 5 +- net/ipv4/af_inet.c | 49 +++---- net/ipv4/inet_hashtables.c | 3 +- net/ipv4/tcp.c | 1 + net/ipv4/tcp_offload.c | 17 ++- net/ipv4/udp.c | 2 - net/ipv4/udp_offload.c | 17 ++- net/ipv6/af_inet6.c | 1 + net/ipv6/inet6_hashtables.c | 8 +- net/ipv6/ip6_offload.c | 18 +-- net/ipv6/tcp_ipv6.c | 17 +-- net/ipv6/tcpv6_offload.c | 16 +-- net/ipv6/udp.c | 19 ++- net/ipv6/udp_offload.c | 21 ++- net/sched/sch_generic.c | 3 +- net/sctp/socket.c | 1 + net/xfrm/espintcp.c | 4 +- net/xfrm/xfrm_input.c | 3 +- 44 files changed, 391 insertions(+), 320 deletions(-) create mode 100644 include/net/hotdata.h create mode 100644 include/net/rps.h create mode 100644 net/core/hotdata.c
Signature · 1 line
2.44.0.278.ge034bb2e1d-goog
PATCH 1/18 net: introduce struct net_hotdata
Instead of spreading networking critical fields all over the places, add a custom net_hotdata structure so that we can precisely control its layout.
In this first patch, move :
- gro_normal_batch used in rx (GRO stack)
- offload_base used in rx and tx (GRO and TSO stacks)
--- include/linux/netdevice.h | 1 - include/net/gro.h | 5 ++--- include/net/hotdata.h | 15 +++++++++++++++ net/core/Makefile | 1 + net/core/gro.c | 15 ++++++--------- net/core/gso.c | 4 ++-- net/core/hotdata.c | 9 +++++++++ net/core/sysctl_net_core.c | 3 ++- 8 files changed, 37 insertions(+), 16 deletions(-) create mode 100644 include/net/hotdata.h create mode 100644 net/core/hotdata.c
include/linux/netdevice.h +0 -1
@@ -4790,7 +4790,6 @@ void dev_get_tstats64(struct net_device *dev, struct rtnl_link_stats64 *s);extern int netdev_max_backlog;extern int dev_rx_weight;extern int dev_tx_weight; -extern int gro_normal_batch;enum {NESTED_SYNC_IMM_BIT ,
include/net/gro.h +2 -3
@@ -9,6 +9,7 @@#include <net/ip6_checksum.h> #include <linux/skbuff.h> #include <net/udp.h> +#include <net/hotdata.h> struct napi_gro_cb { union {
@@ -446,7 +447,7 @@ static inline void gro_normal_one(struct napi_struct *napi, struct sk_buff *skb, {list_add_tail (&skb->list, &napi->rx_list); napi->rx_count += segs; -if (napi->rx_count >=READ_ONCE (gro_normal_batch)) +if (napi->rx_count >=READ_ONCE (net_hotdata.gro_normal_batch))gro_normal_list (napi); }
@@ -493,6 +494,4 @@ static inline void inet6_get_iif_sdif(const struct sk_buff *skb, int *iif, int * #endif } -extern struct list_head offload_base; -#endif /* _NET_IPV6_GRO_H */
include/net/hotdata.h new file +15 -0
@@ -0,0 +1,15 @@ +/* SPDX-License-Identifier: GPL-2.0-or-later */ +#ifndef _NET_HOTDATA_H +#define _NET_HOTDATA_H + +#include <linux/types.h> + +/* Read mostly data used in network fast paths. */ +struct net_hotdata { +struct list_head offload_base; +int gro_normal_batch; +}; + +extern struct net_hotdata net_hotdata; + +#endif /* _NET_HOTDATA_H */
net/core/Makefile +1 -0
@@ -18,6 +18,7 @@ obj-y += dev.o dev_addr_lists.o dst.o netevent.o \ obj-$(CONFIG_NETDEV_ADDR_LIST_TEST) += dev_addr_lists_test.o obj-y += net-sysfs.o +obj-y += hotdata.o obj-$(CONFIG_PAGE_POOL) += page_pool.o page_pool_user.o obj-$(CONFIG_PROC_FS) += net-procfs.o obj-$(CONFIG_NET_PKTGEN) += pktgen.o
net/core/gro.c +6 -9
@@ -10,9 +10,6 @@#define GRO_MAX_HEAD (MAX_HEADER + 128)static DEFINE_SPINLOCK (offload_lock); -struct list_head offload_base__read_mostly =LIST_HEAD_INIT (offload_base); -/* Maximum number of GRO_NORMAL skbs to batch up for list-RX */ -int gro_normal_batch__read_mostly =8 ;/** * dev_add_offload - register offload handlers
@@ -31,7 +28,7 @@ void dev_add_offload(struct packet_offload *po)struct packet_offload *elem;spin_lock (&offload_lock); -list_for_each_entry (elem, &offload_base, list) { +list_for_each_entry (elem, &net_hotdata.offload_base, list) {if (po->priority < elem->priority)break ; }
@@ -55,7 +52,7 @@ EXPORT_SYMBOL(dev_add_offload);*/ static void __dev_remove_offload (struct packet_offload *po) { -struct list_head *head = &offload_base; +struct list_head *head = &net_hotdata.offload_base;struct packet_offload *po1;spin_lock (&offload_lock);
@@ -235,9 +232,9 @@ int skb_gro_receive(struct sk_buff *p, struct sk_buff *skb)static void napi_gro_complete (struct napi_struct *napi,struct sk_buff *skb) { +struct list_head *head = &net_hotdata.offload_base;struct packet_offload *ptype;__be16 type = skb->protocol; -struct list_head *head = &offload_base;int err = -ENOENT ;BUILD_BUG_ON (sizeof (struct napi_gro_cb ) >sizeof (skb->cb));
@@ -444,7 +441,7 @@ static enum gro_result dev_gro_receive(struct napi_struct *napi, struct sk_buff {u32 bucket =skb_get_hash_raw (skb) & (GRO_HASH_BUCKETS -1 );struct gro_list *gro_list = &napi->gro_hash[bucket]; -struct list_head *head = &offload_base; +struct list_head *head = &net_hotdata.offload_base;struct packet_offload *ptype;__be16 type = skb->protocol;struct sk_buff *pp =NULL ;
@@ -550,7 +547,7 @@ static enum gro_result dev_gro_receive(struct napi_struct *napi, struct sk_buffstruct packet_offload *gro_find_receive_by_type (__be16 type) { -struct list_head *offload_head = &offload_base; +struct list_head *offload_head = &net_hotdata.offload_base;struct packet_offload *ptype;list_for_each_entry_rcu (ptype, offload_head, list) {
@@ -564,7 +561,7 @@ EXPORT_SYMBOL(gro_find_receive_by_type);struct packet_offload *gro_find_complete_by_type (__be16 type) { -struct list_head *offload_head = &offload_base; +struct list_head *offload_head = &net_hotdata.offload_base;struct packet_offload *ptype;list_for_each_entry_rcu (ptype, offload_head, list) {
net/core/gso.c +2 -2
@@ -17,7 +17,7 @@ struct sk_buff *skb_eth_gso_segment(struct sk_buff *skb,struct packet_offload *ptype;rcu_read_lock (); -list_for_each_entry_rcu (ptype, &offload_base, list) { +list_for_each_entry_rcu (ptype, &net_hotdata.offload_base, list) {if (ptype->type == type && ptype->callbacks.gso_segment) { segs = ptype->callbacks.gso_segment (skb, features);break ;
@@ -48,7 +48,7 @@ struct sk_buff *skb_mac_gso_segment(struct sk_buff *skb,__skb_pull (skb, vlan_depth);rcu_read_lock (); -list_for_each_entry_rcu (ptype, &offload_base, list) { +list_for_each_entry_rcu (ptype, &net_hotdata.offload_base, list) {if (ptype->type == type && ptype->callbacks.gso_segment) { segs = ptype->callbacks.gso_segment (skb, features);break ;
net/core/hotdata.c new file +9 -0
@@ -0,0 +1,9 @@ +// SPDX-License-Identifier: GPL-2.0-or-later +#include <net/hotdata.h> +#include <linux/cache.h> +#include <linux/list.h> + +struct net_hotdata net_hotdata __cacheline_aligned = { + .offload_base =LIST_HEAD_INIT (net_hotdata.offload_base), + .gro_normal_batch =8 , +};
net/core/sysctl_net_core.c +2 -1
@@ -23,6 +23,7 @@#include <net/net_ratelimit.h> #include <net/busy_poll.h> #include <net/pkt_sched.h> +#include <net/hotdata.h> #include "dev.h"
@@ -632,7 +633,7 @@ static struct ctl_table net_core_table[] = { }, { .procname = "gro_normal_batch", - .data = &gro_normal_batch, + .data = &net_hotdata.gro_normal_batch, .maxlen = sizeof(unsigned int), .mode = 0644, .proc_handler = proc_dointvec_minmax,
Signature · 1 line
2.44.0.278.ge034bb2e1d-goog
PATCH 2/18 net: move netdev_budget and netdev_budget to net_hotdata
In reply to Eric Dumazetnetdev_budget and netdev_budget are used in rx path (net_rx_action())
Move them into net_hotdata for better cache locality.
--- include/net/hotdata.h | 2 ++ net/core/dev.c | 7 ++----- net/core/dev.h | 2 -- net/core/hotdata.c | 6 ++++++ net/core/sysctl_net_core.c | 4 ++-- 5 files changed, 12 insertions(+), 9 deletions(-)
include/net/hotdata.h +2 -0
@@ -8,6 +8,8 @@struct net_hotdata {struct list_head offload_base;int gro_normal_batch; +int netdev_budget; +int netdev_budget_usecs; };extern struct net_hotdata net_hotdata;
net/core/dev.c +2 -5
@@ -4410,9 +4410,6 @@ EXPORT_SYMBOL(netdev_max_backlog);int netdev_tstamp_prequeue__read_mostly =1 ;unsigned int sysctl_skb_defer_max__read_mostly =64 ; -int netdev_budget__read_mostly =300 ; -/* Must be at least 2 jiffes to guarantee 1 jiffy timeout */ -unsigned int __read_mostly netdev_budget_usecs =2 *USEC_PER_SEC /HZ ;int weight_p__read_mostly =64 ;/* old backlog weight */ int dev_weight_rx_bias__read_mostly =1 ;/* bias for backlog weight */ int dev_weight_tx_bias__read_mostly =1 ;/* bias for output_queue quota */
@@ -6790,8 +6787,8 @@ static __latent_entropy void net_rx_action(struct softirq_action *h) {struct softnet_data *sd =this_cpu_ptr (&softnet_data);unsigned long time_limit = jiffies + -usecs_to_jiffies (READ_ONCE (netdev_budget_usecs)); -int budget =READ_ONCE (netdev_budget); +usecs_to_jiffies (READ_ONCE (net_hotdata.netdev_budget_usecs)); +int budget =READ_ONCE (net_hotdata.netdev_budget);LIST_HEAD (list);LIST_HEAD (repoll);
net/core/dev.h +0 -2
@@ -38,8 +38,6 @@ int dev_addr_init(struct net_device *dev);void dev_addr_check (struct net_device *dev);/* sysctls not referred to from outside net/core/ */ -extern int netdev_budget; -extern unsigned int netdev_budget_usecs;extern unsigned int sysctl_skb_defer_max;extern int netdev_tstamp_prequeue;extern int netdev_unregister_timeout_secs;
net/core/hotdata.c +6 -0
@@ -1,9 +1,15 @@// SPDX-License-Identifier: GPL-2.0-or-later #include <net/hotdata.h> #include <linux/cache.h> +#include <linux/jiffies.h> #include <linux/list.h> + struct net_hotdata net_hotdata __cacheline_aligned = { .offload_base =LIST_HEAD_INIT (net_hotdata.offload_base), .gro_normal_batch =8 , + + .netdev_budget =300 , +/* Must be at least 2 jiffes to guarantee 1 jiffy timeout */ + .netdev_budget_usecs =2 *USEC_PER_SEC /HZ , };
net/core/sysctl_net_core.c +2 -2
@@ -577,7 +577,7 @@ static struct ctl_table net_core_table[] = {#endif { .procname = "netdev_budget", - .data = &netdev_budget, + .data = &net_hotdata.netdev_budget, .maxlen = sizeof(int), .mode =0644 , .proc_handler = proc_dointvec
@@ -600,7 +600,7 @@ static struct ctl_table net_core_table[] = { }, { .procname = "netdev_budget_usecs", - .data = &netdev_budget_usecs, + .data = &net_hotdata.netdev_budget_usecs, .maxlen = sizeof(unsigned int), .mode = 0644, .proc_handler = proc_dointvec_minmax,
Signature · 1 line
2.44.0.278.ge034bb2e1d-goog
Re: [PATCH net-next 02/18] net: move netdev_budget and netdev_budget to net_hotdata
Quoted 1 line · Eric Dumazet
netdev_budgetandnetdev_budgetare used in rx path (net_rx_action())
I think one of these is missing _usecs ?
Andrew
PATCH 3/18 net: move netdev_tstamp_prequeue into net_hotdata
In reply to Eric Dumazetnetdev_tstamp_prequeue is used in rx path.
Move it to net_hotdata for better cache locality.
--- include/net/hotdata.h | 1 + net/core/dev.c | 10 +++++----- net/core/dev.h | 1 - net/core/hotdata.c | 2 ++ net/core/sysctl_net_core.c | 2 +- 5 files changed, 9 insertions(+), 7 deletions(-)
include/net/hotdata.h +1 -0
@@ -10,6 +10,7 @@ struct net_hotdata {int gro_normal_batch;int netdev_budget;int netdev_budget_usecs; +int tstamp_prequeue; };extern struct net_hotdata net_hotdata;
net/core/dev.c +5 -5
@@ -4408,7 +4408,6 @@ EXPORT_SYMBOL(__dev_direct_xmit);int netdev_max_backlog__read_mostly =1000 ;EXPORT_SYMBOL (netdev_max_backlog); -int netdev_tstamp_prequeue__read_mostly =1 ;unsigned int sysctl_skb_defer_max__read_mostly =64 ;int weight_p__read_mostly =64 ;/* old backlog weight */ int dev_weight_rx_bias__read_mostly =1 ;/* bias for backlog weight */
@@ -5052,7 +5051,7 @@ static int netif_rx_internal(struct sk_buff *skb) {int ret; -net_timestamp_check (READ_ONCE (netdev_tstamp_prequeue), skb); +net_timestamp_check (READ_ONCE (net_hotdata.tstamp_prequeue), skb);trace_netif_rx (skb);
@@ -5344,7 +5343,7 @@ static int __netif_receive_skb_core(struct sk_buff **pskb, bool pfmemalloc,int ret =NET_RX_DROP ;__be16 type; -net_timestamp_check (!READ_ONCE (netdev_tstamp_prequeue), skb); +net_timestamp_check (!READ_ONCE (net_hotdata.tstamp_prequeue), skb);trace_netif_receive_skb (skb);
@@ -5728,7 +5727,7 @@ static int netif_receive_skb_internal(struct sk_buff *skb) {int ret; -net_timestamp_check (READ_ONCE (netdev_tstamp_prequeue), skb); +net_timestamp_check (READ_ONCE (net_hotdata.tstamp_prequeue), skb);if (skb_defer_rx_timestamp (skb))return NET_RX_SUCCESS ;
@@ -5758,7 +5757,8 @@ void netif_receive_skb_list_internal(struct list_head *head)INIT_LIST_HEAD (&sublist);list_for_each_entry_safe (skb, next, head, list) { -net_timestamp_check (READ_ONCE (netdev_tstamp_prequeue), skb); +net_timestamp_check (READ_ONCE (net_hotdata.tstamp_prequeue), + skb);skb_list_del_init (skb);if (!skb_defer_rx_timestamp (skb))list_add_tail (&skb->list, &sublist);
net/core/dev.h +0 -1
@@ -39,7 +39,6 @@ void dev_addr_check(struct net_device *dev);/* sysctls not referred to from outside net/core/ */ extern unsigned int sysctl_skb_defer_max; -extern int netdev_tstamp_prequeue;extern int netdev_unregister_timeout_secs;extern int weight_p;extern int dev_weight_rx_bias;
net/core/hotdata.c +2 -0
@@ -12,4 +12,6 @@ struct net_hotdata net_hotdata __cacheline_aligned = { .netdev_budget = 300,/* Must be at least 2 jiffes to guarantee 1 jiffy timeout */ .netdev_budget_usecs = 2 * USEC_PER_SEC / HZ, + + .tstamp_prequeue = 1, };
net/core/sysctl_net_core.c +1 -1
@@ -499,7 +499,7 @@ static struct ctl_table net_core_table[] = {#endif { .procname = "netdev_tstamp_prequeue", - .data = &netdev_tstamp_prequeue, + .data = &net_hotdata.tstamp_prequeue, .maxlen = sizeof(int), .mode =0644 , .proc_handler = proc_dointvec
Signature · 1 line
2.44.0.278.ge034bb2e1d-goog
PATCH 4/18 net: move ptype_all into net_hotdata
In reply to Eric Dumazetptype_all is used in rx/tx fast paths.
Move it to net_hotdata for better cache locality.
--- include/linux/netdevice.h | 1 - include/net/hotdata.h | 1 + net/core/dev.c | 16 +++++++--------- net/core/hotdata.c | 1 + net/core/net-procfs.c | 7 ++++--- 5 files changed, 13 insertions(+), 13 deletions(-)
include/linux/netdevice.h +0 -1
@@ -5300,7 +5300,6 @@ static inline const char *netdev_reg_state(const struct net_device *dev)#define PTYPE_HASH_SIZE (16)#define PTYPE_HASH_MASK (PTYPE_HASH_SIZE - 1) -extern struct list_head ptype_all__read_mostly ;extern struct list_head ptype_base[PTYPE_HASH_SIZE ]__read_mostly ;extern struct net_device *blackhole_netdev;
include/net/hotdata.h +1 -0
@@ -7,6 +7,7 @@/* Read mostly data used in network fast paths. */ struct net_hotdata {struct list_head offload_base; +struct list_head ptype_all;int gro_normal_batch;int netdev_budget;int netdev_budget_usecs;
net/core/dev.c +7 -9
@@ -161,7 +161,6 @@static DEFINE_SPINLOCK (ptype_lock);struct list_head ptype_base[PTYPE_HASH_SIZE ]__read_mostly ; -struct list_head ptype_all__read_mostly ;/* Taps */ static int netif_rx_internal (struct sk_buff *skb); static int call_netdevice_notifiers_extack(unsigned long val,
@@ -540,7 +539,7 @@ static inline void netdev_set_addr_lockdep_class(struct net_device *dev)static inline struct list_head *ptype_head (const struct packet_type *pt) {if (pt->type ==htons (ETH_P_ALL )) -return pt->dev ? &pt->dev->ptype_all : &ptype_all; +return pt->dev ? &pt->dev->ptype_all : &net_hotdata.ptype_all;else return pt->dev ? &pt->dev->ptype_specific : &ptype_base[ntohs (pt->type) &PTYPE_HASH_MASK ];
@@ -2226,7 +2225,8 @@ static inline bool skb_loop_sk(struct packet_type *ptype, struct sk_buff *skb)*/ bool dev_nit_active (struct net_device *dev) { -return !list_empty (&ptype_all) || !list_empty (&dev->ptype_all); +return !list_empty (&net_hotdata.ptype_all) || + !list_empty (&dev->ptype_all); }EXPORT_SYMBOL_GPL (dev_nit_active);
@@ -2237,10 +2237,9 @@ EXPORT_SYMBOL_GPL(dev_nit_active);void dev_queue_xmit_nit (struct sk_buff *skb,struct net_device *dev) { -struct packet_type *ptype; +struct list_head *ptype_list = &net_hotdata.ptype_all; +struct packet_type *ptype, *pt_prev =NULL ;struct sk_buff *skb2 =NULL ; -struct packet_type *pt_prev =NULL ; -struct list_head *ptype_list = &ptype_all;rcu_read_lock (); again:
@@ -2286,7 +2285,7 @@ void dev_queue_xmit_nit(struct sk_buff *skb, struct net_device *dev) pt_prev = ptype; } -if (ptype_list == &ptype_all) { +if (ptype_list == &net_hotdata.ptype_all) { ptype_list = &dev->ptype_all; goto again; }
@@ -5387,7 +5386,7 @@ static int __netif_receive_skb_core(struct sk_buff **pskb, bool pfmemalloc,if (pfmemalloc) goto skip_taps; -list_for_each_entry_rcu (ptype, &ptype_all, list) { +list_for_each_entry_rcu (ptype, &net_hotdata.ptype_all, list) {if (pt_prev) ret =deliver_skb (skb, pt_prev, orig_dev); pt_prev = ptype;
@@ -11771,7 +11770,6 @@ static int __init net_dev_init(void)if (netdev_kobject_init ()) goto out; -INIT_LIST_HEAD (&ptype_all);for (i =0 ; i <PTYPE_HASH_SIZE ; i++)INIT_LIST_HEAD (&ptype_base[i]);
net/core/hotdata.c +1 -0
@@ -7,6 +7,7 @@ struct net_hotdata net_hotdata __cacheline_aligned = { .offload_base =LIST_HEAD_INIT (net_hotdata.offload_base), + .ptype_all =LIST_HEAD_INIT (net_hotdata.ptype_all), .gro_normal_batch =8 , .netdev_budget =300 ,
net/core/net-procfs.c +4 -3
@@ -3,6 +3,7 @@#include <linux/proc_fs.h> #include <linux/seq_file.h> #include <net/wext.h> +#include <net/hotdata.h> #include "dev.h"
@@ -183,7 +184,7 @@ static void *ptype_get_idx(struct seq_file *seq, loff_t pos) } } -list_for_each_entry_rcu (pt, &ptype_all, list) { +list_for_each_entry_rcu (pt, &net_hotdata.ptype_all, list) {if (i == pos)return pt; ++i;
@@ -231,13 +232,13 @@ static void *ptype_seq_next(struct seq_file *seq, void *v, loff_t *pos) } } - nxt = ptype_all.next; + nxt = net_hotdata.ptype_all.next; goto ptype_all; }if (pt->type ==htons (ETH_P_ALL )) { ptype_all: -if (nxt != &ptype_all) +if (nxt != &net_hotdata.ptype_all) goto found; hash =0 ; nxt = ptype_base[0 ].next;
Signature · 1 line
2.44.0.278.ge034bb2e1d-goog
PATCH 5/18 net: move netdev_max_backlog to net_hotdata
In reply to Eric Dumazetnetdev_max_backlog is used in rx fat path.
Move it to net_hodata for better cache locality.
--- include/linux/netdevice.h | 1 - include/net/hotdata.h | 1 + net/core/dev.c | 8 +++----- net/core/gro_cells.c | 3 ++- net/core/hotdata.c | 2 ++ net/core/sysctl_net_core.c | 2 +- net/xfrm/espintcp.c | 4 +++- net/xfrm/xfrm_input.c | 3 ++- 8 files changed, 14 insertions(+), 10 deletions(-)
include/linux/netdevice.h +0 -1
@@ -4787,7 +4787,6 @@ void dev_fetch_sw_netstats(struct rtnl_link_stats64 *s, const struct pcpu_sw_netstats __percpu *netstats);void dev_get_tstats64 (struct net_device *dev,struct rtnl_link_stats64 *s); -extern int netdev_max_backlog;extern int dev_rx_weight;extern int dev_tx_weight;
include/net/hotdata.h +1 -0
@@ -12,6 +12,7 @@ struct net_hotdata {int netdev_budget;int netdev_budget_usecs;int tstamp_prequeue; +int max_backlog; };extern struct net_hotdata net_hotdata;
net/core/dev.c +3 -5
@@ -4404,9 +4404,6 @@ EXPORT_SYMBOL(__dev_direct_xmit);* Receiver routines *************************************************************************/ -int netdev_max_backlog__read_mostly =1000 ; -EXPORT_SYMBOL (netdev_max_backlog); -unsigned int sysctl_skb_defer_max__read_mostly =64 ;int weight_p__read_mostly =64 ;/* old backlog weight */ int dev_weight_rx_bias__read_mostly =1 ;/* bias for backlog weight */
@@ -4713,7 +4710,7 @@ static bool skb_flow_limit(struct sk_buff *skb, unsigned int qlen)struct softnet_data *sd;unsigned int old_flow, new_flow; -if (qlen < (READ_ONCE (netdev_max_backlog) >>1 )) +if (qlen < (READ_ONCE (net_hotdata.max_backlog) >>1 ))return false; sd =this_cpu_ptr (&softnet_data);
@@ -4761,7 +4758,8 @@ static int enqueue_to_backlog(struct sk_buff *skb, int cpu,if (!netif_running (skb->dev)) goto drop; qlen =skb_queue_len (&sd->input_pkt_queue); -if (qlen <=READ_ONCE (netdev_max_backlog) && !skb_flow_limit (skb, qlen)) { +if (qlen <=READ_ONCE (net_hotdata.max_backlog) && + !skb_flow_limit (skb, qlen)) {if (qlen) { enqueue:__skb_queue_tail (&sd->input_pkt_queue, skb);
net/core/gro_cells.c +2 -1
@@ -3,6 +3,7 @@#include <linux/slab.h> #include <linux/netdevice.h> #include <net/gro_cells.h> +#include <net/hotdata.h> struct gro_cell {struct sk_buff_head napi_skbs;
@@ -26,7 +27,7 @@ int gro_cells_receive(struct gro_cells *gcells, struct sk_buff *skb) cell =this_cpu_ptr (gcells->cells); -if (skb_queue_len (&cell->napi_skbs) >READ_ONCE (netdev_max_backlog)) { +if (skb_queue_len (&cell->napi_skbs) >READ_ONCE (net_hotdata.max_backlog)) { drop:dev_core_stats_rx_dropped_inc (dev);kfree_skb (skb);
net/core/hotdata.c +2 -0
@@ -15,4 +15,6 @@ struct net_hotdata net_hotdata __cacheline_aligned = { .netdev_budget_usecs = 2 * USEC_PER_SEC / HZ, .tstamp_prequeue = 1, + .max_backlog = 1000, }; +EXPORT_SYMBOL (net_hotdata);
net/core/sysctl_net_core.c +1 -1
@@ -440,7 +440,7 @@ static struct ctl_table net_core_table[] = { }, { .procname = "netdev_max_backlog", - .data = &netdev_max_backlog, + .data = &net_hotdata.max_backlog, .maxlen = sizeof(int), .mode =0644 , .proc_handler = proc_dointvec
net/xfrm/espintcp.c +3 -1
@@ -10,6 +10,7 @@#if IS_ENABLED (CONFIG_IPV6 )#include <net/ipv6_stubs.h> #endif +#include <net/hotdata.h> static void handle_nonesp (struct espintcp_ctx *ctx,struct sk_buff *skb,struct sock *sk)
@@ -169,7 +170,8 @@ int espintcp_queue_out(struct sock *sk, struct sk_buff *skb) {struct espintcp_ctx *ctx =espintcp_getctx (sk); -if (skb_queue_len (&ctx->out_queue) >=READ_ONCE (netdev_max_backlog)) +if (skb_queue_len (&ctx->out_queue) >= +READ_ONCE (net_hotdata.max_backlog))return -ENOBUFS ;__skb_queue_tail (&ctx->out_queue, skb);
net/xfrm/xfrm_input.c +2 -1
@@ -21,6 +21,7 @@#include <net/ip_tunnels.h> #include <net/ip6_tunnel.h> #include <net/dst_metadata.h> +#include <net/hotdata.h> #include "xfrm_inout.h"
@@ -764,7 +765,7 @@ int xfrm_trans_queue_net(struct net *net, struct sk_buff *skb, trans =this_cpu_ptr (&xfrm_trans_tasklet); -if (skb_queue_len (&trans->queue) >=READ_ONCE (netdev_max_backlog)) +if (skb_queue_len (&trans->queue) >=READ_ONCE (net_hotdata.max_backlog))return -ENOBUFS ;BUILD_BUG_ON (sizeof (struct xfrm_trans_cb ) >sizeof (skb->cb));
Signature · 1 line
2.44.0.278.ge034bb2e1d-goog
PATCH 6/18 net: move ip_packet_offload and ipv6_packet_offload to net_hotdata
In reply to Eric DumazetThese structures are used in GRO and GSO paths.
--- include/net/hotdata.h | 7 +++++++ net/ipv4/af_inet.c | 18 +++++++++--------- net/ipv6/ip6_offload.c | 18 +++++++++--------- 3 files changed, 25 insertions(+), 18 deletions(-)
include/net/hotdata.h +7 -0
@@ -3,9 +3,16 @@#define _NET_HOTDATA_H#include <linux/types.h> +#include <linux/netdevice.h> /* Read mostly data used in network fast paths. */ struct net_hotdata { +#if IS_ENABLED (CONFIG_INET ) +struct packet_offload ip_packet_offload; +#endif +#if IS_ENABLED (CONFIG_IPV6 ) +struct packet_offload ipv6_packet_offload; +#endif struct list_head offload_base;struct list_head ptype_all;int gro_normal_batch;
net/ipv4/af_inet.c +9 -9
@@ -1904,14 +1904,6 @@ static int ipv4_proc_init(void);* IP protocol layer initialiser */ -static struct packet_offload ip_packet_offload__read_mostly = { - .type =cpu_to_be16 (ETH_P_IP ), - .callbacks = { - .gso_segment = inet_gso_segment, - .gro_receive = inet_gro_receive, - .gro_complete = inet_gro_complete, - }, -};static const struct net_offload ipip_offload = { .callbacks = {
@@ -1938,7 +1930,15 @@ static int __init ipv4_offload_init(void)if (ipip_offload_init () <0 )pr_crit ("%s: Cannot add IPIP protocol offload\n" , __func__); -dev_add_offload (&ip_packet_offload); + net_hotdata.ip_packet_offload = (struct packet_offload ) { + .type =cpu_to_be16 (ETH_P_IP ), + .callbacks = { + .gso_segment = inet_gso_segment, + .gro_receive = inet_gro_receive, + .gro_complete = inet_gro_complete, + }, + }; +dev_add_offload (&net_hotdata.ip_packet_offload);return 0 ; }
net/ipv6/ip6_offload.c +9 -9
@@ -419,14 +419,6 @@ static int ip4ip6_gro_complete(struct sk_buff *skb, int nhoff)return inet_gro_complete (skb, nhoff); } -static struct packet_offload ipv6_packet_offload__read_mostly = { - .type =cpu_to_be16 (ETH_P_IPV6 ), - .callbacks = { - .gso_segment = ipv6_gso_segment, - .gro_receive = ipv6_gro_receive, - .gro_complete = ipv6_gro_complete, - }, -};static struct sk_buff *sit_gso_segment (struct sk_buff *skb,netdev_features_t features)
@@ -486,7 +478,15 @@ static int __init ipv6_offload_init(void)if (ipv6_exthdrs_offload_init () <0 )pr_crit ("%s: Cannot add EXTHDRS protocol offload\n" , __func__); -dev_add_offload (&ipv6_packet_offload); + net_hotdata.ipv6_packet_offload = (struct packet_offload ) { + .type =cpu_to_be16 (ETH_P_IPV6 ), + .callbacks = { + .gso_segment = ipv6_gso_segment, + .gro_receive = ipv6_gro_receive, + .gro_complete = ipv6_gro_complete, + }, + }; +dev_add_offload (&net_hotdata.ipv6_packet_offload);inet_add_offload (&sit_offload,IPPROTO_IPV6 );inet6_add_offload (&ip6ip6_offload,IPPROTO_IPV6 );
Signature · 1 line
2.44.0.278.ge034bb2e1d-goog
kernel test robot
build botRe: [PATCH net-next 06/18] net: move ip_packet_offload and ipv6_packet_offload to net_hotdata
kernel test robot noticed the following build errors:
Hi Eric,
kernel test robot noticed the following build errors:
[auto build test ERROR on net-next/main]
url: https://github.com/intel-lab-lkp/linux/commits/Eric-Dumazet/net-introduce-struct-net_hotdata/20240306-001407 base: net-next/main patch link: https://lore.kernel.org/r/20240305160413.2231423-7-edumazet%40google.com patch subject: [PATCH net-next 06/18] net: move ip_packet_offload and ipv6_packet_offload to net_hotdata config: hexagon-defconfig (https://download.01.org/0day-ci/archive/20240306/[email protected]/config) compiler: clang version 19.0.0git (https://github.com/llvm/llvm-project 325f51237252e6dab8e4e1ea1fa7acbb4faee1cd) reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20240306/[email protected]/reproduce)
If you fix the issue in a separate patch/commit (i.e. not just a new version of the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <[email protected]>
| Closes: https://lore.kernel.org/oe-kbuild-all/[email protected]/
All errors (new ones prefixed by >>):
In file included from include/linux/highmem.h:12:
In file included from include/linux/hardirq.h:11:
In file included from ./arch/hexagon/include/generated/asm/hardirq.h:1:
In file included from include/asm-generic/hardirq.h:17:
In file included from include/linux/irq.h:20:
In file included from include/linux/io.h:13:
In file included from arch/hexagon/include/asm/io.h:328:
include/asm-generic/io.h:573:61: warning: performing pointer arithmetic on a null pointer has undefined behavior [-Wnull-pointer-arithmetic]
573 | val = __le32_to_cpu((__le32 __force)__raw_readl(PCI_IOBASE + addr));
| ~~~~~~~~~~ ^
include/uapi/linux/byteorder/little_endian.h:35:51: note: expanded from macro '__le32_to_cpu'
35 | #define __le32_to_cpu(x) ((__force __u32)(__le32)(x))
| ^
In file included from net/ipv6/ip6_offload.c:9:
In file included from include/linux/netdevice.h:38:
In file included from include/net/net_namespace.h:43:
In file included from include/linux/skbuff.h:17:
In file included from include/linux/bvec.h:10:
In file included from include/linux/highmem.h:12:
In file included from include/linux/hardirq.h:11:
In file included from ./arch/hexagon/include/generated/asm/hardirq.h:1:
In file included from include/asm-generic/hardirq.h:17:
In file included from include/linux/irq.h:20:
In file included from include/linux/io.h:13:
In file included from arch/hexagon/include/asm/io.h:328:
include/asm-generic/io.h:584:33: warning: performing pointer arithmetic on a null pointer has undefined behavior [-Wnull-pointer-arithmetic]
584 | __raw_writeb(value, PCI_IOBASE + addr);
| ~~~~~~~~~~ ^
include/asm-generic/io.h:594:59: warning: performing pointer arithmetic on a null pointer has undefined behavior [-Wnull-pointer-arithmetic]
594 | __raw_writew((u16 __force)cpu_to_le16(value), PCI_IOBASE + addr);
| ~~~~~~~~~~ ^
include/asm-generic/io.h:604:59: warning: performing pointer arithmetic on a null pointer has undefined behavior [-Wnull-pointer-arithmetic]
604 | __raw_writel((u32 __force)cpu_to_le32(value), PCI_IOBASE + addr);
| ~~~~~~~~~~ ^
In file included from net/ipv6/ip6_offload.c:9:
In file included from include/linux/netdevice.h:45:
In file included from include/uapi/linux/neighbour.h:6:
In file included from include/linux/netlink.h:9:
In file included from include/net/scm.h:9:
In file included from include/linux/security.h:35:
include/linux/bpf.h:736:48: warning: bitwise operation between different enumeration types ('enum bpf_type_flag' and 'enum bpf_arg_type') [-Wenum-enum-conversion]
736 | ARG_PTR_TO_MAP_VALUE_OR_NULL = PTR_MAYBE_NULL | ARG_PTR_TO_MAP_VALUE,
| ~~~~~~~~~~~~~~ ^ ~~~~~~~~~~~~~~~~~~~~
include/linux/bpf.h:737:43: warning: bitwise operation between different enumeration types ('enum bpf_type_flag' and 'enum bpf_arg_type') [-Wenum-enum-conversion]
737 | ARG_PTR_TO_MEM_OR_NULL = PTR_MAYBE_NULL | ARG_PTR_TO_MEM,
| ~~~~~~~~~~~~~~ ^ ~~~~~~~~~~~~~~
include/linux/bpf.h:738:43: warning: bitwise operation between different enumeration types ('enum bpf_type_flag' and 'enum bpf_arg_type') [-Wenum-enum-conversion]
738 | ARG_PTR_TO_CTX_OR_NULL = PTR_MAYBE_NULL | ARG_PTR_TO_CTX,
| ~~~~~~~~~~~~~~ ^ ~~~~~~~~~~~~~~
include/linux/bpf.h:739:45: warning: bitwise operation between different enumeration types ('enum bpf_type_flag' and 'enum bpf_arg_type') [-Wenum-enum-conversion]
739 | ARG_PTR_TO_SOCKET_OR_NULL = PTR_MAYBE_NULL | ARG_PTR_TO_SOCKET,
| ~~~~~~~~~~~~~~ ^ ~~~~~~~~~~~~~~~~~
include/linux/bpf.h:740:44: warning: bitwise operation between different enumeration types ('enum bpf_type_flag' and 'enum bpf_arg_type') [-Wenum-enum-conversion]
740 | ARG_PTR_TO_STACK_OR_NULL = PTR_MAYBE_NULL | ARG_PTR_TO_STACK,
| ~~~~~~~~~~~~~~ ^ ~~~~~~~~~~~~~~~~
include/linux/bpf.h:741:45: warning: bitwise operation between different enumeration types ('enum bpf_type_flag' and 'enum bpf_arg_type') [-Wenum-enum-conversion]
741 | ARG_PTR_TO_BTF_ID_OR_NULL = PTR_MAYBE_NULL | ARG_PTR_TO_BTF_ID,
| ~~~~~~~~~~~~~~ ^ ~~~~~~~~~~~~~~~~~
include/linux/bpf.h:745:38: warning: bitwise operation between different enumeration types ('enum bpf_type_flag' and 'enum bpf_arg_type') [-Wenum-enum-conversion]
745 | ARG_PTR_TO_UNINIT_MEM = MEM_UNINIT | ARG_PTR_TO_MEM,
| ~~~~~~~~~~ ^ ~~~~~~~~~~~~~~
include/linux/bpf.h:747:45: warning: bitwise operation between different enumeration types ('enum bpf_type_flag' and 'enum bpf_arg_type') [-Wenum-enum-conversion]
747 | ARG_PTR_TO_FIXED_SIZE_MEM = MEM_FIXED_SIZE | ARG_PTR_TO_MEM,
| ~~~~~~~~~~~~~~ ^ ~~~~~~~~~~~~~~
include/linux/bpf.h:770:48: warning: bitwise operation between different enumeration types ('enum bpf_type_flag' and 'enum bpf_return_type') [-Wenum-enum-conversion]
770 | RET_PTR_TO_MAP_VALUE_OR_NULL = PTR_MAYBE_NULL | RET_PTR_TO_MAP_VALUE,
| ~~~~~~~~~~~~~~ ^ ~~~~~~~~~~~~~~~~~~~~
include/linux/bpf.h:771:45: warning: bitwise operation between different enumeration types ('enum bpf_type_flag' and 'enum bpf_return_type') [-Wenum-enum-conversion]
771 | RET_PTR_TO_SOCKET_OR_NULL = PTR_MAYBE_NULL | RET_PTR_TO_SOCKET,
| ~~~~~~~~~~~~~~ ^ ~~~~~~~~~~~~~~~~~
include/linux/bpf.h:772:47: warning: bitwise operation between different enumeration types ('enum bpf_type_flag' and 'enum bpf_return_type') [-Wenum-enum-conversion]
772 | RET_PTR_TO_TCP_SOCK_OR_NULL = PTR_MAYBE_NULL | RET_PTR_TO_TCP_SOCK,
| ~~~~~~~~~~~~~~ ^ ~~~~~~~~~~~~~~~~~~~
include/linux/bpf.h:773:50: warning: bitwise operation between different enumeration types ('enum bpf_type_flag' and 'enum bpf_return_type') [-Wenum-enum-conversion]
773 | RET_PTR_TO_SOCK_COMMON_OR_NULL = PTR_MAYBE_NULL | RET_PTR_TO_SOCK_COMMON,
| ~~~~~~~~~~~~~~ ^ ~~~~~~~~~~~~~~~~~~~~~~
include/linux/bpf.h:775:49: warning: bitwise operation between different enumeration types ('enum bpf_type_flag' and 'enum bpf_return_type') [-Wenum-enum-conversion]
775 | RET_PTR_TO_DYNPTR_MEM_OR_NULL = PTR_MAYBE_NULL | RET_PTR_TO_MEM,
| ~~~~~~~~~~~~~~ ^ ~~~~~~~~~~~~~~
include/linux/bpf.h:776:45: warning: bitwise operation between different enumeration types ('enum bpf_type_flag' and 'enum bpf_return_type') [-Wenum-enum-conversion]
776 | RET_PTR_TO_BTF_ID_OR_NULL = PTR_MAYBE_NULL | RET_PTR_TO_BTF_ID,
| ~~~~~~~~~~~~~~ ^ ~~~~~~~~~~~~~~~~~
include/linux/bpf.h:777:43: warning: bitwise operation between different enumeration types ('enum bpf_type_flag' and 'enum bpf_return_type') [-Wenum-enum-conversion]
777 | RET_PTR_TO_BTF_ID_TRUSTED = PTR_TRUSTED | RET_PTR_TO_BTF_ID,
| ~~~~~~~~~~~ ^ ~~~~~~~~~~~~~~~~~
include/linux/bpf.h:888:44: warning: bitwise operation between different enumeration types ('enum bpf_type_flag' and 'enum bpf_reg_type') [-Wenum-enum-conversion]
888 | PTR_TO_MAP_VALUE_OR_NULL = PTR_MAYBE_NULL | PTR_TO_MAP_VALUE,
| ~~~~~~~~~~~~~~ ^ ~~~~~~~~~~~~~~~~
include/linux/bpf.h:889:42: warning: bitwise operation between different enumeration types ('enum bpf_type_flag' and 'enum bpf_reg_type') [-Wenum-enum-conversion]
889 | PTR_TO_SOCKET_OR_NULL = PTR_MAYBE_NULL | PTR_TO_SOCKET,
| ~~~~~~~~~~~~~~ ^ ~~~~~~~~~~~~~
include/linux/bpf.h:890:46: warning: bitwise operation between different enumeration types ('enum bpf_type_flag' and 'enum bpf_reg_type') [-Wenum-enum-conversion]
890 | PTR_TO_SOCK_COMMON_OR_NULL = PTR_MAYBE_NULL | PTR_TO_SOCK_COMMON,
| ~~~~~~~~~~~~~~ ^ ~~~~~~~~~~~~~~~~~~
include/linux/bpf.h:891:44: warning: bitwise operation between different enumeration types ('enum bpf_type_flag' and 'enum bpf_reg_type') [-Wenum-enum-conversion]
891 | PTR_TO_TCP_SOCK_OR_NULL = PTR_MAYBE_NULL | PTR_TO_TCP_SOCK,
| ~~~~~~~~~~~~~~ ^ ~~~~~~~~~~~~~~~
include/linux/bpf.h:892:42: warning: bitwise operation between different enumeration types ('enum bpf_type_flag' and 'enum bpf_reg_type') [-Wenum-enum-conversion]
892 | PTR_TO_BTF_ID_OR_NULL = PTR_MAYBE_NULL | PTR_TO_BTF_ID,
| ~~~~~~~~~~~~~~ ^ ~~~~~~~~~~~~~
>> net/ipv6/ip6_offload.c:481:14: error: no member named 'ipv6_packet_offload' in 'struct net_hotdata'; did you mean 'ip_packet_offload'?
481 | net_hotdata.ipv6_packet_offload = (struct packet_offload) {
| ^~~~~~~~~~~~~~~~~~~
| ip_packet_offload
include/net/hotdata.h:11:24: note: 'ip_packet_offload' declared here
11 | struct packet_offload ip_packet_offload;
| ^
net/ipv6/ip6_offload.c:489:31: error: no member named 'ipv6_packet_offload' in 'struct net_hotdata'; did you mean 'ip_packet_offload'?
489 | dev_add_offload(&net_hotdata.ipv6_packet_offload);
| ^~~~~~~~~~~~~~~~~~~
| ip_packet_offload
include/net/hotdata.h:11:24: note: 'ip_packet_offload' declared here
11 | struct packet_offload ip_packet_offload;
| ^27 warnings and 2 errors generated.
vim +481 net/ipv6/ip6_offload.c
475
476 if (tcpv6_offload_init() < 0)
477 pr_crit("%s: Cannot add TCP protocol offload\n", __func__);
478 if (ipv6_exthdrs_offload_init() < 0)
479 pr_crit("%s: Cannot add EXTHDRS protocol offload\n", __func__);
480
> 481 net_hotdata.ipv6_packet_offload = (struct packet_offload) { 482 .type = cpu_to_be16(ETH_P_IPV6),
483 .callbacks = {
484 .gso_segment = ipv6_gso_segment,
485 .gro_receive = ipv6_gro_receive,
486 .gro_complete = ipv6_gro_complete,
487 },
488 };
489 dev_add_offload(&net_hotdata.ipv6_packet_offload);
490
491 inet_add_offload(&sit_offload, IPPROTO_IPV6);
492 inet6_add_offload(&ip6ip6_offload, IPPROTO_IPV6);
493 inet6_add_offload(&ip4ip6_offload, IPPROTO_IPIP);
494
495 return 0;
496 }
497
Signature · 2 lines
0-DAY CI Kernel Test Service https://github.com/intel/lkp-tests/wiki
Re: [PATCH net-next 06/18] net: move ip_packet_offload and ipv6_packet_offload to net_hotdata
Quoted 15 lines · kernel test robot
Hi Eric,
kernel test robot noticed the following build errors:
[auto build test ERROR on net-next/main]
url: https://github.com/intel-lab-lkp/linux/commits/Eric-Dumazet/net-introduce-struct-net_hotdata/20240306-001407 base: net-next/main patch link: https://lore.kernel.org/r/20240305160413.2231423-7-edumazet%40google.com patch subject: [PATCH net-next 06/18] net: move ip_packet_offload and ipv6_packet_offload to net_hotdata config: hexagon-defconfig (https://download.01.org/0day-ci/archive/20240306/[email protected]/config) compiler: clang version 19.0.0git (https://github.com/llvm/llvm-project 325f51237252e6dab8e4e1ea1fa7acbb4faee1cd) reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20240306/[email protected]/reproduce)
Quoted 4 lines
If you fix the issue in a separate patch/commit (i.e. not just a new version of the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <[email protected]>
| Closes: https://lore.kernel.org/oe-kbuild-all/[email protected]/
Right, all the offloads need to be there if CONFIG_INET=y, regardless of CONFIG_IPV6
I will in v2 have changes so that the cumulative diff is :
include/net/hotdata.h +0 -0
100644
include/net/hotdata.h +3 -3
@@ -14,13 +14,13 @@ struct net_hotdata {struct net_protocol tcp_protocol;struct net_offload udpv4_offload;struct net_protocol udp_protocol; -#endif -#if IS_ENABLED (CONFIG_IPV6 )struct packet_offload ipv6_packet_offload;struct net_offload tcpv6_offload; +#if defined (CONFIG_IPV6 )struct inet6_protocol tcpv6_protocol; -struct net_offload udpv6_offload;struct inet6_protocol udpv6_protocol; +#endif +struct net_offload udpv6_offload;#endif struct list_head offload_base;struct list_head ptype_all;
PATCH 7/18 net: move tcpv4_offload and tcpv6_offload to net_hotdata
In reply to Eric DumazetThese are used in TCP fast paths.
Move them into net_hotdata for better cache locality.
--- include/net/hotdata.h | 3 +++ net/ipv4/tcp_offload.c | 17 ++++++++--------- net/ipv6/tcpv6_offload.c | 16 ++++++++-------- 3 files changed, 19 insertions(+), 17 deletions(-)
include/net/hotdata.h +3 -0
@@ -4,14 +4,17 @@#include <linux/types.h> #include <linux/netdevice.h> +#include <net/protocol.h> /* Read mostly data used in network fast paths. */ struct net_hotdata {#if IS_ENABLED (CONFIG_INET )struct packet_offload ip_packet_offload; +struct net_offload tcpv4_offload;#endif #if IS_ENABLED (CONFIG_IPV6 )struct packet_offload ipv6_packet_offload; +struct net_offload tcpv6_offload;#endif struct list_head offload_base;struct list_head ptype_all;
net/ipv4/tcp_offload.c +8 -9
@@ -345,15 +345,14 @@ INDIRECT_CALLABLE_SCOPE int tcp4_gro_complete(struct sk_buff *skb, int thoff)return 0 ; } -static const struct net_offload tcpv4_offload = { - .callbacks = { - .gso_segment = tcp4_gso_segment, - .gro_receive = tcp4_gro_receive, - .gro_complete = tcp4_gro_complete, - }, -}; -int __init tcpv4_offload_init (void ) { -return inet_add_offload (&tcpv4_offload,IPPROTO_TCP ); + net_hotdata.tcpv4_offload = (struct net_offload ) { + .callbacks = { + .gso_segment = tcp4_gso_segment, + .gro_receive = tcp4_gro_receive, + .gro_complete = tcp4_gro_complete, + }, + }; +return inet_add_offload (&net_hotdata.tcpv4_offload,IPPROTO_TCP ); }
net/ipv6/tcpv6_offload.c +8 -8
@@ -66,15 +66,15 @@ static struct sk_buff *tcp6_gso_segment(struct sk_buff *skb,return tcp_gso_segment (skb, features); } -static const struct net_offload tcpv6_offload = { - .callbacks = { - .gso_segment = tcp6_gso_segment, - .gro_receive = tcp6_gro_receive, - .gro_complete = tcp6_gro_complete, - }, -};int __init tcpv6_offload_init (void ) { -return inet6_add_offload (&tcpv6_offload,IPPROTO_TCP ); + net_hotdata.tcpv6_offload = (struct net_offload ) { + .callbacks = { + .gso_segment = tcp6_gso_segment, + .gro_receive = tcp6_gro_receive, + .gro_complete = tcp6_gro_complete, + }, + }; +return inet6_add_offload (&net_hotdata.tcpv6_offload,IPPROTO_TCP ); }
Signature · 1 line
2.44.0.278.ge034bb2e1d-goog
PATCH 8/18 net: move dev_tx_weight to net_hotdata
In reply to Eric Dumazetdev_tx_weight is used in tx fast path.
Move it to net_hotdata for better cache locality.
--- include/linux/netdevice.h | 1 - include/net/hotdata.h | 1 + net/core/dev.c | 1 - net/core/hotdata.c | 1 + net/core/sysctl_net_core.c | 2 +- net/sched/sch_generic.c | 3 ++- 6 files changed, 5 insertions(+), 4 deletions(-)
include/linux/netdevice.h +0 -1
@@ -4788,7 +4788,6 @@ void dev_fetch_sw_netstats(struct rtnl_link_stats64 *s,void dev_get_tstats64 (struct net_device *dev,struct rtnl_link_stats64 *s);extern int dev_rx_weight; -extern int dev_tx_weight;enum {NESTED_SYNC_IMM_BIT ,
include/net/hotdata.h +1 -0
@@ -23,6 +23,7 @@ struct net_hotdata {int netdev_budget_usecs;int tstamp_prequeue;int max_backlog; +int dev_tx_weight; };extern struct net_hotdata net_hotdata;
net/core/dev.c +0 -1
@@ -4409,7 +4409,6 @@ int weight_p __read_mostly = 64; /* old backlog weight */int dev_weight_rx_bias__read_mostly =1 ;/* bias for backlog weight */ int dev_weight_tx_bias__read_mostly =1 ;/* bias for output_queue quota */ int dev_rx_weight__read_mostly =64 ; -int dev_tx_weight__read_mostly =64 ;/* Called with irq disabled */ static inline void ____napi_schedule(struct softnet_data *sd,
net/core/hotdata.c +1 -0
@@ -16,5 +16,6 @@ struct net_hotdata net_hotdata __cacheline_aligned = { .tstamp_prequeue = 1, .max_backlog = 1000, + .dev_tx_weight = 64, };EXPORT_SYMBOL (net_hotdata);
net/core/sysctl_net_core.c +1 -1
@@ -302,7 +302,7 @@ static int proc_do_dev_weight(struct ctl_table *table, int write,if (!ret && write) { weight =READ_ONCE (weight_p);WRITE_ONCE (dev_rx_weight, weight * dev_weight_rx_bias); -WRITE_ONCE (dev_tx_weight, weight * dev_weight_tx_bias); +WRITE_ONCE (net_hotdata.dev_tx_weight, weight * dev_weight_tx_bias); }mutex_unlock (&dev_weight_mutex);
net/sched/sch_generic.c +2 -1
@@ -27,6 +27,7 @@#include <net/sch_generic.h> #include <net/pkt_sched.h> #include <net/dst.h> +#include <net/hotdata.h> #include <trace/events/qdisc.h> #include <trace/events/net.h> #include <net/xfrm.h>
@@ -409,7 +410,7 @@ static inline bool qdisc_restart(struct Qdisc *q, int *packets)void __qdisc_run (struct Qdisc *q) { -int quota =READ_ONCE (dev_tx_weight); +int quota =READ_ONCE (net_hotdata.dev_tx_weight);int packets;while (qdisc_restart (q, &packets)) {
Signature · 1 line
2.44.0.278.ge034bb2e1d-goog
PATCH 9/18 net: move dev_rx_weight to net_hotdata
In reply to Eric Dumazetdev_rx_weight is read from process_backlog().
Move it to net_hotdata for better cache locality.
--- include/linux/netdevice.h | 2 -- include/net/hotdata.h | 1 + net/core/dev.c | 3 +-- net/core/hotdata.c | 1 + net/core/sysctl_net_core.c | 2 +- 5 files changed, 4 insertions(+), 5 deletions(-)
include/linux/netdevice.h +0 -2
@@ -4787,8 +4787,6 @@ void dev_fetch_sw_netstats(struct rtnl_link_stats64 *s, const struct pcpu_sw_netstats __percpu *netstats);void dev_get_tstats64 (struct net_device *dev,struct rtnl_link_stats64 *s); -extern int dev_rx_weight; -enum {NESTED_SYNC_IMM_BIT ,NESTED_SYNC_TODO_BIT ,
include/net/hotdata.h +1 -0
@@ -24,6 +24,7 @@ struct net_hotdata {int tstamp_prequeue;int max_backlog;int dev_tx_weight; +int dev_rx_weight; };extern struct net_hotdata net_hotdata;
net/core/dev.c +1 -2
@@ -4408,7 +4408,6 @@ unsigned int sysctl_skb_defer_max __read_mostly = 64;int weight_p__read_mostly =64 ;/* old backlog weight */ int dev_weight_rx_bias__read_mostly =1 ;/* bias for backlog weight */ int dev_weight_tx_bias__read_mostly =1 ;/* bias for output_queue quota */ -int dev_rx_weight__read_mostly =64 ;/* Called with irq disabled */ static inline void ____napi_schedule(struct softnet_data *sd,
@@ -5978,7 +5977,7 @@ static int process_backlog(struct napi_struct *napi, int quota)net_rps_action_and_irq_enable (sd); } - napi->weight =READ_ONCE (dev_rx_weight); + napi->weight =READ_ONCE (net_hotdata.dev_rx_weight);while (again) {struct sk_buff *skb;
net/core/hotdata.c +1 -0
@@ -17,5 +17,6 @@ struct net_hotdata net_hotdata __cacheline_aligned = { .tstamp_prequeue = 1, .max_backlog = 1000, .dev_tx_weight = 64, + .dev_rx_weight = 64, };EXPORT_SYMBOL (net_hotdata);
net/core/sysctl_net_core.c +1 -1
@@ -301,7 +301,7 @@ static int proc_do_dev_weight(struct ctl_table *table, int write, ret =proc_dointvec (table, write, buffer, lenp, ppos);if (!ret && write) { weight =READ_ONCE (weight_p); -WRITE_ONCE (dev_rx_weight, weight * dev_weight_rx_bias); +WRITE_ONCE (net_hotdata.dev_rx_weight, weight * dev_weight_rx_bias);WRITE_ONCE (net_hotdata.dev_tx_weight, weight * dev_weight_tx_bias); }mutex_unlock (&dev_weight_mutex);
Signature · 1 line
2.44.0.278.ge034bb2e1d-goog
PATCH 10/18 net: move skbuff_cache(s) to net_hotdata
In reply to Eric Dumazetskbuff_cache, skbuff_fclone_cache and skb_small_head_cache are used in rx/tx fast paths.
Move them to net_hotdata for better cache locality.
--- include/linux/skbuff.h | 1 - include/net/hotdata.h | 3 +++ kernel/bpf/cpumap.c | 4 +++- net/bpf/test_run.c | 4 +++- net/core/skbuff.c | 44 +++++++++++++++++++----------------------- net/core/xdp.c | 5 +++-- 6 files changed, 32 insertions(+), 29 deletions(-)
include/linux/skbuff.h +0 -1
@@ -1271,7 +1271,6 @@ static inline void consume_skb(struct sk_buff *skb)void __consume_stateless_skb (struct sk_buff *skb);void __kfree_skb (struct sk_buff *skb); -extern struct kmem_cache *skbuff_cache;void kfree_skb_partial (struct sk_buff *skb,bool head_stolen); bool skb_try_coalesce(struct sk_buff *to, struct sk_buff *from,
include/net/hotdata.h +3 -0
@@ -18,6 +18,9 @@ struct net_hotdata {#endif struct list_head offload_base;struct list_head ptype_all; +struct kmem_cache *skbuff_cache; +struct kmem_cache *skbuff_fclone_cache; +struct kmem_cache *skb_small_head_cache;int gro_normal_batch;int netdev_budget;int netdev_budget_usecs;
kernel/bpf/cpumap.c +3 -1
@@ -24,6 +24,7 @@#include <linux/filter.h> #include <linux/ptr_ring.h> #include <net/xdp.h> +#include <net/hotdata.h> #include <linux/sched.h> #include <linux/workqueue.h>
@@ -326,7 +327,8 @@ static int cpu_map_kthread_run(void *data)/* Support running another XDP prog on this CPU */ nframes =cpu_map_bpf_prog_run (rcpu, frames, xdp_n, &stats, &list);if (nframes) { - m =kmem_cache_alloc_bulk (skbuff_cache, gfp, nframes, skbs); + m =kmem_cache_alloc_bulk (net_hotdata.skbuff_cache, + gfp, nframes, skbs);if (unlikely (m ==0 )) {for (i =0 ; i < nframes; i++) skbs[i] =NULL ;/* effect: xdp_return_frame */
net/bpf/test_run.c +3 -1
@@ -12,6 +12,7 @@#include <linux/rcupdate_trace.h> #include <linux/sched/signal.h> #include <net/bpf_sk_storage.h> +#include <net/hotdata.h> #include <net/sock.h> #include <net/tcp.h> #include <net/net_namespace.h>
@@ -254,7 +255,8 @@ static int xdp_recv_frames(struct xdp_frame **frames, int nframes,int i, n;LIST_HEAD (list); - n =kmem_cache_alloc_bulk (skbuff_cache, gfp, nframes, (void **)skbs); + n =kmem_cache_alloc_bulk (net_hotdata.skbuff_cache, gfp, nframes, + (void **)skbs);if (unlikely (n ==0 )) {for (i =0 ; i < nframes; i++)xdp_return_frame (frames[i]);
net/core/skbuff.c +20 -24
169 lines not on this page · raw message
net/core/xdp.c +3 -2
@@ -16,6 +16,7 @@#include <linux/bug.h> #include <net/page_pool/helpers.h> +#include <net/hotdata.h> #include <net/xdp.h> #include <net/xdp_priv.h> /* struct xdp_mem_allocator */ #include <trace/events/xdp.h>
@@ -589,7 +590,7 @@ EXPORT_SYMBOL_GPL(xdp_warn);int xdp_alloc_skb_bulk (void **skbs,int n_skb,gfp_t gfp) { - n_skb =kmem_cache_alloc_bulk (skbuff_cache, gfp, n_skb, skbs); + n_skb =kmem_cache_alloc_bulk (net_hotdata.skbuff_cache, gfp, n_skb, skbs);if (unlikely (!n_skb))return -ENOMEM ;
@@ -658,7 +659,7 @@ struct sk_buff *xdp_build_skb_from_frame(struct xdp_frame *xdpf, {struct sk_buff *skb; - skb =kmem_cache_alloc (skbuff_cache,GFP_ATOMIC ); + skb =kmem_cache_alloc (net_hotdata.skbuff_cache,GFP_ATOMIC );if (unlikely (!skb))return NULL ;
Signature · 1 line
2.44.0.278.ge034bb2e1d-goog
PATCH 11/18 udp: move udpv4_offload and udpv6_offload to net_hotdata
In reply to Eric DumazetThese structures are used in GRO and GSO paths. Move them to net_hodata for better cache locality.
--- include/net/hotdata.h | 2 ++ net/ipv4/udp_offload.c | 17 ++++++++--------- net/ipv6/udp_offload.c | 21 ++++++++++----------- 3 files changed, 20 insertions(+), 20 deletions(-)
include/net/hotdata.h +2 -0
@@ -11,10 +11,12 @@ struct net_hotdata {#if IS_ENABLED (CONFIG_INET )struct packet_offload ip_packet_offload;struct net_offload tcpv4_offload; +struct net_offload udpv4_offload;#endif #if IS_ENABLED (CONFIG_IPV6 )struct packet_offload ipv6_packet_offload;struct net_offload tcpv6_offload; +struct net_offload udpv6_offload;#endif struct list_head offload_base;struct list_head ptype_all;
net/ipv4/udp_offload.c +8 -9
@@ -737,15 +737,14 @@ INDIRECT_CALLABLE_SCOPE int udp4_gro_complete(struct sk_buff *skb, int nhoff)return udp_gro_complete (skb, nhoff, udp4_lib_lookup_skb); } -static const struct net_offload udpv4_offload = { - .callbacks = { - .gso_segment = udp4_ufo_fragment, - .gro_receive = udp4_gro_receive, - .gro_complete = udp4_gro_complete, - }, -}; -int __init udpv4_offload_init (void ) { -return inet_add_offload (&udpv4_offload,IPPROTO_UDP ); + net_hotdata.udpv4_offload = (struct net_offload ) { + .callbacks = { + .gso_segment = udp4_ufo_fragment, + .gro_receive = udp4_gro_receive, + .gro_complete = udp4_gro_complete, + }, + }; +return inet_add_offload (&net_hotdata.udpv4_offload,IPPROTO_UDP ); }
net/ipv6/udp_offload.c +10 -11
@@ -192,20 +192,19 @@ INDIRECT_CALLABLE_SCOPE int udp6_gro_complete(struct sk_buff *skb, int nhoff)return udp_gro_complete (skb, nhoff, udp6_lib_lookup_skb); } -static const struct net_offload udpv6_offload = { - .callbacks = { - .gso_segment = udp6_ufo_fragment, - .gro_receive = udp6_gro_receive, - .gro_complete = udp6_gro_complete, - }, -}; - -int udpv6_offload_init (void ) +int __init udpv6_offload_init (void ) { -return inet6_add_offload (&udpv6_offload,IPPROTO_UDP ); + net_hotdata.udpv6_offload = (struct net_offload ) { + .callbacks = { + .gso_segment = udp6_ufo_fragment, + .gro_receive = udp6_gro_receive, + .gro_complete = udp6_gro_complete, + }, + }; +return inet6_add_offload (&net_hotdata.udpv6_offload,IPPROTO_UDP ); }int udpv6_offload_exit (void ) { -return inet6_del_offload (&udpv6_offload,IPPROTO_UDP ); +return inet6_del_offload (&net_hotdata.udpv6_offload,IPPROTO_UDP ); }
Signature · 1 line
2.44.0.278.ge034bb2e1d-goog
PATCH 12/18 ipv6: move tcpv6_protocol and udpv6_protocol to net_hotdata
In reply to Eric DumazetThese structures are read in rx path, move them to net_hotdata for better cache locality.
--- include/net/hotdata.h | 2 ++ net/ipv6/tcp_ipv6.c | 17 +++++++++-------- net/ipv6/udp.c | 16 ++++++++-------- 3 files changed, 19 insertions(+), 16 deletions(-)
include/net/hotdata.h +2 -0
@@ -16,7 +16,9 @@ struct net_hotdata {#if IS_ENABLED (CONFIG_IPV6 )struct packet_offload ipv6_packet_offload;struct net_offload tcpv6_offload; +struct inet6_protocol tcpv6_protocol;struct net_offload udpv6_offload; +struct inet6_protocol udpv6_protocol;#endif struct list_head offload_base;struct list_head ptype_all;
net/ipv6/tcp_ipv6.c +9 -8
@@ -58,6 +58,7 @@#include <net/timewait_sock.h> #include <net/inet_common.h> #include <net/secure_seq.h> +#include <net/hotdata.h> #include <net/busy_poll.h> #include <linux/proc_fs.h>
@@ -2367,11 +2368,6 @@ struct proto tcpv6_prot = { };EXPORT_SYMBOL_GPL (tcpv6_prot); -static const struct inet6_protocol tcpv6_protocol = { - .handler = tcp_v6_rcv, - .err_handler = tcp_v6_err, - .flags =INET6_PROTO_NOPOLICY |INET6_PROTO_FINAL , -};static struct inet_protosw tcpv6_protosw = { .type =SOCK_STREAM ,
@@ -2408,7 +2404,12 @@ int __init tcpv6_init(void) {int ret; - ret =inet6_add_protocol (&tcpv6_protocol,IPPROTO_TCP ); + net_hotdata.tcpv6_protocol = (struct inet6_protocol ) { + .handler = tcp_v6_rcv, + .err_handler = tcp_v6_err, + .flags =INET6_PROTO_NOPOLICY |INET6_PROTO_FINAL , + }; + ret =inet6_add_protocol (&net_hotdata.tcpv6_protocol,IPPROTO_TCP );if (ret) goto out;
@@ -2433,7 +2434,7 @@ int __init tcpv6_init(void) out_tcpv6_protosw:inet6_unregister_protosw (&tcpv6_protosw); out_tcpv6_protocol: -inet6_del_protocol (&tcpv6_protocol,IPPROTO_TCP ); +inet6_del_protocol (&net_hotdata.tcpv6_protocol,IPPROTO_TCP ); goto out; }
@@ -2441,5 +2442,5 @@ void tcpv6_exit(void) {unregister_pernet_subsys (&tcpv6_net_ops);inet6_unregister_protosw (&tcpv6_protosw); -inet6_del_protocol (&tcpv6_protocol,IPPROTO_TCP ); +inet6_del_protocol (&net_hotdata.tcpv6_protocol,IPPROTO_TCP ); }
net/ipv6/udp.c +8 -8
@@ -1702,11 +1702,6 @@ int udpv6_getsockopt(struct sock *sk, int level, int optname,return ipv6_getsockopt (sk, level, optname, optval, optlen); } -static const struct inet6_protocol udpv6_protocol = { - .handler = udpv6_rcv, - .err_handler = udpv6_err, - .flags =INET6_PROTO_NOPOLICY |INET6_PROTO_FINAL , -};/* ------------------------------------------------------------------------ */ #ifdef CONFIG_PROC_FS
@@ -1803,7 +1798,12 @@ int __init udpv6_init(void) {int ret; - ret =inet6_add_protocol (&udpv6_protocol,IPPROTO_UDP ); + net_hotdata.udpv6_protocol = (struct inet6_protocol ) { + .handler = udpv6_rcv, + .err_handler = udpv6_err, + .flags =INET6_PROTO_NOPOLICY |INET6_PROTO_FINAL , + }; + ret =inet6_add_protocol (&net_hotdata.udpv6_protocol,IPPROTO_UDP );if (ret) goto out;
@@ -1814,12 +1814,12 @@ int __init udpv6_init(void)return ret; out_udpv6_protocol: -inet6_del_protocol (&udpv6_protocol,IPPROTO_UDP ); +inet6_del_protocol (&net_hotdata.udpv6_protocol,IPPROTO_UDP ); goto out; }void udpv6_exit (void ) {inet6_unregister_protosw (&udpv6_protosw); -inet6_del_protocol (&udpv6_protocol,IPPROTO_UDP ); +inet6_del_protocol (&net_hotdata.udpv6_protocol,IPPROTO_UDP ); }
Signature · 1 line
2.44.0.278.ge034bb2e1d-goog
PATCH 13/18 inet: move tcp_protocol and udp_protocol to net_hotdata
In reply to Eric DumazetThese structures are read in rx path, move them to net_hotdata for better cache locality.
--- include/net/hotdata.h | 2 ++ net/ipv4/af_inet.c | 30 +++++++++++++++--------------- 2 files changed, 17 insertions(+), 15 deletions(-)
include/net/hotdata.h +2 -0
@@ -11,7 +11,9 @@ struct net_hotdata {#if IS_ENABLED (CONFIG_INET )struct packet_offload ip_packet_offload;struct net_offload tcpv4_offload; +struct net_protocol tcp_protocol;struct net_offload udpv4_offload; +struct net_protocol udp_protocol;#endif #if IS_ENABLED (CONFIG_IPV6 )struct packet_offload ipv6_packet_offload;
net/ipv4/af_inet.c +15 -15
@@ -1751,19 +1751,6 @@ static const struct net_protocol igmp_protocol = { };#endif -static const struct net_protocol tcp_protocol = { - .handler = tcp_v4_rcv, - .err_handler = tcp_v4_err, - .no_policy =1 , - .icmp_strict_tag_validation =1 , -}; - -static const struct net_protocol udp_protocol = { - .handler = udp_rcv, - .err_handler = udp_err, - .no_policy =1 , -}; -static const struct net_protocol icmp_protocol = { .handler = icmp_rcv, .err_handler = icmp_err,
@@ -1992,9 +1979,22 @@ static int __init inet_init(void)if (inet_add_protocol (&icmp_protocol,IPPROTO_ICMP ) <0 )pr_crit ("%s: Cannot add ICMP protocol\n" , __func__); -if (inet_add_protocol (&udp_protocol,IPPROTO_UDP ) <0 ) + + net_hotdata.udp_protocol = (struct net_protocol ) { + .handler = udp_rcv, + .err_handler = udp_err, + .no_policy =1 , + }; +if (inet_add_protocol (&net_hotdata.udp_protocol,IPPROTO_UDP ) <0 )pr_crit ("%s: Cannot add UDP protocol\n" , __func__); -if (inet_add_protocol (&tcp_protocol,IPPROTO_TCP ) <0 ) + + net_hotdata.tcp_protocol = (struct net_protocol ) { + .handler = tcp_v4_rcv, + .err_handler = tcp_v4_err, + .no_policy =1 , + .icmp_strict_tag_validation =1 , + }; +if (inet_add_protocol (&net_hotdata.tcp_protocol,IPPROTO_TCP ) <0 )pr_crit ("%s: Cannot add TCP protocol\n" , __func__);#ifdef CONFIG_IP_MULTICAST if (inet_add_protocol (&igmp_protocol,IPPROTO_IGMP ) <0 )
Signature · 1 line
2.44.0.278.ge034bb2e1d-goog
PATCH 14/18 inet: move inet_ehash_secret and udp_ehash_secret into net_hotdata
In reply to Eric Dumazet"struct net_protocol" has a 32bit hole in 32bit arches.
Use it to store the 32bit secret used by UDP and TCP, to increase cache locality in rx path.
--- include/net/hotdata.h | 3 +++ include/net/protocol.h | 1 + net/ipv4/inet_hashtables.c | 3 +-- net/ipv4/udp.c | 2 -- 4 files changed, 5 insertions(+), 4 deletions(-)
include/net/hotdata.h +3 -0
@@ -36,6 +36,9 @@ struct net_hotdata { int dev_rx_weight; }; +#define inet_ehash_secret net_hotdata.tcp_protocol.secret +#define udp_ehash_secret net_hotdata.udp_protocol.secret +extern struct net_hotdata net_hotdata;#endif /* _NET_HOTDATA_H */
include/net/protocol.h +1 -0
@@ -46,6 +46,7 @@ struct net_protocol {* socket lookup? */ icmp_strict_tag_validation:1 ; +u32 secret; };#if IS_ENABLED (CONFIG_IPV6 )
net/ipv4/inet_hashtables.c +1 -2
@@ -24,6 +24,7 @@#include <net/inet6_hashtables.h> #endif #include <net/secure_seq.h> +#include <net/hotdata.h> #include <net/ip.h> #include <net/tcp.h> #include <net/sock_reuseport.h>
@@ -32,8 +33,6 @@ u32 inet_ehashfn(const struct net *net, const __be32 laddr, const __u16 lport, const __be32 faddr, const __be16 fport) { - static u32 inet_ehash_secret __read_mostly; - net_get_random_once(&inet_ehash_secret, sizeof(inet_ehash_secret)); return __inet_ehashfn(laddr, lport, faddr, fport,
net/ipv4/udp.c +0 -2
@@ -411,8 +411,6 @@ INDIRECT_CALLABLE_SCOPEu32 udp_ehashfn (const struct net *net,const __be32 laddr,const __u16 lport,const __be32 faddr,const __be16 fport) { -static u32 udp_ehash_secret__read_mostly ; -net_get_random_once (&udp_ehash_secret,sizeof (udp_ehash_secret)); return __inet_ehashfn(laddr, lport, faddr, fport,
Signature · 1 line
2.44.0.278.ge034bb2e1d-goog
PATCH 15/18 ipv6: move inet6_ehash_secret and udp6_ehash_secret into net_hotdata
In reply to Eric Dumazet"struct inet6_protocol" has a 32bit hole in 32bit arches.
Use it to store the 32bit secret used by UDP and TCP, to increase cache locality in rx path.
--- include/net/hotdata.h | 2 ++ include/net/protocol.h | 1 + net/ipv6/inet6_hashtables.c | 2 +- net/ipv6/udp.c | 1 - 4 files changed, 4 insertions(+), 2 deletions(-)
include/net/hotdata.h +2 -0
@@ -38,6 +38,8 @@ struct net_hotdata {#define inet_ehash_secret net_hotdata.tcp_protocol.secret#define udp_ehash_secret net_hotdata.udp_protocol.secret +#define inet6_ehash_secret net_hotdata.tcpv6_protocol.secret +#define udp6_ehash_secret net_hotdata.udpv6_protocol.secretextern struct net_hotdata net_hotdata;
include/net/protocol.h +1 -0
@@ -60,6 +60,7 @@ struct inet6_protocol { __be32 info);unsigned int flags;/* INET6_PROTO_xxx */ +u32 secret; };#define INET6_PROTO_NOPOLICY 0x1
net/ipv6/inet6_hashtables.c +1 -1
@@ -14,6 +14,7 @@#include <linux/random.h> #include <net/addrconf.h> +#include <net/hotdata.h> #include <net/inet_connection_sock.h> #include <net/inet_hashtables.h> #include <net/inet6_hashtables.h>
@@ -25,7 +26,6 @@ u32 inet6_ehashfn(const struct net *net, const struct in6_addr *laddr, const u16 lport, const struct in6_addr *faddr, const __be16 fport) { - static u32 inet6_ehash_secret __read_mostly; static u32 ipv6_hash_secret __read_mostly;u32 lhash, fhash;
net/ipv6/udp.c +0 -1
@@ -79,7 +79,6 @@ u32 udp6_ehashfn(const struct net *net, const struct in6_addr *faddr, const __be16 fport) { - static u32 udp6_ehash_secret __read_mostly;static u32 udp_ipv6_hash_secret__read_mostly ;u32 lhash, fhash;
Signature · 1 line
2.44.0.278.ge034bb2e1d-goog
PATCH 16/18 ipv6: move tcp_ipv6_hash_secret and udp_ipv6_hash_secret to net_hotdata
In reply to Eric DumazetUse a 32bit hole in "struct net_offload" to store the remaining 32bit secrets used by TCPv6 and UDPv6.
--- include/net/hotdata.h | 2 ++ include/net/protocol.h | 1 + net/ipv6/inet6_hashtables.c | 6 ++---- net/ipv6/udp.c | 2 -- 4 files changed, 5 insertions(+), 6 deletions(-)
include/net/hotdata.h +2 -0
@@ -39,7 +39,9 @@ struct net_hotdata {#define inet_ehash_secret net_hotdata.tcp_protocol.secret#define udp_ehash_secret net_hotdata.udp_protocol.secret#define inet6_ehash_secret net_hotdata.tcpv6_protocol.secret +#define tcp_ipv6_hash_secret net_hotdata.tcpv6_offload.secret#define udp6_ehash_secret net_hotdata.udpv6_protocol.secret +#define udp_ipv6_hash_secret net_hotdata.udpv6_offload.secretextern struct net_hotdata net_hotdata;
include/net/protocol.h +1 -0
@@ -70,6 +70,7 @@ struct inet6_protocol {struct net_offload {struct offload_callbacks callbacks;unsigned int flags;/* Flags used by IPv6 for now */ +u32 secret; };/* This should be set for any extension header which is compatible with GSO. */ #define INET6_PROTO_GSO_EXTHDR 0x1
net/ipv6/inet6_hashtables.c +2 -4
@@ -26,15 +26,13 @@ u32 inet6_ehashfn(const struct net *net, const struct in6_addr *laddr, const u16 lport, const struct in6_addr *faddr, const __be16 fport) { - static u32 ipv6_hash_secret __read_mostly; - u32 lhash, fhash;net_get_random_once (&inet6_ehash_secret,sizeof (inet6_ehash_secret)); -net_get_random_once (&ipv6_hash_secret,sizeof (ipv6_hash_secret)); +net_get_random_once (&tcp_ipv6_hash_secret,sizeof (tcp_ipv6_hash_secret)); lhash = (__force u32 )laddr->s6_addr32[3 ]; - fhash =__ipv6_addr_jhash (faddr, ipv6_hash_secret); + fhash =__ipv6_addr_jhash (faddr, tcp_ipv6_hash_secret);return __inet6_ehashfn (lhash, lport, fhash, fport, inet6_ehash_secret +net_hash_mix (net));
net/ipv6/udp.c +0 -2
@@ -79,8 +79,6 @@ u32 udp6_ehashfn(const struct net *net,const struct in6_addr *faddr, const __be16 fport) { - static u32 udp_ipv6_hash_secret __read_mostly; - u32 lhash, fhash; net_get_random_once(&udp6_ehash_secret,
Signature · 1 line
2.44.0.278.ge034bb2e1d-goog
PATCH 17/18 net: introduce include/net/rps.h
In reply to Eric DumazetMove RPS related structures and helpers from include/linux/netdevice.h and include/net/sock.h to a new include file.
--- drivers/net/ethernet/intel/ice/ice_arfs.c | 1 + .../net/ethernet/mellanox/mlx4/en_netdev.c | 1 + .../net/ethernet/mellanox/mlx5/core/en_arfs.c | 1 + drivers/net/ethernet/sfc/rx_common.c | 1 + drivers/net/ethernet/sfc/siena/rx_common.c | 1 + drivers/net/tun.c | 1 + include/linux/netdevice.h | 82 ----------- include/net/rps.h | 127 ++++++++++++++++++ include/net/sock.h | 35 ----- net/core/dev.c | 1 + net/core/net-sysfs.c | 1 + net/core/sysctl_net_core.c | 1 + net/ipv4/af_inet.c | 1 + net/ipv4/tcp.c | 1 + net/ipv6/af_inet6.c | 1 + net/sctp/socket.c | 1 + 16 files changed, 140 insertions(+), 117 deletions(-) create mode 100644 include/net/rps.h
drivers/net/ethernet/intel/ice/ice_arfs.c +1 -0
@@ -2,6 +2,7 @@/* Copyright (C) 2018-2020, Intel Corporation. */ #include "ice.h" +#include <net/rps.h> /** * ice_is_arfs_active - helper to check is aRFS is active
drivers/net/ethernet/mellanox/mlx4/en_netdev.c +1 -0
@@ -42,6 +42,7 @@#include <net/ip.h> #include <net/vxlan.h> #include <net/devlink.h> +#include <net/rps.h> #include <linux/mlx4/driver.h> #include <linux/mlx4/device.h>
drivers/net/ethernet/mellanox/mlx5/core/en_arfs.c +1 -0
@@ -34,6 +34,7 @@#include <linux/mlx5/fs.h> #include <linux/ip.h> #include <linux/ipv6.h> +#include <net/rps.h> #include "en.h" #define ARFS_HASH_SHIFT BITS_PER_BYTE
drivers/net/ethernet/sfc/rx_common.c +1 -0
@@ -11,6 +11,7 @@#include "net_driver.h" #include <linux/module.h> #include <linux/iommu.h> +#include <net/rps.h> #include "efx.h" #include "nic.h" #include "rx_common.h"
drivers/net/ethernet/sfc/siena/rx_common.c +1 -0
@@ -11,6 +11,7 @@#include "net_driver.h" #include <linux/module.h> #include <linux/iommu.h> +#include <net/rps.h> #include "efx.h" #include "nic.h" #include "rx_common.h"
drivers/net/tun.c +1 -0
@@ -78,6 +78,7 @@#include <net/ax25.h> #include <net/rose.h> #include <net/6lowpan.h> +#include <net/rps.h> #include <linux/uaccess.h> #include <linux/proc_fs.h>
include/linux/netdevice.h +0 -82
98 lines not on this page · raw message
include/net/rps.h new file +127 -0
127 lines not on this page · raw message
include/net/sock.h +0 -35
@@ -1117,41 +1117,6 @@ static inline void sk_incoming_cpu_update(struct sock *sk)WRITE_ONCE (sk->sk_incoming_cpu, cpu); } -static inline void sock_rps_record_flow_hash (__u32 hash) -{ -#ifdef CONFIG_RPS -struct rps_sock_flow_table *sock_flow_table; - -rcu_read_lock (); - sock_flow_table =rcu_dereference (rps_sock_flow_table); -rps_record_sock_flow (sock_flow_table, hash); -rcu_read_unlock (); -#endif -} - -static inline void sock_rps_record_flow (const struct sock *sk) -{ -#ifdef CONFIG_RPS -if (static_branch_unlikely (&rfs_needed)) { -/* Reading sk->sk_rxhash might incur an expensive cache line -* miss. -* -* TCP_ESTABLISHED does cover almost all states where RFS -* might be useful, and is cheaper [1] than testing : -* IPv4: inet_sk(sk)->inet_daddr -* IPv6: ipv6_addr_any(&sk->sk_v6_daddr) -* OR an additional socket flag -* [1] : sk_state and sk_prot are in the same cache line. -*/ -if (sk->sk_state ==TCP_ESTABLISHED ) { -/* This READ_ONCE() is paired with the WRITE_ONCE() -* from sock_rps_save_rxhash() and sock_rps_reset_rxhash(). -*/ -sock_rps_record_flow_hash (READ_ONCE (sk->sk_rxhash)); - } - } -#endif -}static inline void sock_rps_save_rxhash (struct sock *sk,const struct sk_buff *skb)
net/core/dev.c +1 -0
@@ -155,6 +155,7 @@#include <net/netdev_rx_queue.h> #include <net/page_pool/types.h> #include <net/page_pool/helpers.h> +#include <net/rps.h> #include "dev.h" #include "net-sysfs.h"
net/core/net-sysfs.c +1 -0
@@ -24,6 +24,7 @@#include <linux/of_net.h> #include <linux/cpu.h> #include <net/netdev_rx_queue.h> +#include <net/rps.h> #include "dev.h" #include "net-sysfs.h"
net/core/sysctl_net_core.c +1 -0
@@ -24,6 +24,7 @@#include <net/busy_poll.h> #include <net/pkt_sched.h> #include <net/hotdata.h> +#include <net/rps.h> #include "dev.h"
net/ipv4/af_inet.c +1 -0
@@ -119,6 +119,7 @@#endif #include <net/l3mdev.h> #include <net/compat.h> +#include <net/rps.h> #include <trace/events/sock.h>
net/ipv4/tcp.c +1 -0
@@ -279,6 +279,7 @@#include <linux/uaccess.h> #include <asm/ioctls.h> #include <net/busy_poll.h> +#include <net/rps.h> /* Track pending CMSGs. */ enum {
net/ipv6/af_inet6.c +1 -0
@@ -64,6 +64,7 @@#include <net/xfrm.h> #include <net/ioam6.h> #include <net/rawv6.h> +#include <net/rps.h> #include <linux/uaccess.h> #include <linux/mroute6.h>
net/sctp/socket.c +1 -0
@@ -67,6 +67,7 @@#include <net/sctp/sctp.h> #include <net/sctp/sm.h> #include <net/sctp/stream_sched.h> +#include <net/rps.h> /* Forward declarations for internal helper functions. */ static bool sctp_writeable (const struct sock *sk);
Signature · 1 line
2.44.0.278.ge034bb2e1d-goog
PATCH 18/18 net: move rps_sock_flow_table to net_hotdata
In reply to Eric Dumazetrps_sock_flow_table and rps_cpu_mask are used in fast path.
Move them to net_hotdata for better cache locality.
--- include/net/hotdata.h | 4 ++++ include/net/rps.h | 8 +++----- net/core/dev.c | 12 +++--------- net/core/sysctl_net_core.c | 9 ++++++--- 4 files changed, 16 insertions(+), 17 deletions(-)
include/net/hotdata.h +4 -0
@@ -27,6 +27,10 @@ struct net_hotdata {struct kmem_cache *skbuff_cache;struct kmem_cache *skbuff_fclone_cache;struct kmem_cache *skb_small_head_cache; +#ifdef CONFIG_RPS +struct rps_sock_flow_table __rcu *rps_sock_flow_table; +u32 rps_cpu_mask; +#endif int gro_normal_batch;int netdev_budget;int netdev_budget_usecs;
include/net/rps.h +3 -5
@@ -5,6 +5,7 @@#include <linux/types.h> #include <linux/static_key.h> #include <net/sock.h> +#include <net/hotdata.h> #ifdef CONFIG_RPS
@@ -64,14 +65,11 @@ struct rps_sock_flow_table {#define RPS_NO_CPU 0xffff -extern u32 rps_cpu_mask; -extern struct rps_sock_flow_table __rcu *rps_sock_flow_table; -static inline void rps_record_sock_flow (struct rps_sock_flow_table *table,u32 hash) {unsigned int index = hash & table->mask; -u32 val = hash & ~rps_cpu_mask; +u32 val = hash & ~net_hotdata.rps_cpu_mask;/* We only give a hint, preemption can change CPU under us */ val |=raw_smp_processor_id ();
@@ -93,7 +91,7 @@ static inline void sock_rps_record_flow_hash(__u32 hash)if (!hash)return ;rcu_read_lock (); - sock_flow_table =rcu_dereference (rps_sock_flow_table); + sock_flow_table =rcu_dereference (net_hotdata.rps_sock_flow_table);if (sock_flow_table)rps_record_sock_flow (sock_flow_table, hash);rcu_read_unlock ();
net/core/dev.c +3 -9
@@ -4450,12 +4450,6 @@ static inline void ____napi_schedule(struct softnet_data *sd,#ifdef CONFIG_RPS -/* One global table that all flow-based protocols share. */ -struct rps_sock_flow_table __rcu *rps_sock_flow_table__read_mostly ; -EXPORT_SYMBOL (rps_sock_flow_table); -u32 rps_cpu_mask__read_mostly ; -EXPORT_SYMBOL (rps_cpu_mask); -struct static_key_false rps_needed__read_mostly ;EXPORT_SYMBOL (rps_needed);struct static_key_false rfs_needed__read_mostly ;
@@ -4547,7 +4541,7 @@ static int get_rps_cpu(struct net_device *dev, struct sk_buff *skb,if (!hash) goto done; - sock_flow_table =rcu_dereference (rps_sock_flow_table); + sock_flow_table =rcu_dereference (net_hotdata.rps_sock_flow_table);if (flow_table && sock_flow_table) {struct rps_dev_flow *rflow;u32 next_cpu;
@@ -4557,10 +4551,10 @@ static int get_rps_cpu(struct net_device *dev, struct sk_buff *skb,* This READ_ONCE() pairs with WRITE_ONCE() from rps_record_sock_flow(). */ ident =READ_ONCE (sock_flow_table->ents[hash & sock_flow_table->mask]); -if ((ident ^ hash) & ~rps_cpu_mask) +if ((ident ^ hash) & ~net_hotdata.rps_cpu_mask) goto try_rps; - next_cpu = ident & rps_cpu_mask; + next_cpu = ident & net_hotdata.rps_cpu_mask;/* OK, now we know there is a match, * we can look at the local (per receive queue) flow table
net/core/sysctl_net_core.c +6 -3
@@ -140,7 +140,8 @@ static int rps_sock_flow_sysctl(struct ctl_table *table, int write,mutex_lock (&sock_flow_mutex); - orig_sock_table =rcu_dereference_protected (rps_sock_flow_table, + orig_sock_table =rcu_dereference_protected ( + net_hotdata.rps_sock_flow_table,lockdep_is_held (&sock_flow_mutex)); size = orig_size = orig_sock_table ? orig_sock_table->mask +1 :0 ;
@@ -161,7 +162,8 @@ static int rps_sock_flow_sysctl(struct ctl_table *table, int write,mutex_unlock (&sock_flow_mutex);return -ENOMEM ; } - rps_cpu_mask =roundup_pow_of_two (nr_cpu_ids) -1 ; + net_hotdata.rps_cpu_mask = +roundup_pow_of_two (nr_cpu_ids) -1 ; sock_table->mask = size -1 ; }else sock_table = orig_sock_table;
@@ -172,7 +174,8 @@ static int rps_sock_flow_sysctl(struct ctl_table *table, int write, sock_table =NULL ;if (sock_table != orig_sock_table) { -rcu_assign_pointer (rps_sock_flow_table, sock_table); +rcu_assign_pointer (net_hotdata.rps_sock_flow_table, + sock_table);if (sock_table) {static_branch_inc (&rps_needed);static_branch_inc (&rfs_needed);
Signature · 1 line
2.44.0.278.ge034bb2e1d-goog
Quoted 19 lines · Eric Dumazet
While our recent structure reorganizations were focused on increasing max throughput, there is still an area where improvements are much needed.
In many cases, a cpu handles one packet at a time, instead of a nice batch.
Hardware interrupt.
-> Software interrupt.
-> Network/Protocol stacks.If the cpu was idle or busy in other layers, it has to pull many cache lines.
This series adds a new
net_hotdatastructure, where some critical (and read-mostly) data used in
rx and tx path is packed in a small number of cache lines.
Quoted 7 lines
Synthetic benchmarks will not see much difference, but latency of single packet should improve.
net_hodatacurrent size on 64bit is 416 bytes, but might grow in the future.Also move RPS definitions to a new include file.
Nice series!
Quoted 73 lines
Eric Dumazet (18):
net: introduce structnet_hotdata
net: movenetdev_budgetandnetdev_budgettonet_hotdata
net: movenetdev_tstamp_prequeueintonet_hotdata
net: moveptype_allintonet_hotdata
net: movenetdev_max_backlogtonet_hotdata
net: moveip_packet_offloadandipv6_packet_offloadtonet_hotdata
net: movetcpv4_offloadandtcpv6_offloadtonet_hotdata
net: movedev_tx_weighttonet_hotdata
net: movedev_rx_weighttonet_hotdata
net: moveskbuff_cache(s)tonet_hotdata
udp: moveudpv4_offloadandudpv6_offloadtonet_hotdata
ipv6: movetcpv6_protocolandudpv6_protocoltonet_hotdata
inet: movetcp_protocolandudp_protocoltonet_hotdata
inet: moveinet_ehash_secretandudp_ehash_secretintonet_hotdata
ipv6: moveinet6_ehash_secretandudp6_ehash_secretintonet_hotdata
ipv6: movetcp_ipv6_hash_secretandudp_ipv6_hash_secretto
net_hotdata
net: introduceinclude/net/rps.h
net: moverps_sock_flow_tabletonet_hotdatadrivers/net/ethernet/intel/ice/ice_arfs.c | 1 + .../net/ethernet/mellanox/mlx4/en_netdev.c | 1 + .../net/ethernet/mellanox/mlx5/core/en_arfs.c | 1 + drivers/net/ethernet/sfc/rx_common.c | 1 + drivers/net/ethernet/sfc/siena/rx_common.c | 1 + drivers/net/tun.c | 1 + include/linux/netdevice.h | 88 ------------ include/linux/skbuff.h | 1 - include/net/gro.h | 5 +- include/net/hotdata.h | 52 ++++++++ include/net/protocol.h | 3 + include/net/rps.h | 125 ++++++++++++++++++ include/net/sock.h | 35 ----- kernel/bpf/cpumap.c | 4 +- net/bpf/test_run.c | 4 +- net/core/Makefile | 1 + net/core/dev.c | 58 +++----- net/core/dev.h | 3 - net/core/gro.c | 15 +-- net/core/gro_cells.c | 3 +- net/core/gso.c | 4 +- net/core/hotdata.c | 22 +++ net/core/net-procfs.c | 7 +- net/core/net-sysfs.c | 1 + net/core/skbuff.c | 44 +++--- net/core/sysctl_net_core.c | 25 ++-- net/core/xdp.c | 5 +- net/ipv4/af_inet.c | 49 +++---- net/ipv4/inet_hashtables.c | 3 +- net/ipv4/tcp.c | 1 + net/ipv4/tcp_offload.c | 17 ++- net/ipv4/udp.c | 2 - net/ipv4/udp_offload.c | 17 ++- net/ipv6/af_inet6.c | 1 + net/ipv6/inet6_hashtables.c | 8 +- net/ipv6/ip6_offload.c | 18 +-- net/ipv6/tcp_ipv6.c | 17 +-- net/ipv6/tcpv6_offload.c | 16 +-- net/ipv6/udp.c | 19 ++- net/ipv6/udp_offload.c | 21 ++- net/sched/sch_generic.c | 3 +- net/sctp/socket.c | 1 + net/xfrm/espintcp.c | 4 +- net/xfrm/xfrm_input.c | 3 +- 44 files changed, 391 insertions(+), 320 deletions(-) create mode 100644 include/net/hotdata.h create mode 100644 include/net/rps.h create mode 100644 net/core/hotdata.c--
2.44.0.278.ge034bb2e1d-goog
Quoted 18 lines · Eric Dumazet
While our recent structure reorganizations were focused on increasing max throughput, there is still an area where improvements are much needed.
In many cases, a cpu handles one packet at a time, instead of a nice batch.
Hardware interrupt.
-> Software interrupt.
-> Network/Protocol stacks.If the cpu was idle or busy in other layers, it has to pull many cache lines.
This series adds a new
net_hotdatastructure, where some critical (and read-mostly) data used in
rx and tx path is packed in a small number of cache lines.
Quoted 8 lines
Synthetic benchmarks will not see much difference, but latency of single packet should improve.
net_hodatacurrent size on 64bit is 416 bytes, but might grow in the future.Also move RPS definitions to a new include file.
Interesting patch set. For the set: