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 sk_forced_mem_schedule() to tcp.c

TCP fast path can (auto)inline this helper, instead
of (auto)inling it from tcp_send_fin().

No change of overall code size, but tcp_sendmsg() is faster.

$ scripts/bloat-o-meter -t vmlinux.old vmlinux.new
add/remove: 0/0 grow/shrink: 1/1 up/down: 141/-140 (1)
Function old new delta
tcp_stream_alloc_skb 216 357 +141
tcp_send_fin 688 548 -140
Total: Before=22236729, After=22236730, chg +0.00%

BTW, we might change tcp_send_fin() to use tcp_stream_alloc_skb().

Signed-off-by: Eric Dumazet <edumazet@google.com>
Reviewed-by: Neal Cardwell <ncardwell@google.com>
Link: https://patch.msgid.link/20260123111605.4089200-1-edumazet@google.com
Signed-off-by: Paolo Abeni <pabeni@redhat.com>

authored by

Eric Dumazet and committed by
Paolo Abeni
a18056a6 4778a04c

+27 -27
+27
net/ipv4/tcp.c
··· 915 915 } 916 916 EXPORT_IPV6_MOD(tcp_splice_read); 917 917 918 + /* We allow to exceed memory limits for FIN packets to expedite 919 + * connection tear down and (memory) recovery. 920 + * Otherwise tcp_send_fin() could be tempted to either delay FIN 921 + * or even be forced to close flow without any FIN. 922 + * In general, we want to allow one skb per socket to avoid hangs 923 + * with edge trigger epoll() 924 + */ 925 + void sk_forced_mem_schedule(struct sock *sk, int size) 926 + { 927 + int delta, amt; 928 + 929 + delta = size - sk->sk_forward_alloc; 930 + if (delta <= 0) 931 + return; 932 + 933 + amt = sk_mem_pages(delta); 934 + sk_forward_alloc_add(sk, amt << PAGE_SHIFT); 935 + 936 + if (mem_cgroup_sk_enabled(sk)) 937 + mem_cgroup_sk_charge(sk, amt, gfp_memcg_charge() | __GFP_NOFAIL); 938 + 939 + if (sk->sk_bypass_prot_mem) 940 + return; 941 + 942 + sk_memory_allocated_add(sk, amt); 943 + } 944 + 918 945 struct sk_buff *tcp_stream_alloc_skb(struct sock *sk, gfp_t gfp, 919 946 bool force_schedule) 920 947 {
-27
net/ipv4/tcp_output.c
··· 3767 3767 inet_csk(sk)->icsk_rto, true); 3768 3768 } 3769 3769 3770 - /* We allow to exceed memory limits for FIN packets to expedite 3771 - * connection tear down and (memory) recovery. 3772 - * Otherwise tcp_send_fin() could be tempted to either delay FIN 3773 - * or even be forced to close flow without any FIN. 3774 - * In general, we want to allow one skb per socket to avoid hangs 3775 - * with edge trigger epoll() 3776 - */ 3777 - void sk_forced_mem_schedule(struct sock *sk, int size) 3778 - { 3779 - int delta, amt; 3780 - 3781 - delta = size - sk->sk_forward_alloc; 3782 - if (delta <= 0) 3783 - return; 3784 - 3785 - amt = sk_mem_pages(delta); 3786 - sk_forward_alloc_add(sk, amt << PAGE_SHIFT); 3787 - 3788 - if (mem_cgroup_sk_enabled(sk)) 3789 - mem_cgroup_sk_charge(sk, amt, gfp_memcg_charge() | __GFP_NOFAIL); 3790 - 3791 - if (sk->sk_bypass_prot_mem) 3792 - return; 3793 - 3794 - sk_memory_allocated_add(sk, amt); 3795 - } 3796 - 3797 3770 /* Send a FIN. The caller locks the socket for us. 3798 3771 * We should try to send a FIN packet really hard, but eventually give up. 3799 3772 */