Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp2929495imu; Sun, 11 Nov 2018 04:12:27 -0800 (PST) X-Google-Smtp-Source: AJdET5foUGLr7to6GQaWmm0CYD/x+Rfnxmpw6ykDY1LSIXhXR3agIU1A2vwo8AOz2KES9iYc3b+S X-Received: by 2002:a63:4706:: with SMTP id u6mr13187098pga.95.1541938347190; Sun, 11 Nov 2018 04:12:27 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1541938347; cv=none; d=google.com; s=arc-20160816; b=N3DD8NxKmLmQnUrXI96nP45D/U+UqkiChJUeRSmE5kzy3RwpbmHb1cz6VadSkV8vdY RRAWFxh8VWjKtyaE2qaMSujn2UrssKpU6pMDstGRMjGGAxmCwAywW7ysOc68kQtyXmeY uj7hN6MBMv18mqAtsvQZF9MvrDf5TVuHX7I2TaBzoJ+f2RiQMX/HAqTXyPizU1cjd5OS MYbp+VVrBdwSEXvsi2PxqNlB7Y1WLMeXZI3CqkdK1AKcmHMaEDlhTB2HDflR0Rl4NASs LiTudLb+gV5jovCkM+lEJDSQZrA+a9yo+GQC5agiFqIEjtUsdkdnb5PGiEIwBEczhqoa 94ig== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:message-id:date:subject:cc:to:from :dkim-signature; bh=BFlr4fzbZ2bFRUAgs1AQuqy3va5cbhhQY2IvnpeiMT8=; b=CPsGrb6LrgRd2s5drnA3lragIHpSP6bBfQE1m+uGntn/72xNJOfKmj0os1GLcRiuz+ YxP7RbPo+fTxY+2nADA9Ajqt0zkrIU0UZffM+K6q92gXeQ+bc7A09yL/biy9oCdq2Tt2 ZQ2NahCujYPbGD5vDhUA7uq42PdIULgw3R5+0SeyYBwody92M3zmBX/QEuzxk1fJKdjm uux1s8I3D50ncpXkb91jQ8XNjSxHHXbgJip/L3xREKXN+DutddjEduZ0VmVPddwMuTOI LUnQC1vnvapTs6yAvJ/HAE+k6c2Vn1fXi9InUeYMD9tCCiZPp7wgTKyJrP9Wcc4tbAHa 5JuA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=OdOvsV5A; 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 l123-v6si14963552pfl.200.2018.11.11.04.12.11; Sun, 11 Nov 2018 04:12:27 -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=OdOvsV5A; 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 S1728008AbeKKV65 (ORCPT + 99 others); Sun, 11 Nov 2018 16:58:57 -0500 Received: from mail-pf1-f196.google.com ([209.85.210.196]:40164 "EHLO mail-pf1-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727467AbeKKV65 (ORCPT ); Sun, 11 Nov 2018 16:58:57 -0500 Received: by mail-pf1-f196.google.com with SMTP id x2-v6so2958367pfm.7; Sun, 11 Nov 2018 04:10:33 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id; bh=BFlr4fzbZ2bFRUAgs1AQuqy3va5cbhhQY2IvnpeiMT8=; b=OdOvsV5ABnzL8tK3d3OhR0RFmvgrHm4ZRYS2s/W3eu0slCH+Nmhl5H24Hf1qiHiLZA R+R9sVGLmZ0bIz9O3swSLzyhYlWtmVT6uy18kJSe8d1swLXmFqELDpfsEwF14coOtR5l 7cWaJhYICk+OE1lD/CTw7m+MW9bp9YeRPdqEc3SiztNWiq+/Mi8W8b7AmvhLTzdx6QrV zcWiyypf0DJ6pNLdWsRMvxzDwaE3zdKfYfEnYu5M8fEnB3PqZcIjdPp8D6X3KTll0ZF9 gDwKNHZ8liq/FaB/nZ4FenzthipMZMYlvQmBNenoOcZscY1BSDeNZUVSIK3uaIxrqUwg S8jw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=BFlr4fzbZ2bFRUAgs1AQuqy3va5cbhhQY2IvnpeiMT8=; b=HNvvxf58PElcWZMCO7WT3owfdzR5zjJSirkMV7nV7haJkny7AbYWX/k5WQP0GYFrul YpUOb/6zE+n61kaHTLjc2DLF3DrBbeBChxMxYnFwOQy/m4NNJSlQMlWvTqH68HXGvsHb s82rtSFXY+W8Onc9fcqOy6AQRiHdDZHbOmeZwjzb9WQFlxeBE0GbBgGx85hIoCFb6/iA TkHcOqZhfg26heuEYlwGXGHxKFpnbOYSbERHKd/zokCiUDBy5wR8iuTe/ghSm5VsK+dy Mm+0vFlpXVVGLMCQaFEkaLIDwCvO1ACH9WKVpxm+6TH5+S1rZSu71+wmdJh4iaFVPJez ycIw== X-Gm-Message-State: AGRZ1gKK7a6r3mnEt8dLFZV9Wac7VAG3MKqT8JHo/RUZ++RlBGwCRuRf VsZa2kDWnIY/yRM/aDQOyr0= X-Received: by 2002:a62:3406:: with SMTP id b6-v6mr16248036pfa.50.1541938232672; Sun, 11 Nov 2018 04:10:32 -0800 (PST) Received: from localhost.localdomain ([203.100.54.194]) by smtp.gmail.com with ESMTPSA id i2-v6sm11530897pgq.35.2018.11.11.04.10.29 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 11 Nov 2018 04:10:31 -0800 (PST) From: Yafang Shao To: davem@davemloft.net, edumazet@google.com Cc: netdev@vger.kernel.org, linux-kernel@vger.kernel.org, Yafang Shao , Joe Perches Subject: [PATCH net-next v2] tcp: minor optimization in tcp ack fast path processing Date: Sun, 11 Nov 2018 20:10:10 +0800 Message-Id: <1541938210-11797-1-git-send-email-laoar.shao@gmail.com> X-Mailer: git-send-email 1.8.3.1 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 Suggested-by: Eric Dumazet Signed-off-by: Yafang Shao --- net/ipv4/tcp_input.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/net/ipv4/tcp_input.c b/net/ipv4/tcp_input.c index 2868ef2..edaaebf 100644 --- a/net/ipv4/tcp_input.c +++ b/net/ipv4/tcp_input.c @@ -2457,8 +2457,8 @@ void tcp_cwnd_reduction(struct sock *sk, int newly_acked_sacked, int flag) u64 dividend = (u64)tp->snd_ssthresh * tp->prr_delivered + tp->prior_cwnd - 1; sndcnt = div_u64(dividend, tp->prior_cwnd) - tp->prr_out; - } else if ((flag & FLAG_RETRANS_DATA_ACKED) && - !(flag & FLAG_LOST_RETRANS)) { + } else if ((flag & (FLAG_RETRANS_DATA_ACKED | FLAG_LOST_RETRANS)) == + FLAG_RETRANS_DATA_ACKED) { sndcnt = min_t(int, delta, max_t(int, tp->prr_delivered - tp->prr_out, newly_acked_sacked) + 1); @@ -3610,7 +3610,8 @@ static int tcp_ack(struct sock *sk, const struct sk_buff *skb, int flag) if (flag & FLAG_UPDATE_TS_RECENT) tcp_replace_ts_recent(tp, TCP_SKB_CB(skb)->seq); - if (!(flag & FLAG_SLOWPATH) && after(ack, prior_snd_una)) { + if ((flag & (FLAG_SLOWPATH | FLAG_SND_UNA_ADVANCED)) == + FLAG_SND_UNA_ADVANCED) { /* Window is constant, pure forward advance. * No more checks are required. * Note, we use the fact that SND.UNA>=SND.WL2. -- 1.8.3.1