Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp1392904imu; Wed, 28 Nov 2018 08:55:14 -0800 (PST) X-Google-Smtp-Source: AFSGD/XBjeav9K8u6TCddJyhkKpD0Gh3rdmPkVIIhKmrwTfvoZia0uyyqqImwWj3vTVhfBsKRDQ0 X-Received: by 2002:a62:6b85:: with SMTP id g127mr11100869pfc.42.1543424114021; Wed, 28 Nov 2018 08:55:14 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1543424113; cv=none; d=google.com; s=arc-20160816; b=tDZ3dmd6iM6hNVlWdnOxRG+f5kS2FprRLL7/lPR2RJRi80XokrYOilp4hgwl02a0gY pJdJpOXmSRc592i5bsI32vwuS/w+SvMtWC1jLWZDY3R4kbcZmRNuh/4HEz4+7c/vZo8G /Xe4c9fUOGjGBT4PJWU9m/ihSBdMv7Pp+mcH9qlNeX7TtRZrNsegp2fnlJamFiUCE3ST i6+xyUX1ixs6oZC3UqU/KHeTh2trzjxd3WtYfsGPvKPRu/MHF6nh8QwEujRdDmDJQUf1 ePo4Mlyv6jf9MHWDdoGyw+TqvCclfsq9Q5S2f1CXfMqDL+U2ItmIOVjBNqSgMtRzFkdt Z5UQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding :content-language:in-reply-to:mime-version:user-agent:date :message-id:references:cc:to:from:subject:dkim-signature; bh=nO0+4N14JYBT16pbRqFYBHIRL83n5NnZd2VqEG31nRE=; b=R6v3/ugPcwOae0IERrP1iJstTQLpkWLOTY480VZ4d5DztMBA9rwELIIw4oignlZwOh xyI9hI4m37mkj5F1YQLwDXq7It8TzOgu0VbZ0egOPIEgCi5vZnZ5tJRrJ/UiK9zZ21w0 r4RJsCb+yAPLwejMSqDZLwDReKpyXG451USHzLUMXJjDESSvPXuLeD6ftpGwY1m8A08X p+ozs/CW7/UmYfRfVjk7b+Yjs4LeP+CWPAEQeNOlvUOqw79NK3l/W0exnEg4bn438C2/ pRlpA2Z3+mknEZvo5ctxn7Ez9Jy/eK/D88sqGHGvRo8e4vC+yf/S//p+Sb2UVbOiTasc axpg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=E21Dcl8p; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id f186si8590174pfb.67.2018.11.28.08.54.57; Wed, 28 Nov 2018 08:55:13 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=E21Dcl8p; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729150AbeK2D4R (ORCPT + 99 others); Wed, 28 Nov 2018 22:56:17 -0500 Received: from mail-pl1-f196.google.com ([209.85.214.196]:40756 "EHLO mail-pl1-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728928AbeK2D4R (ORCPT ); Wed, 28 Nov 2018 22:56:17 -0500 Received: by mail-pl1-f196.google.com with SMTP id u18so5092339plq.7; Wed, 28 Nov 2018 08:54:00 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=subject:from:to:cc:references:message-id:date:user-agent :mime-version:in-reply-to:content-language:content-transfer-encoding; bh=nO0+4N14JYBT16pbRqFYBHIRL83n5NnZd2VqEG31nRE=; b=E21Dcl8pff2dDH/2JROGXeyJjw8ajlxM5Tox+qtshwh3pnSig/X/0/IYfnTlDY7ar2 qHx7dwu21149cDayOkg02SNerKNjU+aX4BXGyRe5unaJy9nX5TZRcyAtUjmG5SUod3yG hQQ3tcT63/f/Fi0jYFm6CTqzKMfax/Dey8/8lnwTGQf3/AdK0VkwQjWCREOyFz1vxPfZ NSrvVd17sY067wII9RwnaWXSQOgO82ba7uoVF645gCV5tl/4HpEZCVE3wm1N4s3XlbWd imedV05oBqSw3sMx6SF9bveBhZ9xfXN4LrKiCEB8BLAD0xthFg8XTKa4qvag5SJ8vnZJ Z7Ng== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:from:to:cc:references:message-id:date :user-agent:mime-version:in-reply-to:content-language :content-transfer-encoding; bh=nO0+4N14JYBT16pbRqFYBHIRL83n5NnZd2VqEG31nRE=; b=lHT3cJl/zeNYn/DzMnganpy8IKnTdzI6VwQDHlQG41XK8N4oeAugdqbauuCgUo5pm5 KrhPPm7H/Bw4F2Sxpj7IrulEGxLi8XkOOsm6pSooIT8QZz5B/MYCrXushG79O2iZ5J/r bGYPNJnyXXHy0yXXWADwGVnqJF7nu3y+/h+mNRkmCfaaQozJu/BlGjckBlWGpo4uVj7P EcrbVjBVxcQ1a9sSBbOVe15ekmH6dnyxuUb16Nusm4G6SjuWmkssARpgrtOZ8hkl2RGp +mDn2NJS3y+qrv6wnID44KLUKvkgpcxa87UJDzwTIxFXId1W2R++sByg2B2feonTkLuc TNEg== X-Gm-Message-State: AA+aEWapB8YnsrJgw5dOHhW3/btmvmvfLqpDRf9k/mGNrs98vNlD7A/+ sNb+y7CI2PkoYaJIj67xaSse9s1I X-Received: by 2002:a17:902:14b:: with SMTP id 69mr38178938plb.52.1543424039561; Wed, 28 Nov 2018 08:53:59 -0800 (PST) Received: from ?IPv6:2620:15c:2c1:200:55c7:81e6:c7d8:94b? ([2620:15c:2c1:200:55c7:81e6:c7d8:94b]) by smtp.gmail.com with ESMTPSA id z186sm10201042pfz.119.2018.11.28.08.53.58 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 28 Nov 2018 08:53:58 -0800 (PST) Subject: Re: [PATCH net-next] tcp: introduce skb_rbtree_walk_safe() and use it in tcp_clean_rtx_queue() From: Eric Dumazet To: Yafang Shao , davem@davemloft.net, edumazet@google.com Cc: netdev@vger.kernel.org, linux-kernel@vger.kernel.org References: <1543407379-3144-1-git-send-email-laoar.shao@gmail.com> <60467855-ea5f-3351-8b88-ffdfa60501e0@gmail.com> Message-ID: <408125e7-bbb0-dcfb-ee19-58089802cac7@gmail.com> Date: Wed, 28 Nov 2018 08:53:58 -0800 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.9.1 MIME-Version: 1.0 In-Reply-To: <60467855-ea5f-3351-8b88-ffdfa60501e0@gmail.com> Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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))