* [PATCH net-next] tcp: move tcp_stream_memory_free() to tcp.c
@ 2026-01-22 9:02 Eric Dumazet
2026-01-22 15:19 ` Neal Cardwell
2026-01-23 18:50 ` patchwork-bot+netdevbpf
0 siblings, 2 replies; 3+ messages in thread
From: Eric Dumazet @ 2026-01-22 9:02 UTC (permalink / raw)
To: David S . Miller, Jakub Kicinski, Paolo Abeni
Cc: Simon Horman, Neal Cardwell, Kuniyuki Iwashima, netdev,
eric.dumazet, Eric Dumazet
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 <edumazet@google.com>
---
net/ipv4/tcp.c | 13 +++++++++++++
net/ipv4/tcp_ipv4.c | 14 --------------
2 files changed, 13 insertions(+), 14 deletions(-)
diff --git a/net/ipv4/tcp.c b/net/ipv4/tcp.c
index d5319ebe24525ef9c1f0ea0297eb6c70878e0b29..e4c7cc19de3d9eb45c176ff7e2f71ac5b4f6cd5f 100644
--- a/net/ipv4/tcp.c
+++ b/net/ipv4/tcp.c
@@ -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))
diff --git a/net/ipv4/tcp_ipv4.c b/net/ipv4/tcp_ipv4.c
index f8a9596e8f4d41563896f02329d20b731fe7961f..ffdf52fbf6463b41d7c712f3710b681ecdf6e2d7 100644
--- a/net/ipv4/tcp_ipv4.c
+++ b/net/ipv4/tcp_ipv4.c
@@ -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,
--
2.52.0.457.g6b5491de43-goog
^ permalink raw reply related [flat|nested] 3+ messages in thread* Re: [PATCH net-next] tcp: move tcp_stream_memory_free() to tcp.c
2026-01-22 9:02 [PATCH net-next] tcp: move tcp_stream_memory_free() to tcp.c Eric Dumazet
@ 2026-01-22 15:19 ` Neal Cardwell
2026-01-23 18:50 ` patchwork-bot+netdevbpf
1 sibling, 0 replies; 3+ messages in thread
From: Neal Cardwell @ 2026-01-22 15:19 UTC (permalink / raw)
To: Eric Dumazet
Cc: David S . Miller, Jakub Kicinski, Paolo Abeni, Simon Horman,
Kuniyuki Iwashima, netdev, eric.dumazet
On Thu, Jan 22, 2026 at 4:02 AM Eric Dumazet <edumazet@google.com> wrote:
>
> 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 <edumazet@google.com>
> ---
Reviewed-by: Neal Cardwell <ncardwell@google.com>
Thanks, Eric!
neal
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH net-next] tcp: move tcp_stream_memory_free() to tcp.c
2026-01-22 9:02 [PATCH net-next] tcp: move tcp_stream_memory_free() to tcp.c Eric Dumazet
2026-01-22 15:19 ` Neal Cardwell
@ 2026-01-23 18:50 ` patchwork-bot+netdevbpf
1 sibling, 0 replies; 3+ messages in thread
From: patchwork-bot+netdevbpf @ 2026-01-23 18:50 UTC (permalink / raw)
To: Eric Dumazet
Cc: davem, kuba, pabeni, horms, ncardwell, kuniyu, netdev,
eric.dumazet
Hello:
This patch was applied to netdev/net-next.git (main)
by Jakub Kicinski <kuba@kernel.org>:
On Thu, 22 Jan 2026 09:02:27 +0000 you wrote:
> 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%
>
> [...]
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!
--
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2026-01-23 18:50 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-01-22 9:02 [PATCH net-next] tcp: move tcp_stream_memory_free() to tcp.c Eric Dumazet
2026-01-22 15:19 ` Neal Cardwell
2026-01-23 18:50 ` patchwork-bot+netdevbpf
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox