Skip to content
/ linux Public

Commit c480680

Browse files
edumazetSasha Levin
authored andcommitted
inet: move icmp_global_{credit,stamp} to a separate cache line
[ Upstream commit 87b0891 ] 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> Signed-off-by: Sasha Levin <sashal@kernel.org>
1 parent 5aea79b commit c480680

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

include/net/netns/ipv4.h

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,12 @@ struct netns_ipv4 {
8080
int sysctl_tcp_rmem[3];
8181
__cacheline_group_end(netns_ipv4_read_rx);
8282

83+
/* ICMP rate limiter hot cache line. */
84+
__cacheline_group_begin_aligned(icmp);
85+
atomic_t icmp_global_credit;
86+
u32 icmp_global_stamp;
87+
__cacheline_group_end_aligned(icmp);
88+
8389
struct inet_timewait_death_row tcp_death_row;
8490
struct udp_table *udp_table;
8591

@@ -124,8 +130,7 @@ struct netns_ipv4 {
124130
int sysctl_icmp_ratemask;
125131
int sysctl_icmp_msgs_per_sec;
126132
int sysctl_icmp_msgs_burst;
127-
atomic_t icmp_global_credit;
128-
u32 icmp_global_stamp;
133+
129134
u32 ip_rt_min_pmtu;
130135
int ip_rt_mtu_expires;
131136
int ip_rt_min_advmss;

0 commit comments

Comments
 (0)