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_sent() to tcp_output.c

It is only called from __tcp_transmit_skb() and __tcp_retransmit_skb().

Move it in tcp_output.c and make it static.

clang compiler is now able to inline it from __tcp_transmit_skb().

gcc compiler inlines it in the two callers, which is also fine.

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

authored by

Eric Dumazet and committed by
Jakub Kicinski
f10ab9d3 799759e6

+35 -36
-1
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_sent(struct sock *sk, struct sk_buff *skb); 1360 1359 void tcp_rate_skb_delivered(struct sock *sk, struct sk_buff *skb, 1361 1360 struct rate_sample *rs); 1362 1361 void tcp_rate_gen(struct sock *sk, u32 delivered, u32 lost,
+35
net/ipv4/tcp_output.c
··· 1432 1432 list_move_tail(&skb->tcp_tsorted_anchor, &tp->tsorted_sent_queue); 1433 1433 } 1434 1434 1435 + /* Snapshot the current delivery information in the skb, to generate 1436 + * a rate sample later when the skb is (s)acked in tcp_rate_skb_delivered(). 1437 + */ 1438 + static void tcp_rate_skb_sent(struct sock *sk, struct sk_buff *skb) 1439 + { 1440 + struct tcp_sock *tp = tcp_sk(sk); 1441 + 1442 + /* In general we need to start delivery rate samples from the 1443 + * time we received the most recent ACK, to ensure we include 1444 + * the full time the network needs to deliver all in-flight 1445 + * packets. If there are no packets in flight yet, then we 1446 + * know that any ACKs after now indicate that the network was 1447 + * able to deliver those packets completely in the sampling 1448 + * interval between now and the next ACK. 1449 + * 1450 + * Note that we use packets_out instead of tcp_packets_in_flight(tp) 1451 + * because the latter is a guess based on RTO and loss-marking 1452 + * heuristics. We don't want spurious RTOs or loss markings to cause 1453 + * a spuriously small time interval, causing a spuriously high 1454 + * bandwidth estimate. 1455 + */ 1456 + if (!tp->packets_out) { 1457 + u64 tstamp_us = tcp_skb_timestamp_us(skb); 1458 + 1459 + tp->first_tx_mstamp = tstamp_us; 1460 + tp->delivered_mstamp = tstamp_us; 1461 + } 1462 + 1463 + TCP_SKB_CB(skb)->tx.first_tx_mstamp = tp->first_tx_mstamp; 1464 + TCP_SKB_CB(skb)->tx.delivered_mstamp = tp->delivered_mstamp; 1465 + TCP_SKB_CB(skb)->tx.delivered = tp->delivered; 1466 + TCP_SKB_CB(skb)->tx.delivered_ce = tp->delivered_ce; 1467 + TCP_SKB_CB(skb)->tx.is_app_limited = tp->app_limited ? 1 : 0; 1468 + } 1469 + 1435 1470 INDIRECT_CALLABLE_DECLARE(int ip_queue_xmit(struct sock *sk, struct sk_buff *skb, struct flowi *fl)); 1436 1471 INDIRECT_CALLABLE_DECLARE(int inet6_csk_xmit(struct sock *sk, struct sk_buff *skb, struct flowi *fl)); 1437 1472 INDIRECT_CALLABLE_DECLARE(void tcp_v4_send_check(struct sock *sk, struct sk_buff *skb));
-35
net/ipv4/tcp_rate.c
··· 34 34 * ready to send in the write queue. 35 35 */ 36 36 37 - /* Snapshot the current delivery information in the skb, to generate 38 - * a rate sample later when the skb is (s)acked in tcp_rate_skb_delivered(). 39 - */ 40 - void tcp_rate_skb_sent(struct sock *sk, struct sk_buff *skb) 41 - { 42 - struct tcp_sock *tp = tcp_sk(sk); 43 - 44 - /* In general we need to start delivery rate samples from the 45 - * time we received the most recent ACK, to ensure we include 46 - * the full time the network needs to deliver all in-flight 47 - * packets. If there are no packets in flight yet, then we 48 - * know that any ACKs after now indicate that the network was 49 - * able to deliver those packets completely in the sampling 50 - * interval between now and the next ACK. 51 - * 52 - * Note that we use packets_out instead of tcp_packets_in_flight(tp) 53 - * because the latter is a guess based on RTO and loss-marking 54 - * heuristics. We don't want spurious RTOs or loss markings to cause 55 - * a spuriously small time interval, causing a spuriously high 56 - * bandwidth estimate. 57 - */ 58 - if (!tp->packets_out) { 59 - u64 tstamp_us = tcp_skb_timestamp_us(skb); 60 - 61 - tp->first_tx_mstamp = tstamp_us; 62 - tp->delivered_mstamp = tstamp_us; 63 - } 64 - 65 - TCP_SKB_CB(skb)->tx.first_tx_mstamp = tp->first_tx_mstamp; 66 - TCP_SKB_CB(skb)->tx.delivered_mstamp = tp->delivered_mstamp; 67 - TCP_SKB_CB(skb)->tx.delivered = tp->delivered; 68 - TCP_SKB_CB(skb)->tx.delivered_ce = tp->delivered_ce; 69 - TCP_SKB_CB(skb)->tx.is_app_limited = tp->app_limited ? 1 : 0; 70 - } 71 - 72 37 /* When an skb is sacked or acked, we fill in the rate sample with the (prior) 73 38 * delivery information when the skb was last transmitted. 74 39 *