* [PATCH net-next] tcp: move tcp_rbtree_insert() to tcp_output.c
@ 2026-02-03 4:51 Eric Dumazet
2026-02-04 0:27 ` Kuniyuki Iwashima
2026-02-05 4:50 ` patchwork-bot+netdevbpf
0 siblings, 2 replies; 3+ messages in thread
From: Eric Dumazet @ 2026-02-03 4:51 UTC (permalink / raw)
To: David S . Miller, Jakub Kicinski, Paolo Abeni
Cc: Simon Horman, Neal Cardwell, Kuniyuki Iwashima, netdev,
eric.dumazet, Eric Dumazet
tcp_rbtree_insert() is primarily used from tcp_output.c
In tcp_input.c, only (slow path) tcp_collapse() uses it.
Move it to tcp_output.c to allow its (auto)inlining to improve
TCP tx fast path.
$ scripts/bloat-o-meter -t vmlinux.old vmlinux.new
add/remove: 0/0 grow/shrink: 4/1 up/down: 445/-115 (330)
Function old new delta
tcp_connect 4277 4478 +201
tcp_event_new_data_sent 162 248 +86
tcp_send_synack 780 862 +82
tcp_fragment 1185 1261 +76
tcp_collapse 1524 1409 -115
Total: Before=24896043, After=24896373, chg +0.00%
Signed-off-by: Eric Dumazet <edumazet@google.com>
---
net/ipv4/tcp_input.c | 19 -------------------
net/ipv4/tcp_output.c | 19 +++++++++++++++++++
2 files changed, 19 insertions(+), 19 deletions(-)
diff --git a/net/ipv4/tcp_input.c b/net/ipv4/tcp_input.c
index a2a872382fc0..10f864179982 100644
--- a/net/ipv4/tcp_input.c
+++ b/net/ipv4/tcp_input.c
@@ -5756,25 +5756,6 @@ static struct sk_buff *tcp_collapse_one(struct sock *sk, struct sk_buff *skb,
return next;
}
-/* Insert skb into rb tree, ordered by TCP_SKB_CB(skb)->seq */
-void tcp_rbtree_insert(struct rb_root *root, struct sk_buff *skb)
-{
- struct rb_node **p = &root->rb_node;
- struct rb_node *parent = NULL;
- struct sk_buff *skb1;
-
- while (*p) {
- parent = *p;
- skb1 = rb_to_skb(parent);
- if (before(TCP_SKB_CB(skb)->seq, TCP_SKB_CB(skb1)->seq))
- p = &parent->rb_left;
- else
- p = &parent->rb_right;
- }
- rb_link_node(&skb->rbnode, parent, p);
- rb_insert_color(&skb->rbnode, root);
-}
-
/* Collapse contiguous sequence of skbs head..tail with
* sequence numbers start..end.
*
diff --git a/net/ipv4/tcp_output.c b/net/ipv4/tcp_output.c
index f907f24f74f7..b09f2bcfc237 100644
--- a/net/ipv4/tcp_output.c
+++ b/net/ipv4/tcp_output.c
@@ -66,6 +66,25 @@ void tcp_mstamp_refresh(struct tcp_sock *tp)
static bool tcp_write_xmit(struct sock *sk, unsigned int mss_now, int nonagle,
int push_one, gfp_t gfp);
+/* Insert skb into rb tree, ordered by TCP_SKB_CB(skb)->seq */
+void tcp_rbtree_insert(struct rb_root *root, struct sk_buff *skb)
+{
+ struct rb_node **p = &root->rb_node;
+ struct rb_node *parent = NULL;
+ struct sk_buff *skb1;
+
+ while (*p) {
+ parent = *p;
+ skb1 = rb_to_skb(parent);
+ if (before(TCP_SKB_CB(skb)->seq, TCP_SKB_CB(skb1)->seq))
+ p = &parent->rb_left;
+ else
+ p = &parent->rb_right;
+ }
+ rb_link_node(&skb->rbnode, parent, p);
+ rb_insert_color(&skb->rbnode, root);
+}
+
/* Account for new data that has been sent to the network. */
static void tcp_event_new_data_sent(struct sock *sk, struct sk_buff *skb)
{
--
2.53.0.rc1.225.gd81095ad13-goog
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH net-next] tcp: move tcp_rbtree_insert() to tcp_output.c
2026-02-03 4:51 [PATCH net-next] tcp: move tcp_rbtree_insert() to tcp_output.c Eric Dumazet
@ 2026-02-04 0:27 ` Kuniyuki Iwashima
2026-02-05 4:50 ` patchwork-bot+netdevbpf
1 sibling, 0 replies; 3+ messages in thread
From: Kuniyuki Iwashima @ 2026-02-04 0:27 UTC (permalink / raw)
To: Eric Dumazet
Cc: David S . Miller, Jakub Kicinski, Paolo Abeni, Simon Horman,
Neal Cardwell, netdev, eric.dumazet
On Mon, Feb 2, 2026 at 8:51 PM Eric Dumazet <edumazet@google.com> wrote:
>
> tcp_rbtree_insert() is primarily used from tcp_output.c
> In tcp_input.c, only (slow path) tcp_collapse() uses it.
>
> Move it to tcp_output.c to allow its (auto)inlining to improve
> TCP tx fast path.
>
> $ scripts/bloat-o-meter -t vmlinux.old vmlinux.new
> add/remove: 0/0 grow/shrink: 4/1 up/down: 445/-115 (330)
> Function old new delta
> tcp_connect 4277 4478 +201
> tcp_event_new_data_sent 162 248 +86
> tcp_send_synack 780 862 +82
> tcp_fragment 1185 1261 +76
> tcp_collapse 1524 1409 -115
> Total: Before=24896043, After=24896373, chg +0.00%
>
> Signed-off-by: Eric Dumazet <edumazet@google.com>
Reviewed-by: Kuniyuki Iwashima <kuniyu@google.com>
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH net-next] tcp: move tcp_rbtree_insert() to tcp_output.c
2026-02-03 4:51 [PATCH net-next] tcp: move tcp_rbtree_insert() to tcp_output.c Eric Dumazet
2026-02-04 0:27 ` Kuniyuki Iwashima
@ 2026-02-05 4:50 ` patchwork-bot+netdevbpf
1 sibling, 0 replies; 3+ messages in thread
From: patchwork-bot+netdevbpf @ 2026-02-05 4: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 Tue, 3 Feb 2026 04:51:10 +0000 you wrote:
> tcp_rbtree_insert() is primarily used from tcp_output.c
> In tcp_input.c, only (slow path) tcp_collapse() uses it.
>
> Move it to tcp_output.c to allow its (auto)inlining to improve
> TCP tx fast path.
>
> $ scripts/bloat-o-meter -t vmlinux.old vmlinux.new
> add/remove: 0/0 grow/shrink: 4/1 up/down: 445/-115 (330)
> Function old new delta
> tcp_connect 4277 4478 +201
> tcp_event_new_data_sent 162 248 +86
> tcp_send_synack 780 862 +82
> tcp_fragment 1185 1261 +76
> tcp_collapse 1524 1409 -115
> Total: Before=24896043, After=24896373, chg +0.00%
>
> [...]
Here is the summary with links:
- [net-next] tcp: move tcp_rbtree_insert() to tcp_output.c
https://git.kernel.org/netdev/net-next/c/7c1db78ff75f
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-02-05 4:50 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-02-03 4:51 [PATCH net-next] tcp: move tcp_rbtree_insert() to tcp_output.c Eric Dumazet
2026-02-04 0:27 ` Kuniyuki Iwashima
2026-02-05 4: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