net: more three misplaced fields
Subsystems (4)
cover net: more three misplaced fields
We recently reorganized some structures for better data locality in networking fast paths.
This series moves three fields that were not correctly classified.
There probably more to come.
Reference : https://lwn.net/Articles/951321/
Eric Dumazet (3):
tcp: move tp->scaling_ratio to tcp_sock_read_txrx group
tcp: move tp->tcp_usec_ts to tcp_sock_read_txrx group
net-device: move lstats in net_device_read_txrx
Documentation/networking/net_cachelines/net_device.rst | 4 ++-- Documentation/networking/net_cachelines/tcp_sock.rst | 4 ++-- include/linux/netdevice.h | 10 +++++----- include/linux/tcp.h | 6 +++--- net/core/dev.c | 3 ++- net/ipv4/tcp.c | 3 ++- 6 files changed, 16 insertions(+), 14 deletions(-)
Signature · 1 line
2.43.0.594.gd9cf4e227d-goog
PATCH 1/3 tcp: move tp->scaling_ratio to tcp_sock_read_txrx group
tp->scaling_ratio is a read mostly field, used in rx and tx fast paths.
--- Documentation/networking/net_cachelines/tcp_sock.rst | 2 +- include/linux/tcp.h | 2 +- net/ipv4/tcp.c | 3 ++- 3 files changed, 4 insertions(+), 3 deletions(-)
Documentation/networking/net_cachelines/tcp_sock.rst +1 -1
@@ -38,7 +38,7 @@ u32 max_window read_mostly - u32 mss_cache read_mostly read_mostly tcp_rate_check_app_limited,tcp_current_mss,tcp_sync_mss,tcp_sndbuf_expand,tcp_tso_should_defer(tx);tcp_update_pacing_rate,tcp_clean_rtx_queue(rx) u32 window_clamp read_mostly read_write tcp_rcv_space_adjust,__tcp_select_window u32 rcv_ssthresh read_mostly - __tcp_select_window -u82 scaling_ratio +u8 scaling_ratio read_mostly read_mostly tcp_win_from_space struct tcp_rack u16 advmss - read_mostly tcp_rcv_space_adjust u8 compressed_ack
include/linux/tcp.h +1 -1
@@ -221,6 +221,7 @@ struct tcp_sock {u32 lost_out;/* Lost packets */ u32 sacked_out;/* SACK'd packets */ u16 tcp_header_len;/* Bytes of tcp header to send */ +u8 scaling_ratio;/* see tcp_win_from_space() */ u8 chrono_type : 2, /* current chronograph type */ repair : 1, is_sack_reneg:1, /* in recovery from loss with SACK reneg? */
@@ -352,7 +353,6 @@ struct tcp_sock {u32 compressed_ack_rcv_nxt;struct list_head tsq_node;/* anchor in tsq_tasklet.head list */ -u8 scaling_ratio;/* see tcp_win_from_space() */ /* Information of the most recently (s)acked skb */ struct tcp_rack {u64 mstamp;/* (Re)sent time of the skb */
net/ipv4/tcp.c +2 -1
@@ -4615,7 +4615,8 @@ static void __init tcp_struct_check(void) CACHELINE_ASSERT_GROUP_MEMBER(struct tcp_sock, tcp_sock_read_txrx, prr_out); CACHELINE_ASSERT_GROUP_MEMBER(struct tcp_sock, tcp_sock_read_txrx, lost_out); CACHELINE_ASSERT_GROUP_MEMBER(struct tcp_sock, tcp_sock_read_txrx, sacked_out); - CACHELINE_ASSERT_GROUP_SIZE(struct tcp_sock, tcp_sock_read_txrx, 31); + CACHELINE_ASSERT_GROUP_MEMBER(struct tcp_sock, tcp_sock_read_txrx, scaling_ratio); + CACHELINE_ASSERT_GROUP_SIZE(struct tcp_sock, tcp_sock_read_txrx, 32);/* RX read-mostly hotpath cache lines */ CACHELINE_ASSERT_GROUP_MEMBER(struct tcp_sock, tcp_sock_read_rx, copied_seq);
Signature · 1 line
2.43.0.594.gd9cf4e227d-goog
Re: [PATCH net 1/3] tcp: move tp->scaling_ratio to tcp_sock_read_txrx group
Quoted 6 lines · Eric Dumazet
tp->scaling_ratiois a read mostly field, used in rx and tx fast paths.Fixes d5fed5addb2b ("tcp: reorganize tcp_sock fast path variables")Signed-off-by Eric Dumazet <[email protected]>Cc Coco Li <[email protected]>Cc Wei Wang <[email protected]>
PATCH 2/3 tcp: move tp->tcp_usec_ts to tcp_sock_read_txrx group
In reply to Eric Dumazettp->tcp_usec_ts is a read mostly field, used in rx and tx fast paths.
--- Documentation/networking/net_cachelines/tcp_sock.rst | 2 +- include/linux/tcp.h | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-)
Documentation/networking/net_cachelines/tcp_sock.rst +1 -1
@@ -44,7 +44,7 @@ u16 advmss - read_m u8 compressed_ack u8:2 dup_ack_counter u8:1 tlp_retrans -u8:1 tcp_usec_ts +u8:1 tcp_usec_ts read_mostly read_mostly u32 chrono_start read_write - tcp_chrono_start/stop(tcp_write_xmit,tcp_cwnd_validate,tcp_send_syn_data) u32[3] chrono_stat read_write - tcp_chrono_start/stop(tcp_write_xmit,tcp_cwnd_validate,tcp_send_syn_data) u8:2 chrono_type read_write - tcp_chrono_start/stop(tcp_write_xmit,tcp_cwnd_validate,tcp_send_syn_data)
include/linux/tcp.h +2 -2
@@ -224,6 +224,7 @@ struct tcp_sock {u8 scaling_ratio;/* see tcp_win_from_space() */ u8 chrono_type : 2, /* current chronograph type */ repair : 1, + tcp_usec_ts : 1, /* TSval values in usec */ is_sack_reneg:1, /* in recovery from loss with SACK reneg? */ is_cwnd_limited:1;/* forward progress limited by snd_cwnd? */__cacheline_group_end (tcp_sock_read_txrx);
@@ -368,8 +369,7 @@ struct tcp_sock {u8 compressed_ack; u8 dup_ack_counter:2, tlp_retrans:1, /* TLP is a retransmission */ - tcp_usec_ts:1, /* TSval values in usec */ - unused:4; + unused:5; u8 thin_lto : 1,/* Use linear timeouts for thin streams */ recvmsg_inq : 1,/* Indicate # of bytes in queue upon recvmsg */ fastopen_connect:1, /* FASTOPEN_CONNECT sockopt */
Signature · 1 line
2.43.0.594.gd9cf4e227d-goog
Re: [PATCH net 2/3] tcp: move tp->tcp_usec_ts to tcp_sock_read_txrx group
Quoted 6 lines · Eric Dumazet
tp->tcp_usec_tsis a read mostly field, used in rx and tx fast paths.Fixes d5fed5addb2b ("tcp: reorganize tcp_sock fast path variables")Signed-off-by Eric Dumazet <[email protected]>Cc Coco Li <[email protected]>Cc Wei Wang <[email protected]>
PATCH 3/3 net-device: move lstats in net_device_read_txrx
In reply to Eric Dumazetdev->lstats is notably used from loopback ndo_start_xmit() and other virtual drivers.
Per cpu stats updates are dirtying per-cpu data,
but the pointer itself is read-only.
--- Documentation/networking/net_cachelines/net_device.rst | 4 ++-- include/linux/netdevice.h | 10 +++++----- net/core/dev.c | 3 ++- 3 files changed, 9 insertions(+), 8 deletions(-)
Documentation/networking/net_cachelines/net_device.rst +2 -2
@@ -136,8 +136,8 @@ struct_netpoll_info* npinfo - possible_net_t nd_net - read_mostly (dev_net)napi_busy_loop,tcp_v(4/6)_rcv,ip(v6)_rcv,ip(6)_input,ip(6)_input_finish void* ml_priv enum_netdev_ml_priv_type ml_priv_type -struct_pcpu_lstats__percpu* lstats -struct_pcpu_sw_netstats__percpu* tstats +struct_pcpu_lstats__percpu* lstats read_mostly dev_lstats_add() +struct_pcpu_sw_netstats__percpu* tstats read_mostly dev_sw_netstats_tx_add() struct_pcpu_dstats__percpu* dstats struct_garp_port* garp_port struct_mrp_port* mrp_port
include/linux/netdevice.h +5 -5
@@ -2141,6 +2141,11 @@ struct net_device {/* TXRX read-mostly hotpath */ __cacheline_group_begin (net_device_read_txrx); +union { +struct pcpu_lstats __percpu *lstats; +struct pcpu_sw_netstats __percpu *tstats; +struct pcpu_dstats __percpu *dstats; + };unsigned int flags;unsigned short hard_header_len;netdev_features_t features;
@@ -2395,11 +2400,6 @@ struct net_device {enum netdev_ml_priv_type ml_priv_type; enum netdev_stat_type pcpu_stat_type:8; -union { -struct pcpu_lstats __percpu *lstats; -struct pcpu_sw_netstats __percpu *tstats; -struct pcpu_dstats __percpu *dstats; - };#if IS_ENABLED (CONFIG_GARP )struct garp_port __rcu *garp_port;
net/core/dev.c +2 -1
@@ -11652,11 +11652,12 @@ static void __init net_dev_struct_check(void) CACHELINE_ASSERT_GROUP_SIZE(struct net_device, net_device_read_tx, 160);/* TXRX read-mostly hotpath */ + CACHELINE_ASSERT_GROUP_MEMBER(struct net_device, net_device_read_txrx, lstats); CACHELINE_ASSERT_GROUP_MEMBER(struct net_device, net_device_read_txrx, flags); CACHELINE_ASSERT_GROUP_MEMBER(struct net_device, net_device_read_txrx, hard_header_len); CACHELINE_ASSERT_GROUP_MEMBER(struct net_device, net_device_read_txrx, features); CACHELINE_ASSERT_GROUP_MEMBER(struct net_device, net_device_read_txrx, ip6_ptr); - CACHELINE_ASSERT_GROUP_SIZE(struct net_device, net_device_read_txrx, 30); + CACHELINE_ASSERT_GROUP_SIZE(struct net_device, net_device_read_txrx, 38);/* RX read-mostly hotpath */ CACHELINE_ASSERT_GROUP_MEMBER(struct net_device, net_device_read_rx, ptype_specific);
Signature · 1 line
2.43.0.594.gd9cf4e227d-goog
Re: [PATCH net 3/3] net-device: move lstats in net_device_read_txrx
Quoted 10 lines · Eric Dumazet
dev->lstatsis notably used from loopbackndo_start_xmit()and other virtual drivers.Per cpu stats updates are dirtying per-cpu data,
but the pointer itself is read-only.Fixes 43a71cd66b9c ("net-device: reorganize net_device fast path variables")Signed-off-by Eric Dumazet <[email protected]>Cc Coco Li <[email protected]>Cc Simon Horman <[email protected]>
This series was applied to netdev/net.git (main) by David S. Miller <[email protected]>:
Hello:
This series was applied to netdev/net.git (main)
by David S. Miller <[email protected]>:
Quoted 8 lines · On Thu, 8 Feb 2024 14:43:20 +0000 you wrote:
We recently reorganized some structures for better data locality in networking fast paths.
This series moves three fields that were not correctly classified.
There probably more to come.
[...]
Here is the summary with links:
- [net,1/3] tcp: move tp->scaling_ratio to tcp_sock_read_txrx group
https://git.kernel.org/netdev/net/c/119ff04864a2 - [net,2/3] tcp: move tp->tcp_usec_ts to tcp_sock_read_txrx group https://git.kernel.org/netdev/net/c/666a877deab2 - [net,3/3] net-device: move lstats in net_device_read_txrx https://git.kernel.org/netdev/net/c/c353c7b7ffb7
You are awesome, thank you!
Signature · 2 lines
Deet-doot-dot, I am a bot. https://korg.docs.kernel.org/patchwork/pwbot.html