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: split tcp_check_space() in two parts

tcp_check_space() is fat and not inlined.

Move its slow path in (out of line) __tcp_check_space()
and make tcp_check_space() an inline function for better TCP performance.

$ scripts/bloat-o-meter -t vmlinux.old vmlinux.new
add/remove: 2/2 grow/shrink: 4/0 up/down: 708/-582 (126)
Function old new delta
__tcp_check_space - 521 +521
tcp_rcv_established 1860 1916 +56
tcp_rcv_state_process 3342 3384 +42
tcp_event_new_data_sent 248 286 +38
tcp_data_snd_check 71 106 +35
__pfx___tcp_check_space - 16 +16
__pfx_tcp_check_space 16 - -16
tcp_check_space 566 - -566
Total: Before=24896373, After=24896499, chg +0.00%

Signed-off-by: Eric Dumazet <edumazet@google.com>
Reviewed-by: Kuniyuki Iwashima <kuniyu@google.com>
Link: https://patch.msgid.link/20260203050932.3522221-1-edumazet@google.com
Signed-off-by: Jakub Kicinski <kuba@kernel.org>

authored by

Eric Dumazet and committed by
Jakub Kicinski
309dd994 7c1db78f

+13 -10
+9 -1
include/net/tcp.h
··· 763 763 void tcp_done_with_error(struct sock *sk, int err); 764 764 void tcp_reset(struct sock *sk, struct sk_buff *skb); 765 765 void tcp_fin(struct sock *sk); 766 - void tcp_check_space(struct sock *sk); 766 + void __tcp_check_space(struct sock *sk); 767 + static inline void tcp_check_space(struct sock *sk) 768 + { 769 + /* pairs with tcp_poll() */ 770 + smp_mb(); 771 + 772 + if (sk->sk_socket && test_bit(SOCK_NOSPACE, &sk->sk_socket->flags)) 773 + __tcp_check_space(sk); 774 + } 767 775 void tcp_sack_compress_send_ack(struct sock *sk); 768 776 769 777 static inline void tcp_cleanup_skb(struct sk_buff *skb)
+4 -9
net/ipv4/tcp_input.c
··· 6118 6118 * small enough that tcp_stream_memory_free() decides it 6119 6119 * is time to generate EPOLLOUT. 6120 6120 */ 6121 - void tcp_check_space(struct sock *sk) 6121 + void __tcp_check_space(struct sock *sk) 6122 6122 { 6123 - /* pairs with tcp_poll() */ 6124 - smp_mb(); 6125 - if (sk->sk_socket && 6126 - test_bit(SOCK_NOSPACE, &sk->sk_socket->flags)) { 6127 - tcp_new_space(sk); 6128 - if (!test_bit(SOCK_NOSPACE, &sk->sk_socket->flags)) 6129 - tcp_chrono_stop(sk, TCP_CHRONO_SNDBUF_LIMITED); 6130 - } 6123 + tcp_new_space(sk); 6124 + if (!test_bit(SOCK_NOSPACE, &sk->sk_socket->flags)) 6125 + tcp_chrono_stop(sk, TCP_CHRONO_SNDBUF_LIMITED); 6131 6126 } 6132 6127 6133 6128 static inline void tcp_data_snd_check(struct sock *sk)