tcp: move few fields for data locality
Subsystems (5)
v2 cover tcp: move few fields for data locality
After recent additions (PSP and AccECN) I wanted to make another round on fields locations to increase data locality.
This series manages to shrink TCP and TCPv6 objects by 128 bytes, but more importantly should reduce number of touched cache lines in TCP fast paths.
There is more to come.
v2: removed tcp CACHELINE_ASSERT_GROUP_SIZE after a kernel build bot reported an error.
Eric Dumazet (8):
net: move sk_uid and sk_protocol to sock_read_tx
net: move sk->sk_err_soft and sk->sk_sndbuf
tcp: remove CACHELINE_ASSERT_GROUP_SIZE() uses
tcp: move tcp->rcv_tstamp to tcp_sock_write_txrx group
tcp: move recvmsg_inq to tcp_sock_read_txrx
tcp: move tcp_clean_acked to tcp_sock_read_tx group
tcp: move mtu_info to remove two 32bit holes
tcp: reclaim 8 bytes in struct request_sock_queue
.../networking/net_cachelines/tcp_sock.rst | 6 +++--- include/linux/tcp.h | 20 +++++++++---------- include/net/request_sock.h | 2 +- include/net/sock.h | 10 +++++----- net/core/sock.c | 5 ++++- net/ipv4/tcp.c | 20 ++++--------------- net/ipv4/tcp_input.c | 7 ++++--- 7 files changed, 31 insertions(+), 39 deletions(-)
Signature · 1 line
2.51.0.470.ga7dc726c21-goog
PATCH v2 1/8 net: move sk_uid and sk_protocol to sock_read_tx
sk_uid and sk_protocol are read from inet6_csk_route_socket() for each TCP transmit.
Also read from udpv6_sendmsg(), udp_sendmsg() and others.
Move them to sock_read_tx for better cache locality.
--- include/net/sock.h | 6 +++--- net/core/sock.c | 2 ++ 2 files changed, 5 insertions(+), 3 deletions(-)
include/net/sock.h +3 -3
@@ -492,6 +492,9 @@ struct sock {long sk_sndtimeo;u32 sk_priority;u32 sk_mark; +kuid_t sk_uid; +u16 sk_protocol; +u16 sk_type;struct dst_entry __rcu *sk_dst_cache;netdev_features_t sk_route_caps;#ifdef CONFIG_SOCK_VALIDATE_XMIT
@@ -517,15 +520,12 @@ struct sock { sk_no_check_tx :1 , sk_no_check_rx : 1;u8 sk_shutdown; -u16 sk_type; -u16 sk_protocol;unsigned long sk_lingertime;struct proto *sk_prot_creator;rwlock_t sk_callback_lock;int sk_err_soft;u32 sk_ack_backlog;u32 sk_max_ack_backlog; -kuid_t sk_uid;unsigned long sk_ino;spinlock_t sk_peer_lock;int sk_bind_phc;
net/core/sock.c +2 -0
@@ -4471,6 +4471,8 @@ static int __init sock_struct_check(void) CACHELINE_ASSERT_GROUP_MEMBER(struct sock, sock_read_tx, sk_sndtimeo); CACHELINE_ASSERT_GROUP_MEMBER(struct sock, sock_read_tx, sk_priority); CACHELINE_ASSERT_GROUP_MEMBER(struct sock, sock_read_tx, sk_mark); + CACHELINE_ASSERT_GROUP_MEMBER(struct sock, sock_read_tx, sk_uid); + CACHELINE_ASSERT_GROUP_MEMBER(struct sock, sock_read_tx, sk_protocol); CACHELINE_ASSERT_GROUP_MEMBER(struct sock, sock_read_tx, sk_dst_cache); CACHELINE_ASSERT_GROUP_MEMBER(struct sock, sock_read_tx, sk_route_caps); CACHELINE_ASSERT_GROUP_MEMBER(struct sock, sock_read_tx, sk_gso_type);
Signature · 1 line
2.51.0.470.ga7dc726c21-goog
Re: [PATCH v2 net-next 1/8] net: move sk_uid and sk_protocol to sock_read_tx
Quoted 9 lines · Eric Dumazet
sk_uidandsk_protocolare read frominet6_csk_route_socket()for each TCP transmit.Also read from
udpv6_sendmsg(),udp_sendmsg()and others.Move them to
sock_read_txfor better cache locality.Signed-off-by Eric Dumazet <[email protected]>
PATCH v2 2/8 net: move sk->sk_err_soft and sk->sk_sndbuf
In reply to Eric Dumazetsk->sk_sndbuf is read-mostly in tx path, so move it from sock_write_tx group to more appropriate sock_read_tx.
sk->sk_err_soft was not identified previously, but is used from tcp_ack().
Move it to sock_write_tx group for better cache locality.
Also change tcp_ack() to clear sk->sk_err_soft only if needed.
--- include/net/sock.h | 4 ++-- net/core/sock.c | 3 ++- net/ipv4/tcp_input.c | 3 ++- 3 files changed, 6 insertions(+), 4 deletions(-)
include/net/sock.h +2 -2
@@ -467,7 +467,7 @@ struct sock {__cacheline_group_begin (sock_write_tx);int sk_write_pending;atomic_t sk_omem_alloc; -int sk_sndbuf; +int sk_err_soft;int sk_wmem_queued;refcount_t sk_wmem_alloc;
@@ -507,6 +507,7 @@ struct sock {unsigned int sk_gso_max_size;gfp_t sk_allocation;u32 sk_txhash; +int sk_sndbuf;u8 sk_pacing_shift;bool sk_use_task_frag;__cacheline_group_end (sock_read_tx);
@@ -523,7 +524,6 @@ struct sock {unsigned long sk_lingertime;struct proto *sk_prot_creator;rwlock_t sk_callback_lock; -int sk_err_soft;u32 sk_ack_backlog;u32 sk_max_ack_backlog;unsigned long sk_ino;
net/core/sock.c +2 -1
@@ -4452,7 +4452,7 @@ static int __init sock_struct_check(void) CACHELINE_ASSERT_GROUP_MEMBER(struct sock, sock_write_tx, sk_omem_alloc); CACHELINE_ASSERT_GROUP_MEMBER(struct sock, sock_write_tx, sk_omem_alloc); - CACHELINE_ASSERT_GROUP_MEMBER(struct sock, sock_write_tx, sk_sndbuf); + CACHELINE_ASSERT_GROUP_MEMBER(struct sock, sock_write_tx, sk_err_soft); CACHELINE_ASSERT_GROUP_MEMBER(struct sock, sock_write_tx, sk_wmem_queued); CACHELINE_ASSERT_GROUP_MEMBER(struct sock, sock_write_tx, sk_wmem_alloc); CACHELINE_ASSERT_GROUP_MEMBER(struct sock, sock_write_tx, sk_tsq_flags);
@@ -4479,6 +4479,7 @@ static int __init sock_struct_check(void) CACHELINE_ASSERT_GROUP_MEMBER(struct sock, sock_read_tx, sk_gso_max_size); CACHELINE_ASSERT_GROUP_MEMBER(struct sock, sock_read_tx, sk_allocation); CACHELINE_ASSERT_GROUP_MEMBER(struct sock, sock_read_tx, sk_txhash); + CACHELINE_ASSERT_GROUP_MEMBER(struct sock, sock_read_tx, sk_sndbuf); CACHELINE_ASSERT_GROUP_MEMBER(struct sock, sock_read_tx, sk_gso_max_segs); CACHELINE_ASSERT_GROUP_MEMBER(struct sock, sock_read_tx, sk_pacing_shift); CACHELINE_ASSERT_GROUP_MEMBER(struct sock, sock_read_tx, sk_use_task_frag);
net/ipv4/tcp_input.c +2 -1
@@ -4085,7 +4085,8 @@ static int tcp_ack(struct sock *sk, const struct sk_buff *skb, int flag)/* We passed data and got it acked, remove any soft error * log. Something worked... */ -WRITE_ONCE (sk->sk_err_soft,0 ); +if (READ_ONCE (sk->sk_err_soft)) +WRITE_ONCE (sk->sk_err_soft,0 );WRITE_ONCE (icsk->icsk_probes_out,0 ); tp->rcv_tstamp = tcp_jiffies32;if (!prior_packets)
Signature · 1 line
2.51.0.470.ga7dc726c21-goog
Re: [PATCH v2 net-next 2/8] net: move sk->sk_err_soft and sk->sk_sndbuf
Quoted 4 lines · Eric Dumazet
sk->sk_sndbufis read-mostly in tx path, so move it fromsock_write_txgroup to more appropriatesock_read_tx.
Quoted 8 lines
sk->sk_err_softwas not identified previously, but is used fromtcp_ack().Move it to
sock_write_txgroup for better cache locality.Also change
tcp_ack()to clearsk->sk_err_softonly if needed.Signed-off-by Eric Dumazet <[email protected]>
PATCH v2 3/8 tcp: remove CACHELINE_ASSERT_GROUP_SIZE() uses
In reply to Eric DumazetMaintaining the CACHELINE_ASSERT_GROUP_SIZE() uses for struct tcp_sock has been painful.
This had little benefit, so remove them.
--- net/ipv4/tcp.c | 12 ------------ 1 file changed, 12 deletions(-)
net/ipv4/tcp.c +0 -12
@@ -5101,7 +5101,6 @@ static void __init tcp_struct_check(void) CACHELINE_ASSERT_GROUP_MEMBER(struct tcp_sock, tcp_sock_read_tx, notsent_lowat); CACHELINE_ASSERT_GROUP_MEMBER(struct tcp_sock, tcp_sock_read_tx, gso_segs); CACHELINE_ASSERT_GROUP_MEMBER(struct tcp_sock, tcp_sock_read_tx, retransmit_skb_hint); - CACHELINE_ASSERT_GROUP_SIZE(struct tcp_sock, tcp_sock_read_tx, 32);/* TXRX read-mostly hotpath cache lines */ CACHELINE_ASSERT_GROUP_MEMBER(struct tcp_sock, tcp_sock_read_txrx, tsoffset);
@@ -5112,7 +5111,6 @@ static void __init tcp_struct_check(void) 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_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);
@@ -5129,9 +5127,6 @@ static void __init tcp_struct_check(void) CACHELINE_ASSERT_GROUP_MEMBER(struct tcp_sock, tcp_sock_read_rx, snd_ssthresh);#if IS_ENABLED (CONFIG_TLS_DEVICE ) CACHELINE_ASSERT_GROUP_MEMBER(struct tcp_sock, tcp_sock_read_rx, tcp_clean_acked); - CACHELINE_ASSERT_GROUP_SIZE(struct tcp_sock, tcp_sock_read_rx, 77); -#else - CACHELINE_ASSERT_GROUP_SIZE(struct tcp_sock, tcp_sock_read_rx, 69);#endif /* TX read-write hotpath cache lines */
@@ -5151,7 +5146,6 @@ static void __init tcp_struct_check(void) CACHELINE_ASSERT_GROUP_MEMBER(struct tcp_sock, tcp_sock_write_tx, tsorted_sent_queue); CACHELINE_ASSERT_GROUP_MEMBER(struct tcp_sock, tcp_sock_write_tx, highest_sack); CACHELINE_ASSERT_GROUP_MEMBER(struct tcp_sock, tcp_sock_write_tx, ecn_flags); - CACHELINE_ASSERT_GROUP_SIZE(struct tcp_sock, tcp_sock_write_tx, 97);/* TXRX read-write hotpath cache lines */ CACHELINE_ASSERT_GROUP_MEMBER(struct tcp_sock, tcp_sock_write_txrx, pred_flags);
@@ -5172,11 +5166,6 @@ static void __init tcp_struct_check(void) CACHELINE_ASSERT_GROUP_MEMBER(struct tcp_sock, tcp_sock_write_txrx, rcv_wnd); CACHELINE_ASSERT_GROUP_MEMBER(struct tcp_sock, tcp_sock_write_txrx, rx_opt); -/* 32bit arches with 8byte alignment on u64 fields might need padding -* before tcp_clock_cache. -*/ - CACHELINE_ASSERT_GROUP_SIZE(struct tcp_sock, tcp_sock_write_txrx, 107 + 4); -/* RX read-write hotpath cache lines */ CACHELINE_ASSERT_GROUP_MEMBER(struct tcp_sock, tcp_sock_write_rx, bytes_received); CACHELINE_ASSERT_GROUP_MEMBER(struct tcp_sock, tcp_sock_write_rx, segs_in);
@@ -5193,7 +5182,6 @@ static void __init tcp_struct_check(void) CACHELINE_ASSERT_GROUP_MEMBER(struct tcp_sock, tcp_sock_write_rx, bytes_acked); CACHELINE_ASSERT_GROUP_MEMBER(struct tcp_sock, tcp_sock_write_rx, rcv_rtt_est); CACHELINE_ASSERT_GROUP_MEMBER(struct tcp_sock, tcp_sock_write_rx, rcvq_space); - CACHELINE_ASSERT_GROUP_SIZE(struct tcp_sock, tcp_sock_write_rx, 112); }void __init tcp_init (void )
Signature · 1 line
2.51.0.470.ga7dc726c21-goog
Re: [PATCH v2 net-next 3/8] tcp: remove CACHELINE_ASSERT_GROUP_SIZE() uses
Quoted 7 lines · Eric Dumazet
Maintaining the
CACHELINE_ASSERT_GROUP_SIZE()uses for structtcp_sockhas been painful.This had little benefit, so remove them.
Signed-off-by Eric Dumazet <[email protected]>
PATCH v2 4/8 tcp: move tcp->rcv_tstamp to tcp_sock_write_txrx group
In reply to Eric Dumazettcp_ack() writes this field, it belongs to tcp_sock_write_txrx.
--- Documentation/networking/net_cachelines/tcp_sock.rst | 2 +- include/linux/tcp.h | 4 ++-- net/ipv4/tcp.c | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-)
Documentation/networking/net_cachelines/tcp_sock.rst +1 -1
@@ -26,7 +26,7 @@ u64 bytes_acked read_w u32 dsack_dups u32 snd_una read_mostly read_write tcp_wnd_end,tcp_urg_mode,tcp_minshall_check,tcp_cwnd_validate(tx);tcp_ack,tcp_may_update_window,tcp_clean_rtx_queue(write),tcp_ack_tstamp(rx) u32 snd_sml read_write tcp_minshall_check,tcp_minshall_update -u32 rcv_tstamp read_mostly tcp_ack +u32 rcv_tstamp read_write read_write tcp_ack void * tcp_clean_acked read_mostly tcp_ack u32 lsndtime read_write tcp_slow_start_after_idle_check,tcp_event_data_sent u32 last_oow_ack_time
include/linux/tcp.h +2 -2
@@ -238,7 +238,6 @@ struct tcp_sock {/* RX read-mostly hotpath cache lines */ __cacheline_group_begin (tcp_sock_read_rx);u32 copied_seq;/* Head of yet unread data */ -u32 rcv_tstamp;/* timestamp of last received ACK (for keepalives) */ u32 snd_wl1;/* Sequence for window update */ u32 tlp_high_seq;/* snd_nxt at the time of TLP */ u32 rttvar_us;/* smoothed mdev_max */
@@ -246,13 +245,13 @@ struct tcp_sock {u16 advmss;/* Advertised MSS */ u16 urg_data;/* Saved octet of OOB data and control flags */ u32 lost;/* Total data packets lost incl. rexmits */ +u32 snd_ssthresh;/* Slow start size threshold */ struct minmax rtt_min;/* OOO segments go in this rbtree. Socket lock must be held. */ struct rb_root out_of_order_queue;#if defined(CONFIG_TLS_DEVICE )void (*tcp_clean_acked)(struct sock *sk,u32 acked_seq);#endif -u32 snd_ssthresh;/* Slow start size threshold */ u8 recvmsg_inq : 1;/* Indicate # of bytes in queue upon recvmsg */__cacheline_group_end (tcp_sock_read_rx);
@@ -319,6 +318,7 @@ struct tcp_sock {*/ u32 app_limited;/* limited until "delivered" reaches this val */ u32 rcv_wnd;/* Current receiver window */ +u32 rcv_tstamp;/* timestamp of last received ACK (for keepalives) */ /* * Options received (usually on last packet, some only on SYN packets). */
net/ipv4/tcp.c +1 -1
@@ -5114,7 +5114,6 @@ static void __init tcp_struct_check(void)/* RX read-mostly hotpath cache lines */ CACHELINE_ASSERT_GROUP_MEMBER(struct tcp_sock, tcp_sock_read_rx, copied_seq); - CACHELINE_ASSERT_GROUP_MEMBER(struct tcp_sock, tcp_sock_read_rx, rcv_tstamp); CACHELINE_ASSERT_GROUP_MEMBER(struct tcp_sock, tcp_sock_read_rx, snd_wl1); CACHELINE_ASSERT_GROUP_MEMBER(struct tcp_sock, tcp_sock_read_rx, tlp_high_seq); CACHELINE_ASSERT_GROUP_MEMBER(struct tcp_sock, tcp_sock_read_rx, rttvar_us);
@@ -5164,6 +5163,7 @@ static void __init tcp_struct_check(void) CACHELINE_ASSERT_GROUP_MEMBER(struct tcp_sock, tcp_sock_write_txrx, received_ecn_bytes); CACHELINE_ASSERT_GROUP_MEMBER(struct tcp_sock, tcp_sock_write_txrx, app_limited); CACHELINE_ASSERT_GROUP_MEMBER(struct tcp_sock, tcp_sock_write_txrx, rcv_wnd); + CACHELINE_ASSERT_GROUP_MEMBER(struct tcp_sock, tcp_sock_write_txrx, rcv_tstamp); CACHELINE_ASSERT_GROUP_MEMBER(struct tcp_sock, tcp_sock_write_txrx, rx_opt);/* RX read-write hotpath cache lines */
Signature · 1 line
2.51.0.470.ga7dc726c21-goog
Re: [PATCH v2 net-next 4/8] tcp: move tcp->rcv_tstamp to tcp_sock_write_txrx group
Quoted 4 lines · Eric Dumazet
tcp_ack()writes this field, it belongs totcp_sock_write_txrx.Signed-off-by Eric Dumazet <[email protected]>
Confirmed that if snd_ssthresh was not moved, there would be a 4-bytes hole.
PATCH v2 5/8 tcp: move recvmsg_inq to tcp_sock_read_txrx
In reply to Eric DumazetFill a hole in tcp_sock_read_txrx, instead of possibly wasting a cache line.
Note that tcp_recvmsg_locked() is also reading tp->repair, so this removes one cache line miss in tcp recvmsg().
--- 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
@@ -57,7 +57,7 @@ u8:1 is_sack_reneg read_m u8:2 fastopen_client_fail u8:4 nonagle read_write tcp_skb_entail,tcp_push_pending_frames u8:1 thin_lto -u8:1 recvmsg_inq +u8:1 recvmsg_inq read_mostly tcp_recvmsg u8:1 repair read_mostly tcp_write_xmit u8:1 frto u8 repair_queue
include/linux/tcp.h +2 -2
@@ -232,7 +232,8 @@ struct tcp_sock { 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? */ + is_cwnd_limited:1,/* forward progress limited by snd_cwnd? */ + recvmsg_inq : 1;/* Indicate # of bytes in queue upon recvmsg */__cacheline_group_end (tcp_sock_read_txrx);/* RX read-mostly hotpath cache lines */
@@ -252,7 +253,6 @@ struct tcp_sock {#if defined(CONFIG_TLS_DEVICE )void (*tcp_clean_acked)(struct sock *sk,u32 acked_seq);#endif - u8 recvmsg_inq : 1;/* Indicate # of bytes in queue upon recvmsg */__cacheline_group_end (tcp_sock_read_rx);/* TX read-write hotpath cache lines */
Signature · 1 line
2.51.0.470.ga7dc726c21-goog
Re: [PATCH v2 net-next 5/8] tcp: move recvmsg_inq to tcp_sock_read_txrx
Quoted 8 lines · Eric Dumazet
Fill a hole in
tcp_sock_read_txrx, instead of possibly wasting a cache line.Note that
tcp_recvmsg_locked()is also readingtp->repair, so this removes one cache line miss in tcprecvmsg().Signed-off-by Eric Dumazet <[email protected]>
PATCH v2 6/8 tcp: move tcp_clean_acked to tcp_sock_read_tx group
In reply to Eric Dumazettp->tcp_clean_acked is fetched in tx path when snd_una is updated.
This field thus belongs to tcp_sock_read_tx group.
--- Documentation/networking/net_cachelines/tcp_sock.rst | 2 +- include/linux/tcp.h | 6 +++--- net/ipv4/tcp.c | 6 +++--- 3 files changed, 7 insertions(+), 7 deletions(-)
Documentation/networking/net_cachelines/tcp_sock.rst +1 -1
@@ -27,7 +27,7 @@ u32 dsack_dups u32 snd_una read_mostly read_write tcp_wnd_end,tcp_urg_mode,tcp_minshall_check,tcp_cwnd_validate(tx);tcp_ack,tcp_may_update_window,tcp_clean_rtx_queue(write),tcp_ack_tstamp(rx) u32 snd_sml read_write tcp_minshall_check,tcp_minshall_update u32 rcv_tstamp read_write read_write tcp_ack -void * tcp_clean_acked read_mostly tcp_ack +void * tcp_clean_acked read_mostly tcp_ack u32 lsndtime read_write tcp_slow_start_after_idle_check,tcp_event_data_sent u32 last_oow_ack_time u32 compressed_ack_rcv_nxt
include/linux/tcp.h +3 -3
@@ -215,6 +215,9 @@ struct tcp_sock {u16 gso_segs;/* Max number of segs per GSO packet */ /* from STCP, retrans queue hinting */ struct sk_buff *retransmit_skb_hint; +#if defined(CONFIG_TLS_DEVICE ) +void (*tcp_clean_acked)(struct sock *sk,u32 acked_seq); +#endif __cacheline_group_end (tcp_sock_read_tx);/* TXRX read-mostly hotpath cache lines */
@@ -250,9 +253,6 @@ struct tcp_sock {struct minmax rtt_min;/* OOO segments go in this rbtree. Socket lock must be held. */ struct rb_root out_of_order_queue; -#if defined(CONFIG_TLS_DEVICE ) -void (*tcp_clean_acked)(struct sock *sk,u32 acked_seq); -#endif __cacheline_group_end (tcp_sock_read_rx);/* TX read-write hotpath cache lines */
net/ipv4/tcp.c +3 -3
@@ -5101,6 +5101,9 @@ static void __init tcp_struct_check(void) CACHELINE_ASSERT_GROUP_MEMBER(struct tcp_sock, tcp_sock_read_tx, notsent_lowat); CACHELINE_ASSERT_GROUP_MEMBER(struct tcp_sock, tcp_sock_read_tx, gso_segs); CACHELINE_ASSERT_GROUP_MEMBER(struct tcp_sock, tcp_sock_read_tx, retransmit_skb_hint); +#if IS_ENABLED (CONFIG_TLS_DEVICE ) + CACHELINE_ASSERT_GROUP_MEMBER(struct tcp_sock, tcp_sock_read_tx, tcp_clean_acked); +#endif /* TXRX read-mostly hotpath cache lines */ CACHELINE_ASSERT_GROUP_MEMBER(struct tcp_sock, tcp_sock_read_txrx, tsoffset);
@@ -5124,9 +5127,6 @@ static void __init tcp_struct_check(void) CACHELINE_ASSERT_GROUP_MEMBER(struct tcp_sock, tcp_sock_read_rx, rtt_min); CACHELINE_ASSERT_GROUP_MEMBER(struct tcp_sock, tcp_sock_read_rx, out_of_order_queue); CACHELINE_ASSERT_GROUP_MEMBER(struct tcp_sock, tcp_sock_read_rx, snd_ssthresh); -#if IS_ENABLED (CONFIG_TLS_DEVICE ) - CACHELINE_ASSERT_GROUP_MEMBER(struct tcp_sock, tcp_sock_read_rx, tcp_clean_acked); -#endif /* TX read-write hotpath cache lines */ CACHELINE_ASSERT_GROUP_MEMBER(struct tcp_sock, tcp_sock_write_tx, segs_out);
Signature · 1 line
2.51.0.470.ga7dc726c21-goog
Re: [PATCH v2 net-next 6/8] tcp: move tcp_clean_acked to tcp_sock_read_tx group
Quoted 6 lines · Eric Dumazet
tp->tcp_clean_ackedis fetched in tx path whensnd_unais updated.This field thus belongs to
tcp_sock_read_txgroup.Signed-off-by Eric Dumazet <[email protected]>
PATCH v2 7/8 tcp: move mtu_info to remove two 32bit holes
In reply to Eric DumazetThis removes 8bytes waste on 64bit builds.
--- include/linux/tcp.h | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
include/linux/tcp.h +3 -3
@@ -448,6 +448,9 @@ struct tcp_sock {* the first SYN. */ u32 undo_marker;/* snd_una upon a new recovery episode. */ int undo_retrans;/* number of undoable retransmissions. */ +u32 mtu_info;/* We received an ICMP_FRAG_NEEDED / ICMPV6_PKT_TOOBIG +* while socket was owned by user. +*/ u64 bytes_retrans;/* RFC4898 tcpEStatsPerfOctetsRetrans * Total data bytes retransmitted */
@@ -494,9 +497,6 @@ struct tcp_sock {u32 probe_seq_end; } mtu_probe;u32 plb_rehash;/* PLB-triggered rehash attempts */ -u32 mtu_info;/* We received an ICMP_FRAG_NEEDED / ICMPV6_PKT_TOOBIG -* while socket was owned by user. -*/ #if IS_ENABLED (CONFIG_MPTCP )bool is_mptcp;#endif
Signature · 1 line
2.51.0.470.ga7dc726c21-goog
Re: [PATCH v2 net-next 7/8] tcp: move mtu_info to remove two 32bit holes
Quoted 4 lines · Eric Dumazet
This removes 8bytes waste on 64bit builds.
Signed-off-by Eric Dumazet <[email protected]>
PATCH v2 8/8 tcp: reclaim 8 bytes in struct request_sock_queue
In reply to Eric Dumazetsynflood_warned had to be u32 for xchg(), but ensuring atomicity is not really needed.
--- include/net/request_sock.h | 2 +- net/ipv4/tcp_input.c | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-)
include/net/request_sock.h +1 -1
@@ -185,8 +185,8 @@ struct fastopen_queue {struct request_sock_queue {spinlock_t rskq_lock;u8 rskq_defer_accept; +u8 synflood_warned; -u32 synflood_warned;atomic_t qlen;atomic_t young;
net/ipv4/tcp_input.c +2 -2
@@ -7282,8 +7282,8 @@ static bool tcp_syn_flood_action(struct sock *sk, const char *proto)#endif __NET_INC_STATS (sock_net (sk),LINUX_MIB_TCPREQQFULLDROP ); -if (!READ_ONCE (queue->synflood_warned) && syncookies !=2 && -xchg (&queue->synflood_warned,1 ) ==0 ) { +if (syncookies !=2 && !READ_ONCE (queue->synflood_warned)) { +WRITE_ONCE (queue->synflood_warned,1 );if (IS_ENABLED (CONFIG_IPV6 ) && sk->sk_family ==AF_INET6 ) { net_info_ratelimited("%s: Possible SYN flooding on port [%pI6c]:%u. %s.\n", proto, inet6_rcv_saddr(sk),
Signature · 1 line
2.51.0.470.ga7dc726c21-goog
Re: [PATCH v2 net-next 8/8] tcp: reclaim 8 bytes in struct request_sock_queue
Quoted 5 lines · Eric Dumazet
synflood_warnedhad to be u32 forxchg(), but ensuring atomicity is not really needed.Signed-off-by Eric Dumazet <[email protected]>
Thanks!
This series was applied to netdev/net-next.git (main) by Jakub Kicinski <[email protected]>:
Hello:
This series was applied to netdev/net-next.git (main) by Jakub Kicinski <[email protected]>:
Quoted 8 lines · On Fri, 19 Sep 2025 20:48:48 +0000 you wrote:
After recent additions (PSP and AccECN) I wanted to make another round on fields locations to increase data locality.
This series manages to shrink TCP and TCPv6 objects by 128 bytes, but more importantly should reduce number of touched cache lines in TCP fast paths.
[...]
Here is the summary with links:
- [v2,net-next,1/8] net: move sk_uid and sk_protocol to sock_read_tx
https://git.kernel.org/netdev/net-next/c/17b14d235f58 - [v2,net-next,2/8] net: move sk->sk_err_soft and sk->sk_sndbuf https://git.kernel.org/netdev/net-next/c/9303c3ced111 - [v2,net-next,3/8] tcp: remove CACHELINE_ASSERT_GROUP_SIZE() uses https://git.kernel.org/netdev/net-next/c/e1b022c2bdf1 - [v2,net-next,4/8] tcp: move tcp->rcv_tstamp to tcp_sock_write_txrx group https://git.kernel.org/netdev/net-next/c/1b44d700023e - [v2,net-next,5/8] tcp: move recvmsg_inq to tcp_sock_read_txrx https://git.kernel.org/netdev/net-next/c/969904dcd77d - [v2,net-next,6/8] tcp: move tcp_clean_acked to tcp_sock_read_tx group https://git.kernel.org/netdev/net-next/c/a105ea47a4e8 - [v2,net-next,7/8] tcp: move mtu_info to remove two 32bit holes https://git.kernel.org/netdev/net-next/c/31c4511bbb0c - [v2,net-next,8/8] tcp: reclaim 8 bytes in struct request_sock_queue https://git.kernel.org/netdev/net-next/c/649091ef597b
You are awesome, thank you!
Signature · 2 lines
Deet-doot-dot, I am a bot. https://korg.docs.kernel.org/patchwork/pwbot.html