]> git.ipfire.org Git - thirdparty/kernel/linux.git/commit
inet_diag: avoid cache line misses in inet_diag_bc_sk()
authorEric Dumazet <edumazet@google.com>
Thu, 28 Aug 2025 10:27:38 +0000 (10:27 +0000)
committerJakub Kicinski <kuba@kernel.org>
Sat, 30 Aug 2025 02:29:24 +0000 (19:29 -0700)
commit95fa78830e5b2eb2041174c7f9549c746e003dd6
tree61e4192b22fe88910082096dcf0e76e3d84e19d3
parent9529320ad64e614cfaf96e6b8e3d8c0a1245160c
inet_diag: avoid cache line misses in inet_diag_bc_sk()

inet_diag_bc_sk() pulls five cache lines per socket,
while most filters only need the two first ones.

Add three booleans to struct inet_diag_dump_data,
that are selectively set if a filter needs specific socket fields.

- mark_needed       /* INET_DIAG_BC_MARK_COND present. */
- cgroup_needed     /* INET_DIAG_BC_CGROUP_COND present. */
- userlocks_needed  /* INET_DIAG_BC_AUTO present. */

This removes millions of cache lines misses per ss invocation
when simple filters are specified on busy servers.

offsetof(struct sock, sk_userlocks) = 0xf3
offsetof(struct sock, sk_mark) = 0x20c
offsetof(struct sock, sk_cgrp_data) = 0x298

Signed-off-by: Eric Dumazet <edumazet@google.com>
Reviewed-by: Kuniyuki Iwashima <kuniyu@google.com>
Link: https://patch.msgid.link/20250828102738.2065992-6-edumazet@google.com
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
include/linux/inet_diag.h
net/ipv4/inet_diag.c