Received: by 2002:ac0:a5a7:0:0:0:0:0 with SMTP id m36-v6csp3432415imm; Mon, 6 Aug 2018 04:50:47 -0700 (PDT) X-Google-Smtp-Source: AAOMgpd940EZt8KDwTJybUUG9UD+8hgKZ2B7/CoBKiuMNniDrFI4gYXoreewxFhlDKczLkL/APxQ X-Received: by 2002:a62:68c3:: with SMTP id d186-v6mr16857786pfc.70.1533556247624; Mon, 06 Aug 2018 04:50:47 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1533556247; cv=none; d=google.com; s=arc-20160816; b=k5MbgPjJ+cc381+qemhibZL8OEGdGB7XuTsnK43xv6TK79NQ9tSuTwgNPpqkAXUu8Z hvywFOVzqBNcmrFLvffBu2Gi4ckCVADSvlbM5k3j+J6splgx2NaM6RGsL+Fd5Zjeh3xF ytFDuVF8Wr46q7ouHeaN0HKbd0R6W0Th8T5IqT5PRT9R11a1mmYJAKuPNOjY+fuBBtB4 00Q4zzcjc65e3574pv+QK9FLLdshDpKlp4FVPcxpQS1oLIZ5BRdtv4+WAUvkcpCNrQ44 TiII+RPkO9P4MpO29W6Xc95c0kkCWG6uMysianMOXEDyDVA2+5iXxU4QuM8Ek4Q6dSx2 cShA== 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:arc-authentication-results; bh=yijoUS1MFBPFg+VL+kX0YrD63FqfAB1oTUd4eglEjbI=; b=Q9btNrHYnyq0P/yVvKkjEayNMNiWIcw6e6sBdnKMW/Cqx1ehu5AhHzaO1NVDNinCTD UqvCYlCzWNK/3qkkJMZohY8Il5u4SburHZegncnu6F1nPOIDGTvKMYj6Cv9SZv+25hMY hP+1ipA2wpaPHECaPCB2bYr/oYYoKI8V9FmV6JFn467ORw1RZHoqdfzYnZrBYz+W0/hx PDlZcrV9/5TiqjFwv9ODSh7XYiolY4ZBic6ww+kmqiG5KSeAdY/2ehZ0C1MsFnf+EN0y JseRS53AP2sjjrBhYPwNNqy1YPJCO/J2Y2v0M5eQjO1JS9rLj+7lM9gnXvV0uITiU0iM 6+GQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=lA3b4P03; 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 c9-v6si12194954pgi.493.2018.08.06.04.50.24; Mon, 06 Aug 2018 04:50:47 -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=lA3b4P03; 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 S1730897AbeHFN4D (ORCPT + 99 others); Mon, 6 Aug 2018 09:56:03 -0400 Received: from mail-pf1-f195.google.com ([209.85.210.195]:36378 "EHLO mail-pf1-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730822AbeHFN4C (ORCPT ); Mon, 6 Aug 2018 09:56:02 -0400 Received: by mail-pf1-f195.google.com with SMTP id b11-v6so6748127pfo.3; Mon, 06 Aug 2018 04:47:20 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id; bh=yijoUS1MFBPFg+VL+kX0YrD63FqfAB1oTUd4eglEjbI=; b=lA3b4P03jwg1gQZSAKh2A8czLjx4TAJoro8R1emSS3pKd+LXCa8u1Mn/TqoOxo+GKi qBjEiIObdo0ZIDo2+18+oO0v8NwDumV75hebclfI+hwRzmxouR3ihvkhVGw1kjBXqhk/ M7E4K3sI4TVipli6oxFpszD2/rCUNs2wYpLbaWyvq5SvyZyK8a4DUECjlCqG0ylJGW1O G/BJ8z+uKBUpTaDzf+61cn4R/2u+2mffELYRinJ/P/j3D5A/17vSI8S8Ch2vw0J9x4aI 6WXqG4W4lVQ6OxD0ICw/zMMxBFxCI8svwBDlXPHDPQAExJ/PGE9a4mmL5GOjm1bxjuU+ JQyQ== 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=yijoUS1MFBPFg+VL+kX0YrD63FqfAB1oTUd4eglEjbI=; b=Lb8Hn8ZEVzrSe8KN/0rLGsunb4lqfhLcMm/7FykQmnDwUVSh4wzNP8O7INvqdrAnBb 9XurUq5KJOyzKhRirSH1/pDuAG3pCByAS6gYLw6aq8DY6UytyiJDtDoy+J8LDGseRdJ0 8fObtWB7l1Bj83CDAMie1YWHLrWNA6V6GLRKC4jDqKOGXzOB42sPKDlOUY3Suj6RXnOh aRFrCY2oNqZBTLL0SULbJbMCMJhVoAqQXyO0ffXkK+bmXstoKZYZTyspGXJQ00g6mseV dWIUggLZaJFNO95Yqfo/QC8RGatpRgsU82/Hl8LoDKvLbm0Mr0Yy2Ic/2P+Xqzk/eECb O7Kg== X-Gm-Message-State: AOUpUlFXPRcVPezYe68QT8e/x/ukXRadHQAy+6dpNVsZicVfP0uA5BLD W/NYXPcN0zA26oaaDfpdRGCkLNCRr/c= X-Received: by 2002:a63:7b1b:: with SMTP id w27-v6mr13715564pgc.199.1533556040097; Mon, 06 Aug 2018 04:47:20 -0700 (PDT) Received: from bogon.didichuxing.com ([203.100.54.194]) by smtp.gmail.com with ESMTPSA id j72-v6sm19357098pge.19.2018.08.06.04.47.17 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 06 Aug 2018 04:47:19 -0700 (PDT) From: Yafang Shao To: edumazet@google.com, davem@davemloft.net, yanhaishuang@cmss.chinamobile.com Cc: netdev@vger.kernel.org, linux-kernel@vger.kernel.org, Yafang Shao Subject: [PATCH net-next] tcp: fix the calculation of sysctl_max_tw_buckets in tcp_sk_init() Date: Mon, 6 Aug 2018 19:47:00 +0800 Message-Id: <1533556020-20778-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 tcp_hashinfo.ehash_mask is always an odd number, which is set in function alloc_large_system_hash(). See bellow, if (_hash_mask) *_hash_mask = (1 << log2qty) - 1; <<< always odd number Hence the local variable 'cnt' is a even number, as a result of that it is no difference to do the incrementation here. Maybe the compiler could also optimize it, but this code is a little ugly. Fix: fee83d09 ("ipv4: Namespaceify tcp_max_syn_backlog knob") Signed-off-by: Yafang Shao --- net/ipv4/tcp_ipv4.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/net/ipv4/tcp_ipv4.c b/net/ipv4/tcp_ipv4.c index 9e041fa..a9b7c4b 100644 --- a/net/ipv4/tcp_ipv4.c +++ b/net/ipv4/tcp_ipv4.c @@ -2543,7 +2543,7 @@ static int __net_init tcp_sk_init(struct net *net) net->ipv4.sysctl_tcp_tw_reuse = 2; cnt = tcp_hashinfo.ehash_mask + 1; - net->ipv4.tcp_death_row.sysctl_max_tw_buckets = (cnt + 1) / 2; + net->ipv4.tcp_death_row.sysctl_max_tw_buckets = cnt / 2; net->ipv4.tcp_death_row.hashinfo = &tcp_hashinfo; net->ipv4.sysctl_max_syn_backlog = max(128, cnt / 256); -- 1.8.3.1