Skip to content

Commit 87b0891

Browse files
edumazetkuba-moo
authored andcommitted
inet: move icmp_global_{credit,stamp} to a separate cache line
icmp_global_credit was meant to be changed ~1000 times per second, but if an admin sets net.ipv4.icmp_msgs_per_sec to a very high value, icmp_global_credit changes can inflict false sharing to surrounding fields that are read mostly. Move icmp_global_credit and icmp_global_stamp to a separate cacheline aligned group. Fixes: b056b4c ("icmp: move icmp_global.credit and icmp_global.stamp to per netns storage") Signed-off-by: Eric Dumazet <edumazet@google.com> Reviewed-by: Kuniyuki Iwashima <kuniyu@google.com> Link: https://patch.msgid.link/20260216142832.3834174-3-edumazet@google.com Signed-off-by: Jakub Kicinski <kuba@kernel.org>
1 parent 034bbd8 commit 87b0891

1 file changed

Lines changed: 7 additions & 2 deletions

File tree

include/net/netns/ipv4.h

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,12 @@ struct netns_ipv4 {
8888
int sysctl_tcp_rcvbuf_low_rtt;
8989
__cacheline_group_end(netns_ipv4_read_rx);
9090

91+
/* ICMP rate limiter hot cache line. */
92+
__cacheline_group_begin_aligned(icmp);
93+
atomic_t icmp_global_credit;
94+
u32 icmp_global_stamp;
95+
__cacheline_group_end_aligned(icmp);
96+
9197
struct inet_timewait_death_row tcp_death_row;
9298
struct udp_table *udp_table;
9399

@@ -141,8 +147,7 @@ struct netns_ipv4 {
141147
int sysctl_icmp_ratemask;
142148
int sysctl_icmp_msgs_per_sec;
143149
int sysctl_icmp_msgs_burst;
144-
atomic_t icmp_global_credit;
145-
u32 icmp_global_stamp;
150+
146151
u32 ip_rt_min_pmtu;
147152
int ip_rt_mtu_expires;
148153
int ip_rt_min_advmss;

0 commit comments

Comments
 (0)