Received: by 2002:ac0:98c7:0:0:0:0:0 with SMTP id g7-v6csp1087340imd; Sat, 3 Nov 2018 17:43:19 -0700 (PDT) X-Google-Smtp-Source: AJdET5f+U2n5OcxOfiZsMnhI0xtU2cttph2sLBZmETzjbPh9YC6fZ1jPNukInACJ2f7VTdCfGp/l X-Received: by 2002:a17:902:bb07:: with SMTP id l7-v6mr17220834pls.230.1541292199472; Sat, 03 Nov 2018 17:43:19 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1541292199; cv=none; d=google.com; s=arc-20160816; b=bZTOh02aozydyEh/4urjeui7R/NAr4d1tKOtasVTWJdr2IPVFnrbIY9yjnGZa4hVKg FWZRwiT+uLqlZytJR5ZqGYR0VKj2ZkZgX6SC7s/YvIsZqt3QK0/26HR5KWJsYr7FWHLP lCVymkEl6b330DO2JDx2LLSJrJhCCkJj5ZPuNmbYQ5EYwyTFNe/TEIFU3lh1s4/cIl64 JH31OUoBskPUGiXyof+if7AAR6lAOkv4s0G/c6LQjndoW2yUlBrmu7ztwFai/i6Qqbxx 9cXZe91oqcCBrwv0RlipeNk9Ssu9QJpei+zti5wH2ugPGKkNW9duoDVV4/xOTMu5AF/b en1Q== 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:from:references:cc:to:subject:dkim-signature; bh=5wzR6fJgE1m2Lw4LkHFP27xBQ7EYJ6Vj89edQ5HTBs4=; b=ujZjah3joT7d7cLKWXZG8Qd9bg4yETSiFGqX7a9jQCT2zhgRmlm1ltUjp45BsHkm7N Yttp58TnD+wp7q8YTpB0Fh5sXhe0CC1r+2Ds7GWFIpgiFRn6Me3Mcs/loRMO23pdS7Lq 7iEygYcGYSpn3f3Odm8Ted8/Ii1J9tLeXsw/YteQMWongDNn/y/tB603J25s6zztteKT lhmpl7n4P9SDOsvtfaVdL1mbQf/qePM74yLyoJ7vBh5ta0dqHGRIl+MxU8UILu7N0P8Z pvPQq/GPTNSx09lQ5Xo9nztwETd6sInV+0UDRLpsr5IYpY3nEJpM0YM87Ypmrgy+SV1u WxFg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=fROur40x; 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 r25-v6si41032768pfk.83.2018.11.03.17.43.04; Sat, 03 Nov 2018 17:43:19 -0700 (PDT) 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=fROur40x; 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 S1728858AbeKDJxj (ORCPT + 99 others); Sun, 4 Nov 2018 04:53:39 -0500 Received: from mail-pf1-f194.google.com ([209.85.210.194]:45140 "EHLO mail-pf1-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727157AbeKDJxj (ORCPT ); Sun, 4 Nov 2018 04:53:39 -0500 Received: by mail-pf1-f194.google.com with SMTP id p17-v6so2322862pfj.12; Sat, 03 Nov 2018 17:40:41 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=subject:to:cc:references:from:message-id:date:user-agent :mime-version:in-reply-to:content-language:content-transfer-encoding; bh=5wzR6fJgE1m2Lw4LkHFP27xBQ7EYJ6Vj89edQ5HTBs4=; b=fROur40xL9WcHj7Vf0fjQeGSbXSmkvNamwCqGea8NDm3QoZ9FMwO0az1Wp1rACqJC0 zNKAW1GQQuYQgTJu2xGNoqhNivbNDW42hZKxUV7MaNcTKfk6lHBYYOkhcfC+pi6JSpik WNe1ZinkNjFNJcct3fBuoZaTlzlI02oba0A5il1kHOtPFZ+nho0oF2dNF+2E3Y20WvrZ +ZUUUyiItbhVlWa775/TgV48E7ZYAGA+x7Iwi5SAdsfDL1UmK86Sx6vYhxfc+2jxNvXF FNhzF5P0mBHnNVk1LvT3kxnAtqw3bdFcTZ07KQa0mIr8NlEvLhiq2bt2c8d9I8FRGZkM ttCA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:to:cc:references:from:message-id:date :user-agent:mime-version:in-reply-to:content-language :content-transfer-encoding; bh=5wzR6fJgE1m2Lw4LkHFP27xBQ7EYJ6Vj89edQ5HTBs4=; b=jl2lCQplnrzDkpf5jE+GR0UBrWb5fra4QSWmswPkRKVrEj/ezli7Ujf44ZInZAZUJS wow+cd4Dyz3IELQVzb+XKXCwmvFgTElvj3uFVNDHHDgt4CguUNp5NvmrewEntgQIKjwa V14q0HZ+hX1HOnHrjYRLk9ZcwwrLV8aWqciuMYV05UDNHsbhXtbiHW3fJcrNsc2F2O+y L/Oy7AfcY4GsqxOR1xeKPmfs/LLQXb/faEia4Q8TZnXYkf4XI24ncikhVLbi8iIXu3mW 6CGmFKaDcfHR2Xpeiis4ahMM0GJVvwcU+7+T/B66hhi2S20Ic81ly8MIaUNC8R6ApJqh pnHw== X-Gm-Message-State: AGRZ1gLsmLq5YGBcKDeGZwQcmKC9UAwcLJ2nOWBH0XywVhsop7HuZGfV 0NKGTdC0mbiOz1o/JHmOaX4M9wVV X-Received: by 2002:a62:6981:: with SMTP id e123-v6mr1881546pfc.104.1541292041226; Sat, 03 Nov 2018 17:40:41 -0700 (PDT) Received: from [192.168.86.235] (c-67-180-167-114.hsd1.ca.comcast.net. [67.180.167.114]) by smtp.gmail.com with ESMTPSA id q11-v6sm15809789pgp.62.2018.11.03.17.40.39 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sat, 03 Nov 2018 17:40:40 -0700 (PDT) Subject: Re: [PATCH] tcp: do not update snd_una if it is same with ack_seq To: Yafang Shao , davem@davemloft.net, edumazet@google.com Cc: netdev@vger.kernel.org, linux-kernel@vger.kernel.org References: <1541264071-9905-1-git-send-email-laoar.shao@gmail.com> From: Eric Dumazet Message-ID: <5f585304-b6f5-5f49-adcf-eaed471c0d76@gmail.com> Date: Sat, 3 Nov 2018 17:40:39 -0700 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: <1541264071-9905-1-git-send-email-laoar.shao@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/03/2018 09:54 AM, Yafang Shao wrote: > In the slow path, TCP_SKB_SB(skb)->ack_seq may be same with tp->snd_una, > and under this condition we don't need to update the snd_una. > > Furthermore, tcp_ack_update_window() is only called in slow path, > so introducing this check won't affect the fast path processing. > > By the way, '&' is a little faster than '-', so I replaced after() with > "flag & FLAG_SND_UNA_ADVANCED". > > Signed-off-by: Yafang Shao > --- > net/ipv4/tcp_input.c | 5 +++-- > 1 file changed, 3 insertions(+), 2 deletions(-) > > diff --git a/net/ipv4/tcp_input.c b/net/ipv4/tcp_input.c > index 2868ef2..db5a6b7 100644 > --- a/net/ipv4/tcp_input.c > +++ b/net/ipv4/tcp_input.c > @@ -3376,7 +3376,8 @@ static int tcp_ack_update_window(struct sock *sk, const struct sk_buff *skb, u32 > } > } > > - tcp_snd_una_update(tp, ack); > + if (after(ack, tp->snd_una)) > + tcp_snd_una_update(tp, ack); > Adding this after() here is confusing, how ack could be before snd_una ? That would be a serious bug. I do not see why another conditional has any gain here. You are trying to avoid very cheap operations : u32 delta = ack - tp->snd_una; tp->bytes_acked += delta; tp->snd_una = ack; Maybe the real reason for this patch is not explained in the changelog ?