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_rate_skb_delivered() to tcp_input.c

tcp_rate_skb_delivered() is only called from tcp_input.c.
Move it there and make it static.

Both gcc and clang are (auto)inlining it, TCP performance
is increased at a small space cost.

$ scripts/bloat-o-meter -t vmlinux.old vmlinux.new
add/remove: 0/2 grow/shrink: 3/0 up/down: 509/-187 (322)
Function old new delta
tcp_sacktag_walk 1682 1867 +185
tcp_ack 5230 5405 +175
tcp_shifted_skb 437 586 +149
__pfx_tcp_rate_skb_delivered 16 - -16
tcp_rate_skb_delivered 171 - -171
Total: Before=22566192, After=22566514, chg +0.00%

Signed-off-by: Eric Dumazet <edumazet@google.com>
Reviewed-by: Neal Cardwell <ncardwell@google.com>
Link: https://patch.msgid.link/20260118123204.2315993-1-edumazet@google.com
Signed-off-by: Jakub Kicinski <kuba@kernel.org>

authored by

Eric Dumazet and committed by
Jakub Kicinski
670ade3b 2d265e2f

+44 -46
-2
include/net/tcp.h
··· 1356 1356 void tcp_set_ca_state(struct sock *sk, const u8 ca_state); 1357 1357 1358 1358 /* From tcp_rate.c */ 1359 - void tcp_rate_skb_delivered(struct sock *sk, struct sk_buff *skb, 1360 - struct rate_sample *rs); 1361 1359 void tcp_rate_gen(struct sock *sk, u32 delivered, u32 lost, 1362 1360 bool is_sack_reneg, struct rate_sample *rs); 1363 1361 void tcp_rate_check_app_limited(struct sock *sk);
+44
net/ipv4/tcp_input.c
··· 1637 1637 return sacked; 1638 1638 } 1639 1639 1640 + /* When an skb is sacked or acked, we fill in the rate sample with the (prior) 1641 + * delivery information when the skb was last transmitted. 1642 + * 1643 + * If an ACK (s)acks multiple skbs (e.g., stretched-acks), this function is 1644 + * called multiple times. We favor the information from the most recently 1645 + * sent skb, i.e., the skb with the most recently sent time and the highest 1646 + * sequence. 1647 + */ 1648 + static void tcp_rate_skb_delivered(struct sock *sk, struct sk_buff *skb, 1649 + struct rate_sample *rs) 1650 + { 1651 + struct tcp_skb_cb *scb = TCP_SKB_CB(skb); 1652 + struct tcp_sock *tp = tcp_sk(sk); 1653 + u64 tx_tstamp; 1654 + 1655 + if (!scb->tx.delivered_mstamp) 1656 + return; 1657 + 1658 + tx_tstamp = tcp_skb_timestamp_us(skb); 1659 + if (!rs->prior_delivered || 1660 + tcp_skb_sent_after(tx_tstamp, tp->first_tx_mstamp, 1661 + scb->end_seq, rs->last_end_seq)) { 1662 + rs->prior_delivered_ce = scb->tx.delivered_ce; 1663 + rs->prior_delivered = scb->tx.delivered; 1664 + rs->prior_mstamp = scb->tx.delivered_mstamp; 1665 + rs->is_app_limited = scb->tx.is_app_limited; 1666 + rs->is_retrans = scb->sacked & TCPCB_RETRANS; 1667 + rs->last_end_seq = scb->end_seq; 1668 + 1669 + /* Record send time of most recently ACKed packet: */ 1670 + tp->first_tx_mstamp = tx_tstamp; 1671 + /* Find the duration of the "send phase" of this window: */ 1672 + rs->interval_us = tcp_stamp_us_delta(tp->first_tx_mstamp, 1673 + scb->tx.first_tx_mstamp); 1674 + 1675 + } 1676 + /* Mark off the skb delivered once it's sacked to avoid being 1677 + * used again when it's cumulatively acked. For acked packets 1678 + * we don't need to reset since it'll be freed soon. 1679 + */ 1680 + if (scb->sacked & TCPCB_SACKED_ACKED) 1681 + scb->tx.delivered_mstamp = 0; 1682 + } 1683 + 1640 1684 /* Shift newly-SACKed bytes from this skb to the immediately previous 1641 1685 * already-SACKed sk_buff. Mark the newly-SACKed bytes as such. 1642 1686 */
-44
net/ipv4/tcp_rate.c
··· 34 34 * ready to send in the write queue. 35 35 */ 36 36 37 - /* When an skb is sacked or acked, we fill in the rate sample with the (prior) 38 - * delivery information when the skb was last transmitted. 39 - * 40 - * If an ACK (s)acks multiple skbs (e.g., stretched-acks), this function is 41 - * called multiple times. We favor the information from the most recently 42 - * sent skb, i.e., the skb with the most recently sent time and the highest 43 - * sequence. 44 - */ 45 - void tcp_rate_skb_delivered(struct sock *sk, struct sk_buff *skb, 46 - struct rate_sample *rs) 47 - { 48 - struct tcp_sock *tp = tcp_sk(sk); 49 - struct tcp_skb_cb *scb = TCP_SKB_CB(skb); 50 - u64 tx_tstamp; 51 - 52 - if (!scb->tx.delivered_mstamp) 53 - return; 54 - 55 - tx_tstamp = tcp_skb_timestamp_us(skb); 56 - if (!rs->prior_delivered || 57 - tcp_skb_sent_after(tx_tstamp, tp->first_tx_mstamp, 58 - scb->end_seq, rs->last_end_seq)) { 59 - rs->prior_delivered_ce = scb->tx.delivered_ce; 60 - rs->prior_delivered = scb->tx.delivered; 61 - rs->prior_mstamp = scb->tx.delivered_mstamp; 62 - rs->is_app_limited = scb->tx.is_app_limited; 63 - rs->is_retrans = scb->sacked & TCPCB_RETRANS; 64 - rs->last_end_seq = scb->end_seq; 65 - 66 - /* Record send time of most recently ACKed packet: */ 67 - tp->first_tx_mstamp = tx_tstamp; 68 - /* Find the duration of the "send phase" of this window: */ 69 - rs->interval_us = tcp_stamp_us_delta(tp->first_tx_mstamp, 70 - scb->tx.first_tx_mstamp); 71 - 72 - } 73 - /* Mark off the skb delivered once it's sacked to avoid being 74 - * used again when it's cumulatively acked. For acked packets 75 - * we don't need to reset since it'll be freed soon. 76 - */ 77 - if (scb->sacked & TCPCB_SACKED_ACKED) 78 - scb->tx.delivered_mstamp = 0; 79 - } 80 - 81 37 /* Update the connection delivery information and generate a rate sample. */ 82 38 void tcp_rate_gen(struct sock *sk, u32 delivered, u32 lost, 83 39 bool is_sack_reneg, struct rate_sample *rs)