From mboxrd@z Thu Jan 1 00:00:00 1970 From: Eric Dumazet Subject: Re: [PATCH net-next] tcp: introduce skb_rbtree_walk_safe() and use it in tcp_clean_rtx_queue() Date: Wed, 28 Nov 2018 09:26:27 -0800 Message-ID: References: <1543407379-3144-1-git-send-email-laoar.shao@gmail.com> <60467855-ea5f-3351-8b88-ffdfa60501e0@gmail.com> <408125e7-bbb0-dcfb-ee19-58089802cac7@gmail.com> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit Cc: netdev@vger.kernel.org, linux-kernel@vger.kernel.org To: Yafang Shao , davem@davemloft.net, edumazet@google.com Return-path: In-Reply-To: <408125e7-bbb0-dcfb-ee19-58089802cac7@gmail.com> Content-Language: en-US Sender: linux-kernel-owner@vger.kernel.org List-Id: netdev.vger.kernel.org On 11/28/2018 08:53 AM, Eric Dumazet wrote: > > > On 11/28/2018 06:44 AM, Eric Dumazet wrote: >> > >> Because we can break of the loop if the current skb is not fully acked. >> >> So your patch would add unnecessary overhead, since the extra sk_rb_next() >> could add more extra cache line misses. > > I am testing the following optimization, since we can avoid the rb_next() call > when we reached snd_una > > diff --git a/net/ipv4/tcp_input.c b/net/ipv4/tcp_input.c > index f32397890b6dcbc34976954c4be142108efa04d8..6829e470f0c186a73c34dca414cd4a2b379baded 100644 > --- a/net/ipv4/tcp_input.c > +++ b/net/ipv4/tcp_input.c > @@ -3126,7 +3126,8 @@ static int tcp_clean_rtx_queue(struct sock *sk, u32 prior_fack, > if (!fully_acked) > break; > > - next = skb_rb_next(skb); > + next = (scb->end_seq == tp->snd_una) ? NULL : skb_rb_next(skb); > + > if (unlikely(skb == tp->retransmit_skb_hint)) > tp->retransmit_skb_hint = NULL; > if (unlikely(skb == tp->lost_skb_hint)) > This does not work since we use next skb after the loop : 1) if (!skb) tcp_chrono_stop(sk, TCP_CHRONO_BUSY); This test could use tcp_rtx_queue_empty() 2) SACK reneging if (skb && (TCP_SKB_CB(skb)->sacked & TCPCB_SACKED_ACKED)) flag |= FLAG_SACK_RENEGING; 3) FLAG_SET_XMIT_TIMER } else if (skb && rtt_update && sack_rtt_us >= 0 && sack_rtt_us > tcp_stamp_us_delta(tp->tcp_mstamp, tcp_skb_timestamp_us(skb))) { flag |= FLAG_SET_XMIT_TIMER; /* set TLP or RTO timer */ So this idea is not feasible.