Skip to content

Commit

Permalink
net-tcp_bbr: v2: snapshot packets in flight at transmit time and pass…
Browse files Browse the repository at this point in the history
… in rate_sample

For understanding the relationship between inflight and losses or ECN
signals, to try to find the highest inflight value that has acceptable
levels of loss/ECN marking.

Effort: net-tcp_bbr
Origin-9xx-SHA1: b3eb4f2d20efab4ca001f32c9294739036c493ea
Change-Id: I7314047d0ff14dd261a04b1969a46dc658c8836a
  • Loading branch information
nealcardwell authored and xanmod committed Apr 27, 2021
1 parent ef335de commit 71527a4
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 0 deletions.
5 changes: 5 additions & 0 deletions include/net/tcp.h
Expand Up @@ -882,6 +882,10 @@ struct tcp_skb_cb {
u32 first_tx_mstamp;
/* when we reached the "delivered" count */
u32 delivered_mstamp;
#define TCPCB_IN_FLIGHT_BITS 20
#define TCPCB_IN_FLIGHT_MAX ((1U << TCPCB_IN_FLIGHT_BITS) - 1)
u32 in_flight:20, /* packets in flight at transmit */
unused2:12;
} tx; /* only used for outgoing skbs */
union {
struct inet_skb_parm h4;
Expand Down Expand Up @@ -1053,6 +1057,7 @@ struct rate_sample {
u64 prior_mstamp; /* starting timestamp for interval */
u32 prior_delivered; /* tp->delivered at "prior_mstamp" */
u32 prior_delivered_ce;/* tp->delivered_ce at "prior_mstamp" */
u32 tx_in_flight; /* packets in flight at starting timestamp */
s32 delivered; /* number of packets delivered over interval */
s32 delivered_ce; /* number of packets delivered w/ CE marks*/
long interval_us; /* time for tp->delivered to incr "delivered" */
Expand Down
14 changes: 14 additions & 0 deletions net/ipv4/tcp_rate.c
Expand Up @@ -40,6 +40,7 @@
void tcp_rate_skb_sent(struct sock *sk, struct sk_buff *skb)
{
struct tcp_sock *tp = tcp_sk(sk);
u32 in_flight;

/* In general we need to start delivery rate samples from the
* time we received the most recent ACK, to ensure we include
Expand Down Expand Up @@ -67,6 +68,18 @@ void tcp_rate_skb_sent(struct sock *sk, struct sk_buff *skb)
TCP_SKB_CB(skb)->tx.delivered = tp->delivered;
TCP_SKB_CB(skb)->tx.delivered_ce = tp->delivered_ce;
TCP_SKB_CB(skb)->tx.is_app_limited = tp->app_limited ? 1 : 0;

/* Check, sanitize, and record packets in flight after skb was sent. */
in_flight = tcp_packets_in_flight(tp) + tcp_skb_pcount(skb);
WARN_ONCE(in_flight > TCPCB_IN_FLIGHT_MAX,
"insane in_flight %u cc %s mss %u "
"cwnd %u pif %u %u %u %u\n",
in_flight, inet_csk(sk)->icsk_ca_ops->name,
tp->mss_cache, tp->snd_cwnd,
tp->packets_out, tp->retrans_out,
tp->sacked_out, tp->lost_out);
in_flight = min(in_flight, TCPCB_IN_FLIGHT_MAX);
TCP_SKB_CB(skb)->tx.in_flight = in_flight;
}

/* When an skb is sacked or acked, we fill in the rate sample with the (prior)
Expand All @@ -92,6 +105,7 @@ void tcp_rate_skb_delivered(struct sock *sk, struct sk_buff *skb,
rs->prior_mstamp = scb->tx.delivered_mstamp;
rs->is_app_limited = scb->tx.is_app_limited;
rs->is_retrans = scb->sacked & TCPCB_RETRANS;
rs->tx_in_flight = scb->tx.in_flight;

/* Record send time of most recently ACKed packet: */
tp->first_tx_mstamp = tcp_skb_timestamp_us(skb);
Expand Down

0 comments on commit 71527a4

Please sign in to comment.