Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

tcp: move tcp_rbtree_insert() to tcp_output.c

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>
Link: https://patch.msgid.link/20260203045110.3499713-1-edumazet@google.com
Signed-off-by: Jakub Kicinski <kuba@kernel.org>

authored by

Eric Dumazet and committed by
Jakub Kicinski
7c1db78f 59b5e7f4

+19 -19
-19
net/ipv4/tcp_input.c
··· 5785 5785 return next; 5786 5786 } 5787 5787 5788 - /* Insert skb into rb tree, ordered by TCP_SKB_CB(skb)->seq */ 5789 - void tcp_rbtree_insert(struct rb_root *root, struct sk_buff *skb) 5790 - { 5791 - struct rb_node **p = &root->rb_node; 5792 - struct rb_node *parent = NULL; 5793 - struct sk_buff *skb1; 5794 - 5795 - while (*p) { 5796 - parent = *p; 5797 - skb1 = rb_to_skb(parent); 5798 - if (before(TCP_SKB_CB(skb)->seq, TCP_SKB_CB(skb1)->seq)) 5799 - p = &parent->rb_left; 5800 - else 5801 - p = &parent->rb_right; 5802 - } 5803 - rb_link_node(&skb->rbnode, parent, p); 5804 - rb_insert_color(&skb->rbnode, root); 5805 - } 5806 - 5807 5788 /* Collapse contiguous sequence of skbs head..tail with 5808 5789 * sequence numbers start..end. 5809 5790 *
+19
net/ipv4/tcp_output.c
··· 66 66 static bool tcp_write_xmit(struct sock *sk, unsigned int mss_now, int nonagle, 67 67 int push_one, gfp_t gfp); 68 68 69 + /* Insert skb into rb tree, ordered by TCP_SKB_CB(skb)->seq */ 70 + void tcp_rbtree_insert(struct rb_root *root, struct sk_buff *skb) 71 + { 72 + struct rb_node **p = &root->rb_node; 73 + struct rb_node *parent = NULL; 74 + struct sk_buff *skb1; 75 + 76 + while (*p) { 77 + parent = *p; 78 + skb1 = rb_to_skb(parent); 79 + if (before(TCP_SKB_CB(skb)->seq, TCP_SKB_CB(skb1)->seq)) 80 + p = &parent->rb_left; 81 + else 82 + p = &parent->rb_right; 83 + } 84 + rb_link_node(&skb->rbnode, parent, p); 85 + rb_insert_color(&skb->rbnode, root); 86 + } 87 + 69 88 /* Account for new data that has been sent to the network. */ 70 89 static void tcp_event_new_data_sent(struct sock *sk, struct sk_buff *skb) 71 90 {