mirror of
https://github.com/torvalds/linux.git
synced 2025-12-07 20:06:24 +00:00
In {tcp6,udp6,raw6}_sock, struct ipv6_pinfo is always placed at
the beginning of a new cache line because
1. __alignof__(struct tcp_sock) is 64 due to ____cacheline_aligned
of __cacheline_group_begin(tcp_sock_write_tx)
2. __alignof__(struct udp_sock) is 64 due to ____cacheline_aligned
of struct numa_drop_counters
3. in raw6_sock, struct numa_drop_counters is placed before
struct ipv6_pinfo
. struct ipv6_pinfo is 136 bytes, but the last cache line is
only used by ipv6_fl_list:
$ pahole -C ipv6_pinfo vmlinux
struct ipv6_pinfo {
...
/* --- cacheline 2 boundary (128 bytes) --- */
struct ipv6_fl_socklist * ipv6_fl_list; /* 128 8 */
/* size: 136, cachelines: 3, members: 23 */
Let's move ipv6_fl_list from struct ipv6_pinfo to struct inet_sock
to save a full cache line for {tcp6,udp6,raw6}_sock.
Now, struct ipv6_pinfo is 128 bytes, and {tcp6,udp6,raw6}_sock have
64 bytes less, while {tcp,udp,raw}_sock retain the same size.
Before:
# grep -E "^(RAW|UDP[^L\-]|TCP)" /proc/slabinfo | awk '{print $1, "\t", $4}'
RAWv6 1408
UDPv6 1472
TCPv6 2560
RAW 1152
UDP 1280
TCP 2368
After:
# grep -E "^(RAW|UDP[^L\-]|TCP)" /proc/slabinfo | awk '{print $1, "\t", $4}'
RAWv6 1344
UDPv6 1408
TCPv6 2496
RAW 1152
UDP 1280
TCP 2368
Also, ipv6_fl_list and inet_flags (SNDFLOW bit) are placed in the
same cache line.
$ pahole -C inet_sock vmlinux
...
/* --- cacheline 11 boundary (704 bytes) was 56 bytes ago --- */
struct ipv6_pinfo * pinet6; /* 760 8 */
/* --- cacheline 12 boundary (768 bytes) --- */
struct ipv6_fl_socklist * ipv6_fl_list; /* 768 8 */
unsigned long inet_flags; /* 776 8 */
Doc churn is due to the insufficient Type column (only 1 space short).
Suggested-by: Eric Dumazet <edumazet@google.com>
Signed-off-by: Kuniyuki Iwashima <kuniyu@google.com>
Link: https://patch.msgid.link/20251014224210.2964778-1-kuniyu@google.com
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
48 lines
3.0 KiB
ReStructuredText
48 lines
3.0 KiB
ReStructuredText
.. SPDX-License-Identifier: GPL-2.0
|
|
.. Copyright (C) 2023 Google LLC
|
|
|
|
==========================================
|
|
inet_sock struct fast path usage breakdown
|
|
==========================================
|
|
|
|
======================== ===================== =================== =================== ======================================================================================================
|
|
Type Name fastpath_tx_access fastpath_rx_access comment
|
|
======================== ===================== =================== =================== ======================================================================================================
|
|
struct sock sk read_mostly read_mostly tcp_init_buffer_space,tcp_init_transfer,tcp_finish_connect,tcp_connect,tcp_send_rcvq,tcp_send_syn_data
|
|
struct ipv6_pinfo* pinet6
|
|
struct ipv6_fl_socklist* ipv6_fl_list read_mostly tcp_v6_connect,__ip6_datagram_connect,udpv6_sendmsg,rawv6_sendmsg
|
|
be16 inet_sport read_mostly __tcp_transmit_skb
|
|
be32 inet_daddr read_mostly ip_select_ident_segs
|
|
be32 inet_rcv_saddr
|
|
be16 inet_dport read_mostly __tcp_transmit_skb
|
|
u16 inet_num
|
|
be32 inet_saddr
|
|
s16 uc_ttl read_mostly __ip_queue_xmit/ip_select_ttl
|
|
u16 cmsg_flags
|
|
struct ip_options_rcu* inet_opt read_mostly __ip_queue_xmit
|
|
u16 inet_id read_mostly ip_select_ident_segs
|
|
u8 tos read_mostly ip_queue_xmit
|
|
u8 min_ttl
|
|
u8 mc_ttl
|
|
u8 pmtudisc
|
|
u8:1 recverr
|
|
u8:1 is_icsk
|
|
u8:1 freebind
|
|
u8:1 hdrincl
|
|
u8:1 mc_loop
|
|
u8:1 transparent
|
|
u8:1 mc_all
|
|
u8:1 nodefrag
|
|
u8:1 bind_address_no_port
|
|
u8:1 recverr_rfc4884
|
|
u8:1 defer_connect read_mostly tcp_sendmsg_fastopen
|
|
u8 rcv_tos
|
|
u8 convert_csum
|
|
int uc_index
|
|
int mc_index
|
|
be32 mc_addr
|
|
struct ip_mc_socklist* mc_list
|
|
struct inet_cork_full cork read_mostly __tcp_transmit_skb
|
|
struct local_port_range
|
|
======================== ===================== =================== =================== ======================================================================================================
|