tcp: move tcp_stream_memory_free() to tcp.c
Subsystems (3)
PATCH 1/1 tcp: move tcp_stream_memory_free() to tcp.c
Moving tcp_stream_memory_free() to tcp.c allows the compiler to (auto)inline it from tcp_poll() and tcp_sendmsg_locked() for better performance.
$ scripts/bloat-o-meter -t vmlinux.old vmlinux.new add/remove: 0/0 grow/shrink: 2/0 up/down: 118/0 (118) Function old new delta tcp_poll 840 923 +83 tcp_sendmsg_locked 4217 4252 +35 Total: Before=22573095, After=22573213, chg +0.00%
Signed-off-by Eric Dumazet <[email protected]>
--- net/ipv4/tcp.c | 13 +++++++++++++ net/ipv4/tcp_ipv4.c | 14 -------------- 2 files changed, 13 insertions(+), 14 deletions(-)
net/ipv4/tcp.c +13 -0
@@ -517,6 +517,19 @@ static void tcp_tx_timestamp(struct sock *sk, struct sockcm_cookie *sockc)bpf_skops_tx_timestamping (sk, skb,BPF_SOCK_OPS_TSTAMP_SENDMSG_CB ); } +/* @wake is one when sk_stream_write_space() calls us. +* This sends EPOLLOUT only if notsent_bytes is half the limit. +* This mimics the strategy used in sock_def_write_space(). +*/ +bool tcp_stream_memory_free (const struct sock *sk,int wake) +{ +const struct tcp_sock *tp =tcp_sk (sk); +u32 notsent_bytes =READ_ONCE (tp->write_seq) -READ_ONCE (tp->snd_nxt); + +return (notsent_bytes << wake) <tcp_notsent_lowat (tp); +} +EXPORT_SYMBOL (tcp_stream_memory_free); +static bool tcp_stream_is_readable (struct sock *sk,int target) {if (tcp_epollin_ready (sk, target))
net/ipv4/tcp_ipv4.c +0 -14
@@ -3418,20 +3418,6 @@ void tcp4_proc_exit(void) }#endif /* CONFIG_PROC_FS */ -/* @wake is one when sk_stream_write_space() calls us. -* This sends EPOLLOUT only if notsent_bytes is half the limit. -* This mimics the strategy used in sock_def_write_space(). -*/ -bool tcp_stream_memory_free (const struct sock *sk,int wake) -{ -const struct tcp_sock *tp =tcp_sk (sk); -u32 notsent_bytes =READ_ONCE (tp->write_seq) - -READ_ONCE (tp->snd_nxt); - -return (notsent_bytes << wake) <tcp_notsent_lowat (tp); -} -EXPORT_SYMBOL (tcp_stream_memory_free); -struct proto tcp_prot = { .name ="TCP" , .owner =THIS_MODULE ,
Signature · 1 line
2.52.0.457.g6b5491de43-goog
Quoted 12 lines · Eric Dumazet
Moving
tcp_stream_memory_free()totcp.callows the compiler to (auto)inline it fromtcp_poll()andtcp_sendmsg_locked()for better performance.$ scripts/bloat-o-meter -t vmlinux.old vmlinux.new add/remove: 0/0 grow/shrink: 2/0 up/down: 118/0 (118) Function old new delta tcp_poll 840 923 +83 tcp_sendmsg_locked 4217 4252 +35 Total: Before=22573095, After=22573213, chg +0.00%
Quoted 2 lines
Signed-off-by Eric Dumazet <[email protected]>---
Reviewed-by Neal Cardwell <[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 4 lines · On Thu, 22 Jan 2026 09:02:27 +0000 you wrote:
Moving
tcp_stream_memory_free()totcp.callows the compiler to (auto)inline it fromtcp_poll()andtcp_sendmsg_locked()for better performance.
Quoted 8 lines
$ scripts/bloat-o-meter -t vmlinux.old vmlinux.new add/remove: 0/0 grow/shrink: 2/0 up/down: 118/0 (118) Function old new delta tcp_poll 840 923 +83 tcp_sendmsg_locked 4217 4252 +35 Total: Before=22573095, After=22573213, chg +0.00%[...]
Here is the summary with links:
- [net-next] tcp: move tcp_stream_memory_free() to tcp.c
https://git.kernel.org/netdev/net-next/c/1685e1770856
You are awesome, thank you!
Signature · 2 lines
Deet-doot-dot, I am a bot. https://korg.docs.kernel.org/patchwork/pwbot.html