Skip to content

Commit 5e13a0d

Browse files
laoardavem330
authored andcommitted
tcp: minor optimization in tcp ack fast path processing
Bitwise operation is a little faster. So I replace after() with using the flag FLAG_SND_UNA_ADVANCED as it is already set before. In addtion, there's another similar improvement in tcp_cwnd_reduction(). Cc: Joe Perches <[email protected]> Suggested-by: Eric Dumazet <[email protected]> Signed-off-by: Yafang Shao <[email protected]> Signed-off-by: Eric Dumazet <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent 0cf3a68 commit 5e13a0d

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

net/ipv4/tcp_input.c

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2457,8 +2457,8 @@ void tcp_cwnd_reduction(struct sock *sk, int newly_acked_sacked, int flag)
24572457
u64 dividend = (u64)tp->snd_ssthresh * tp->prr_delivered +
24582458
tp->prior_cwnd - 1;
24592459
sndcnt = div_u64(dividend, tp->prior_cwnd) - tp->prr_out;
2460-
} else if ((flag & FLAG_RETRANS_DATA_ACKED) &&
2461-
!(flag & FLAG_LOST_RETRANS)) {
2460+
} else if ((flag & (FLAG_RETRANS_DATA_ACKED | FLAG_LOST_RETRANS)) ==
2461+
FLAG_RETRANS_DATA_ACKED) {
24622462
sndcnt = min_t(int, delta,
24632463
max_t(int, tp->prr_delivered - tp->prr_out,
24642464
newly_acked_sacked) + 1);
@@ -3610,7 +3610,8 @@ static int tcp_ack(struct sock *sk, const struct sk_buff *skb, int flag)
36103610
if (flag & FLAG_UPDATE_TS_RECENT)
36113611
tcp_replace_ts_recent(tp, TCP_SKB_CB(skb)->seq);
36123612

3613-
if (!(flag & FLAG_SLOWPATH) && after(ack, prior_snd_una)) {
3613+
if ((flag & (FLAG_SLOWPATH | FLAG_SND_UNA_ADVANCED)) ==
3614+
FLAG_SND_UNA_ADVANCED) {
36143615
/* Window is constant, pure forward advance.
36153616
* No more checks are required.
36163617
* Note, we use the fact that SND.UNA>=SND.WL2.

0 commit comments

Comments
 (0)