Received: by 2002:a25:ab43:0:0:0:0:0 with SMTP id u61csp502879ybi; Thu, 13 Jun 2019 21:28:46 -0700 (PDT) X-Google-Smtp-Source: APXvYqzGXNo/KauNN9lqZD5aBUNtoAvLheKtfVGvgdpC8kOExVUU+qQi9My0RC0uIN8pNY5IpJAQ X-Received: by 2002:a17:90a:35e5:: with SMTP id r92mr6914080pjb.34.1560486526130; Thu, 13 Jun 2019 21:28:46 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1560486526; cv=none; d=google.com; s=arc-20160816; b=vR2hewm0GJQWvdTG5P9a4dwnpk93V6KVXpB9d4zONNDmtaaKffcAfzZWnSR9M1HKpq 0rVpRn97XOnTTVRQ2PbtanIo9S+9lijvXz8hizA+jS9HS35qk8OgzpqsTrD4Plv2ez2d q78c/hHXypaPTq19KP0YCc0PYMyVRNCU30Pmxj2wZL/Mnq+tX9Plqm3qm8lrXU9QYBZL 0v7gyLKGh5+/jtVk4J3d233nehz8AWHoI3A5LDLgDUQlwwwU8oUGwPArcvwBU+lW2sR7 3dsFza2uBCO8Efwlz1EQiwSDL6YVv9LcnCSECHaJ4dCxCX1NsmDGI7MWrdjPTgv8eYmy gOJw== 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=MynhCFGpqGZRdy/9WKV4HLYAsGzpq7c+1tDJnUMvrZU=; b=y5at90tfeQoTjrb6n/INaBYhWJCyPQ8iuLT1o0St/nZ/L2ZELK7qS8DYF2kfpdQ130 elNqHrP1Ywb8JxFaQQ/8SHeB9G5UkGSL9aNlV91/dEYMncptFiDqlwEWE7jzMtnG9Pu1 VcpZp/K36yIPndFOyKlP5ZQJ4pRY3Sv5Kp1ris5M9lRn7TnijEVkxngsX6E2ZP+HIYju aLQKW2sVOFJmv22Mom+ZFrmArJjmQ9fQyY2FB376fv4Uxpvm5qovr5i3MNfkO5xTxMbx fnZiTsdGbrPZTQ5hi7WBW0K0ioQuH3x84cmXMotFo25JF6uF7EkAcuCcD8JKn9/CBQJc vvfA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=J+8uMKYN; 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 g12si1259167pla.322.2019.06.13.21.28.30; Thu, 13 Jun 2019 21:28:46 -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=J+8uMKYN; 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 S1725906AbfFNE2Z (ORCPT + 99 others); Fri, 14 Jun 2019 00:28:25 -0400 Received: from mail-pf1-f195.google.com ([209.85.210.195]:35628 "EHLO mail-pf1-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725767AbfFNE2Y (ORCPT ); Fri, 14 Jun 2019 00:28:24 -0400 Received: by mail-pf1-f195.google.com with SMTP id d126so607899pfd.2; Thu, 13 Jun 2019 21:28:24 -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=MynhCFGpqGZRdy/9WKV4HLYAsGzpq7c+1tDJnUMvrZU=; b=J+8uMKYNoOLsfTiXqiLyLoLc/SKcQPM9blclrSKHTa0mZt/o49S/fk3/09YAF0ROEa 5Fv4UtfTdD83CaoDMEDg28fReb4uBw4/f12GFNABPDwG3oIERxrH1z3ULZh3CJMJwNdc wuLzQhDgAtBx6RXjVnrZZ988vY5Nw/duo20whUJ7ylu9nMGXnT31WWcCdffxG4P5292L fo8iPsU42wHFZbIKukXN1Gbk3siox/m6nCcpXRwwJLTQuedQMw+lNnOaJBR5gtYhnTGL QKQiq96f0gyj/c0Ox3mBO1fKNPCWw9PeG5rKydU9F+azg1wu2+jv65NguR+3AzuXOmAL ouYg== 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=MynhCFGpqGZRdy/9WKV4HLYAsGzpq7c+1tDJnUMvrZU=; b=guoR9syc+U2MPGIlXIBHuS6ctgWVotrOGzSv8cKKHU9N2BvW/ludaXMkiq02cVaYCI t4Ji89My9Mg+YCnKRQODMZuqk/0/gRP/pd7p0c5dx+L0RV6QerhNrg93uuUsNiaIjrz2 KOrb8dL/i5Vx4telc3i8Az1soEWidpcfTCQxZUAhVr3U3/qcOR2xUksb/UWviteHFPqL vhGndzVZ7aX8Gk80HpZhYB/SPHtSk2aD6H749kfl1OFu0LWn1CqiA8DorUJ+RwT+h/De rsJHHFGaxovy0AwABlbCJmANBhId8y+7LHkkcoGZzg1OC1D3VyXdqq6cykGtTjh5Ncrn T3wQ== X-Gm-Message-State: APjAAAVjrNSIKX93pnIA6DxgBUqjUq3YRtZ7SzMrHSzuGfxvuEmiWiCV YcMP+xkwuso4FKcbp2ffbGCcqoh6 X-Received: by 2002:a17:90a:30e4:: with SMTP id h91mr8614183pjb.37.1560486503596; Thu, 13 Jun 2019 21:28:23 -0700 (PDT) Received: from [192.168.86.235] (c-73-241-150-70.hsd1.ca.comcast.net. [73.241.150.70]) by smtp.gmail.com with ESMTPSA id s7sm1287340pgm.8.2019.06.13.21.28.22 (version=TLS1_3 cipher=AEAD-AES128-GCM-SHA256 bits=128/128); Thu, 13 Jun 2019 21:28:22 -0700 (PDT) Subject: Re: [PATCH net v2] tcp: avoid creating multiple req socks with the same tuples To: maowenan , Eric Dumazet Cc: David Miller , netdev , LKML References: <20190612035715.166676-1-maowenan@huawei.com> <6de5d6d8-e481-8235-193e-b12e7f511030@huawei.com> From: Eric Dumazet Message-ID: <6aa69ab5-ed81-6a7f-2b2b-214e44ff0ada@gmail.com> Date: Thu, 13 Jun 2019 21:28:21 -0700 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.7.0 MIME-Version: 1.0 In-Reply-To: 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 6/13/19 9:19 PM, maowenan wrote: > > > @Eric, for this issue I only want to check TCP_NEW_SYN_RECV sk, is it OK like below? > + if (!osk && sk->sk_state == TCP_NEW_SYN_RECV) > + reqsk = __inet_lookup_established(sock_net(sk), &tcp_hashinfo, > + sk->sk_daddr, sk->sk_dport, > + sk->sk_rcv_saddr, sk->sk_num, > + sk->sk_bound_dev_if, sk->sk_bound_dev_if); > + if (unlikely(reqsk)) { > Not enough. If we have many cpus here, there is a chance another cpu has inserted a request socket, then replaced it by an ESTABLISH socket for the same 4-tuple. We need to take the per bucket spinlock much sooner. And this is fine, all what matters is that we do no longer grab the listener spinlock.