tcp: inline tcp_chrono_start()
Subsystems (3)
PATCH 1/1 tcp: inline tcp_chrono_start()
tcp_chrono_start() is small enough, and used in TCP sendmsg() fast path (from tcp_skb_entail()).
Note clang is already inlining it from functions in tcp_output.c.
Inlining it improves performance and reduces bloat :
$ scripts/bloat-o-meter -t vmlinux.old vmlinux.new add/remove: 0/2 grow/shrink: 1/0 up/down: 1/-84 (-83) Function old new delta tcp_skb_entail 280 281 +1 __pfx_tcp_chrono_start 16 - -16 tcp_chrono_start 68 - -68 Total: Before=25192434, After=25192351, chg -0.00%
Note that tcp_chrono_stop() is too big.
--- include/net/tcp.h | 25 ++++++++++++++++++++++++- net/ipv4/tcp_output.c | 24 ------------------------ 2 files changed, 24 insertions(+), 25 deletions(-)
include/net/tcp.h +24 -1
@@ -2160,7 +2160,30 @@ enum tcp_chrono { __TCP_CHRONO_MAX, }; -void tcp_chrono_start (struct sock *sk,const enum tcp_chrono type); +static inline void tcp_chrono_set (struct tcp_sock *tp,const enum tcp_chrono new) +{ +const u32 now = tcp_jiffies32; +enum tcp_chrono old = tp->chrono_type; + +if (old >TCP_CHRONO_UNSPEC ) + tp->chrono_stat[old -1 ] += now - tp->chrono_start; + tp->chrono_start = now; + tp->chrono_type = new; +} + +static inline void tcp_chrono_start (struct sock *sk,const enum tcp_chrono type) +{ +struct tcp_sock *tp =tcp_sk (sk); + +/* If there are multiple conditions worthy of tracking in a +* chronograph then the highest priority enum takes precedence +* over the other conditions. So that if something "more interesting" +* starts happening, stop the previous chrono and start a new one. +*/ +if (type > tp->chrono_type) +tcp_chrono_set (tp, type); +} +void tcp_chrono_stop (struct sock *sk,const enum tcp_chrono type);/* This helper is needed, because skb->tcp_tsorted_anchor uses
net/ipv4/tcp_output.c +0 -24
@@ -2904,30 +2904,6 @@ static bool tcp_small_queue_check(struct sock *sk, const struct sk_buff *skb,return false; } -static void tcp_chrono_set (struct tcp_sock *tp,const enum tcp_chrono new) -{ -const u32 now = tcp_jiffies32; -enum tcp_chrono old = tp->chrono_type; - -if (old >TCP_CHRONO_UNSPEC ) - tp->chrono_stat[old -1 ] += now - tp->chrono_start; - tp->chrono_start = now; - tp->chrono_type = new; -} - -void tcp_chrono_start (struct sock *sk,const enum tcp_chrono type) -{ -struct tcp_sock *tp =tcp_sk (sk); - -/* If there are multiple conditions worthy of tracking in a -* chronograph then the highest priority enum takes precedence -* over the other conditions. So that if something "more interesting" -* starts happening, stop the previous chrono and start a new one. -*/ -if (type > tp->chrono_type) -tcp_chrono_set (tp, type); -} -void tcp_chrono_stop (struct sock *sk,const enum tcp_chrono type) {struct tcp_sock *tp =tcp_sk (sk);
Signature · 1 line
2.53.0.473.g4a7958ca14-goog
Quoted 16 lines · Eric Dumazet
tcp_chrono_start()is small enough, and used in TCPsendmsg()fast path (fromtcp_skb_entail()).Note clang is already inlining it from functions in
tcp_output.c.Inlining it improves performance and reduces bloat :
$ scripts/bloat-o-meter -t vmlinux.old vmlinux.new add/remove: 0/2 grow/shrink: 1/0 up/down: 1/-84 (-83) Function old new delta tcp_skb_entail 280 281 +1 __pfx_tcp_chrono_start 16 - -16 tcp_chrono_start 68 - -68 Total: Before=25192434, After=25192351, chg -0.00%
Quoted 3 lines
Note that
tcp_chrono_stop()is too big.Signed-off-by Eric Dumazet <[email protected]>
Thanks, Eric!
neal
This patch was applied to netdev/net-next.git (main) by Jakub Kicinski <[email protected]>:
Hello:
This patch was applied to netdev/net-next.git (main) by Jakub Kicinski <[email protected]>:
Quoted 8 lines · On Sun, 8 Mar 2026 12:35:49 +0000 you wrote:
tcp_chrono_start()is small enough, and used in TCPsendmsg()fast path (fromtcp_skb_entail()).Note clang is already inlining it from functions in
tcp_output.c.Inlining it improves performance and reduces bloat :
[...]
Here is the summary with links:
- [net-next] tcp: inline tcp_chrono_start()
https://git.kernel.org/netdev/net-next/c/d6d4ff335db2
You are awesome, thank you!
Signature · 2 lines
Deet-doot-dot, I am a bot. https://korg.docs.kernel.org/patchwork/pwbot.html