Received: by 2002:ac0:a5a7:0:0:0:0:0 with SMTP id m36-v6csp4172048imm; Mon, 6 Aug 2018 18:48:04 -0700 (PDT) X-Google-Smtp-Source: AAOMgpcROYrQghuAwrcWZOro+8qNAJPiZkhMevXrGIu44BmfWddGHZM/MhHF8p/17DTseOS8630n X-Received: by 2002:a17:902:9a47:: with SMTP id x7-v6mr16031602plv.37.1533606484660; Mon, 06 Aug 2018 18:48:04 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1533606484; cv=none; d=google.com; s=arc-20160816; b=Q7dOt40ZtnnGRMptmD4JPgWO+g/ITslBsXe4nZpGri/YqdIAEhhWdJCZumHRQRKQ0f GldKb+D30MlCvj8sSIInRQaZ4qwTa1u9ztYXurR0O+ZIv3a5+ZWDOY3irz+hNMNXO+EX jlrm1Acj5KCQXwmrYBkLRdq84nyvCepTGm/JRNzsfAu31FPNhdS6qYE8Ku02/CZtm8cb eROC01JCup3Th90RuyFxg1dMxeEqZaha49G6laCmOvSFEoGNT6aZuJYKCIzSc5AbCnFg AqKNHcDokWTqSTIuE6tRhqrBdbuSAiO8xPIE3uxzM6CfGPsWCdEbud3S5HhUs7jaeUUn brUA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :references:in-reply-to:mime-version:dkim-signature :arc-authentication-results; bh=duih8xtEl8dcKiqrRSMQb8mIrFSoiDvO60a+C7OqFL8=; b=g8jaOb4eAukoqyajRj+UAgBExV5BCdq+S/aTdzdBYGFTBZkoHFJLjXufyhfWBYt6TD TTdKqgupkRlSJFu9Qc/nbHOPS5brpH3O77649v+KOT40+UmhIzOJxWytc4F3hsGHMUsw 59zMGzpkk8nCsdq3vhTLxoaHE5iqCOhITtE9SV880SBzYNDPEfuhG7QA9GoisoTEXfAB rdsIV9Lh2OVLScR9hWHD4NqpFdjDrWaOyQg9xvbIeKTk9RnEI40M06cxOTYZWhOJ2l4i EaeiuPORj/5l1IaNm8+y7XkwLFQvjS9Ztsy4rFGmS04cj/4dFaBfp+soDrl/uKQvwhfl 3oxg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=KWBhfIVJ; 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 b4-v6si20036pgg.537.2018.08.06.18.47.26; Mon, 06 Aug 2018 18:48:04 -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=KWBhfIVJ; 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 S2387404AbeHGDxP (ORCPT + 99 others); Mon, 6 Aug 2018 23:53:15 -0400 Received: from mail-it0-f68.google.com ([209.85.214.68]:37831 "EHLO mail-it0-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729786AbeHGDxP (ORCPT ); Mon, 6 Aug 2018 23:53:15 -0400 Received: by mail-it0-f68.google.com with SMTP id h20-v6so20905469itf.2; Mon, 06 Aug 2018 18:41:23 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc; bh=duih8xtEl8dcKiqrRSMQb8mIrFSoiDvO60a+C7OqFL8=; b=KWBhfIVJi0dxw9QHd6G6IQ3VAZUpamRA+Nr0tvbTMwq/o7oYzM3I/P6VfwmyaBij85 oo9GZVllOr+nTOFkrgi28rajocHE481finmQy/qDdvI5Ug7LiIZI3aJrwIHJQHUi01D+ 4diRyn2FHJ+2jP3CyMX+rHBIM8+i/tFAz9Lf4NFDY/6Oj/exkkXb/ase0oR9iBsb3t2a jMLEgMB0a7cP01Ejs1mdWSkum3WPT4P4xUOJn9255Q5+wrDxbuA5+3FUbMlfB4syOhNo rI4lolJw35zoGPFsJ0j6tvMvDsAMn0rRXg1dDPaIkPqaL9SV6iKBLSBfYvU0rR4CjOk+ 5kdA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:in-reply-to:references:from:date :message-id:subject:to:cc; bh=duih8xtEl8dcKiqrRSMQb8mIrFSoiDvO60a+C7OqFL8=; b=SrYio03UiwLejZVWuoTTNkiXsa9NRzWIsSCx77Ym+lo+Eaar9i2SyplwCS3AEmlx2g qD3iDykzp9PxOxqKjfTB63sZmjwdoJ8bE8MOLFSev82wFJMYQ+CK8Txhdp7426gdUaWq 38zT7LshJGlGTdX5Tiyh7YOI/JAe/zP5YZ9qf5wUau+NYCX0fLe863ZLfmpXb/s7FhEG Mu8pA//asqOyN8oYGuNqCXWY2kQkiQxFixA9z1aTNsM3Jr15xFGw54+xT3/WrLeYk8ee cJjrGtjgw8s9QhC07j9pWg7Q1GL4Z/AgN56/iUDU97235OeCDa1hAZBC6Uv+JLkhx2PW lsqQ== X-Gm-Message-State: AOUpUlHiAO5Yg8cuuV946QrV8cJPM6j5h/JdO8Sq2DKdizKLGCH0+Weg lO8g97xYrWnPRDAoQ/v/UIlyNl6MOoYJWY905+U= X-Received: by 2002:a24:5004:: with SMTP id m4-v6mr347247itb.38.1533606082906; Mon, 06 Aug 2018 18:41:22 -0700 (PDT) MIME-Version: 1.0 Received: by 2002:a6b:7a47:0:0:0:0:0 with HTTP; Mon, 6 Aug 2018 18:40:42 -0700 (PDT) In-Reply-To: <20180806.134116.1016660959593702560.davem@davemloft.net> References: <1533556020-20778-1-git-send-email-laoar.shao@gmail.com> <20180806.134116.1016660959593702560.davem@davemloft.net> From: Yafang Shao Date: Tue, 7 Aug 2018 09:40:42 +0800 Message-ID: Subject: Re: [PATCH net-next] tcp: fix the calculation of sysctl_max_tw_buckets in tcp_sk_init() To: David Miller Cc: Eric Dumazet , yanhaishuang@cmss.chinamobile.com, netdev , LKML Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, Aug 7, 2018 at 4:41 AM, David Miller wrote: > From: Yafang Shao > Date: Mon, 6 Aug 2018 19:47:00 +0800 > >> 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") > > The correct tag is "Fixes: " OK > >> @@ -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; > > This is completely harmless, and does no harm. > It is harmless, meanwhile, it is useless and a little ugly. By the way, why do we init sysctl_max_tw_buckets to (tcp_hashinfo.ehash_mask + 1) / 2 or (tcp_hashinfo.ehash_mask + 2) / 2 ? Per my pespective, this default value is a little huge, sometimes we have to set this value to a lower value with sysctl, otherwise it may easily cause tcp port exhaustion issue. So why not just init it to a lower value ? > You aren't "fixing" anything.