Skip to content

Commit

Permalink
net-tcp_rate: consolidate inflight tracking approaches in TCP
Browse files Browse the repository at this point in the history
In order to track CE marks per rate sample (one round trip), we'll
need to snap the starting tcp delivered_ce acount in the packet
meta header (tcp_skb_cb). But there's not enough space.

Good news is that the "last_in_flight" in the header, used by
NV congestion control, is almost equivalent as "delivered". In
fact "delivered" is better by accounting out-of-order packets
additionally.  Therefore we can remove it to make room for the
CE tracking.

This would make delayed ACK detection slightly less accurate but the
impact is negligible since it's not used for any critical control.

Effort: net-tcp_rate
Origin-9xx-SHA1: ddcd46ec85d5f1c4454258af0c54b3254c0d64a7
Change-Id: I1a184aad6d101c981ac7f2f275aa9417ff856910
  • Loading branch information
yuchungcheng authored and xanmod committed Jan 17, 2021
1 parent a4a523d commit 48dab57
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 11 deletions.
5 changes: 2 additions & 3 deletions include/net/tcp.h
Expand Up @@ -860,9 +860,8 @@ struct tcp_skb_cb {
union {
struct {
/* There is space for up to 24 bytes */
__u32 in_flight:30,/* Bytes in flight at transmit */
is_app_limited:1, /* cwnd not fully used? */
unused:1;
__u32 is_app_limited:1, /* cwnd not fully used? */
unused:31;
/* pkts S/ACKed so far upon tx of skb, incl retrans: */
__u32 delivered;
/* start of send pipeline phase */
Expand Down
11 changes: 5 additions & 6 deletions net/ipv4/tcp_input.c
Expand Up @@ -3167,7 +3167,6 @@ static int tcp_clean_rtx_queue(struct sock *sk, u32 prior_fack,
long seq_rtt_us = -1L;
long ca_rtt_us = -1L;
u32 pkts_acked = 0;
u32 last_in_flight = 0;
bool rtt_update;
int flag = 0;

Expand Down Expand Up @@ -3203,7 +3202,6 @@ static int tcp_clean_rtx_queue(struct sock *sk, u32 prior_fack,
if (!first_ackt)
first_ackt = last_ackt;

last_in_flight = TCP_SKB_CB(skb)->tx.in_flight;
if (before(start_seq, reord))
reord = start_seq;
if (!after(scb->end_seq, tp->high_seq))
Expand Down Expand Up @@ -3269,8 +3267,8 @@ static int tcp_clean_rtx_queue(struct sock *sk, u32 prior_fack,
seq_rtt_us = tcp_stamp_us_delta(tp->tcp_mstamp, first_ackt);
ca_rtt_us = tcp_stamp_us_delta(tp->tcp_mstamp, last_ackt);

if (pkts_acked == 1 && last_in_flight < tp->mss_cache &&
last_in_flight && !prior_sacked && fully_acked &&
if (pkts_acked == 1 && fully_acked && !prior_sacked &&
(tp->snd_una - prior_snd_una) < tp->mss_cache &&
sack->rate->prior_delivered + 1 == tp->delivered &&
!(flag & (FLAG_CA_ALERT | FLAG_SYN_ACKED))) {
/* Conservatively mark a delayed ACK. It's typically
Expand Down Expand Up @@ -3327,9 +3325,10 @@ static int tcp_clean_rtx_queue(struct sock *sk, u32 prior_fack,

if (icsk->icsk_ca_ops->pkts_acked) {
struct ack_sample sample = { .pkts_acked = pkts_acked,
.rtt_us = sack->rate->rtt_us,
.in_flight = last_in_flight };
.rtt_us = sack->rate->rtt_us };

sample.in_flight = tp->mss_cache *
(tp->delivered - sack->rate->prior_delivered);
icsk->icsk_ca_ops->pkts_acked(sk, &sample);
}

Expand Down
2 changes: 0 additions & 2 deletions net/ipv4/tcp_output.c
Expand Up @@ -1257,8 +1257,6 @@ static int __tcp_transmit_skb(struct sock *sk, struct sk_buff *skb,
tp->tcp_wstamp_ns = max(tp->tcp_wstamp_ns, tp->tcp_clock_cache);
skb->skb_mstamp_ns = tp->tcp_wstamp_ns;
if (clone_it) {
TCP_SKB_CB(skb)->tx.in_flight = TCP_SKB_CB(skb)->end_seq
- tp->snd_una;
oskb = skb;

tcp_skb_tsorted_save(oskb) {
Expand Down

0 comments on commit 48dab57

Please sign in to comment.