🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: linux.kernel.netdev
Article #7747

Re: [PATCH net v2] tcp: Fix fastreuse cache initialization on first bind

#7747
From: Jason Xing
Date: Tue, 27 Oct 2026 06:13
33 lines
13218 bytes
On Mon, Oct 26, 2026 at 5:55 PM Zhewei Yuan <yzwlhm@gmail.com> wrote:
>
> inet_csk_update_fastreuse() initializes the reuse caches only when
> tb->bhash2 is empty, but both inet_csk_get_port() and
> __inet_inherit_port() link tb2 before calling it, so the first-bind
> branch is never taken.
>
> As a result, SO_REUSEADDR binds never get fastreuse=1 and keep
> scanning existing owners, and SO_REUSEPORT starts in STRICT instead
> of ANY.
>
> Initialize the caches when tb2 is the only entry in tb->bhash2 and has
> no owners. Timewait sockets are also linked on tb2->owners, so this is
> equivalent to the old hlist_empty(&tb->owners) test.
>
> Found by manual code inspection and confirmed with GDB. Binding 16000

I thought it was discovered by an LLM.

> SO_REUSEADDR sockets to one address/port in a KVM guest takes 4.18 s
> before and 19.4 ms after this patch. Existing bind/reuse selftests
> pass. Analysis and testing were assisted by an AI tool (Codex).
>
> Fixes: 8002d44fe84d ("tcp: Check hlist_empty(&tb->bhash2) instead of hlist_empty(&tb->owners).")
> Reviewed-by: Eric Dumazet <edumazet@kernel.org>
> Signed-off-by: Zhewei Yuan <yzwlhm@gmail.com>

Reviewed-by: Jason Xing <kerneljasonxing@gmail.com>

Thanks!
Technical Details
Message-ID: <CAL+tcoCsZs3JL4CdmAP6oNk8eZD9tmtzyeQEeBnb1m9+ypMp9Q@mail.gmail.com>
Path: mbox-mo1.pugleaf.net!archive.usenet.blueworldhosting.com!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-352234-linux-kernel-netdev=dewy.ru
References: <20261026095208.58504-1-yzwlhm@gmail.com>

Show Full Headers
Complete Article Headers
Path: mbox-mo1.pugleaf.net!archive.usenet.blueworldhosting.com!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-352234-linux-kernel-netdev=dewy.ru
From: kerneljasonxing@gmail.com (Jason Xing)
Newsgroups: linux.kernel.netdev
Subject: Re: [PATCH net v2] tcp: Fix fastreuse cache initialization on first bind
Date: Tue, 27 Oct 2026 14:13:55 +0800
Organization: Usenet Network
Message-ID: <CAL+tcoCsZs3JL4CdmAP6oNk8eZD9tmtzyeQEeBnb1m9+ypMp9Q@mail.gmail.com>
References: <20261026095208.58504-1-yzwlhm@gmail.com>
MIME-Version: 1.0
Content-Type: text/plain; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable
Injection-Info: usenet.network;
	logging-data="1476123"; mail-complaints-to="abuse@usenet.network"
Cancel-Lock: sha1:JjDYpBT/0KMLYdcdYni6NjMxtwA= sha256:59yBm5Q4FFMdZm3IQ4LEMcvawT155RPzLAhex35L3s8=
	sha1:VoyLdez8A3sIY4hCstlfyR0Nyeo= sha256:8/ZHcUmyS/nVJi9WTZD65md8OsMuUmpRPCm1J3wR+FA=
List-ID: <netdev.vger.kernel.org>
X-Mailpost-Empty-Hdrs: X-Spam-Level
X-Received: from localhost (localhost [127.0.0.1])
	by mail.dewy.ru (Postfix) with ESMTP id 0A33C125BDD; Tue, 27 Oct 2026 09:15:13 +0300 (MSK)
X-Virus-Scanned: Debian amavisd-new at usenet.network
X-Spam-Flag: NO
X-Spam-Score: -3.048
X-Spam-Status: No, score=-3.048 tagged_above=-9999 required=6.31
	tests=[DCC_REPUT_70_89=0.1, DKIM_SIGNED=0.1, DKIM_VALID=-0.1,
	DKIM_VALID_AU=-0.1, FREEMAIL_FORGED_FROMDOMAIN=0.001,
	FREEMAIL_FROM=0.001, HEADER_FROM_DIFFERENT_DOMAINS=0.25,
	MAILING_LIST_MULTI=-1, RCVD_IN_DNSWL_MED=-2.3, SPF_HELO_NONE=0.001,
	SPF_PASS=-0.001] autolearn=ham autolearn_force=no
X-Authentication-Results: mail.dewy.ru (amavisd-new); dkim=pass (2048-bit key)
	header.d=gmail.com
X-Received: from mail.dewy.ru ([127.0.0.1])
	by localhost (mail.dewy.ru [127.0.0.1]) (amavisd-new, port 10024)
	with ESMTP id BhMO0xlkxGLc;
	Tue, 27 Oct 2026 09:15:06 +0300 (MSK)
X-Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=172.234.253.10; helo=sea.lore.kernel.org; envelope-from=netdev+bounces-352234-linux-kernel-netdev=dewy.ru@vger.kernel.org; receiver=<UNKNOWN> 
X-Authentication-Results: OpenDMARC; dmarc=fail (p=none dis=none) header.from=gmail.com
X-Received: from sea.lore.kernel.org (sea.lore.kernel.org [172.234.253.10])
	by mail.dewy.ru (Postfix) with ESMTPS id C8303125BDB; Tue, 27 Oct 2026 09:14:56 +0300 (MSK)
X-Received: from smtp.subspace.kernel.org (conduit.subspace.kernel.org [100.77.114.92])
	by sea.lore.kernel.org (Postfix) with ESMTP id 994EB27027; Tue, 27 Oct 2026 06:14:41 +0000 (UTC)
X-Authentication-Results: smtp.subspace.kernel.org; arc=pass header.oldest-pass=0 smtp.remote-ip=127.0.0.1
X-ARC-Seal: i=3; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=pass;
	t=1793081681;
	b=1T0Wf5Gpt5hNXDbN1WLnPNWkX3VrJf6qEwI4fjgWOvI5jGWKoKle1RdAwtIsIsl9v8bc
	 Lf/x/fbwfqW2LPp3r9NL/NE/XlMjQTB5Si7k+4ZIYVdYCmVhkAoyAfQo58qnC3+IfgenM
	 gTjcBFdBd4ugBntO7Jh3jPB7rkxzLIGWj2MOtnvy2fpmaWdJPliKHz1Mv5a1Iz71o5o0E
	 esKnYxjAAGXdoieW65QzTUI/tfI41wodSEcXmhz+lVQiyJNOEIgZGXUMAcMg2YISarxBd
	 AONElkccg8xAtRto9x/bHweW63pyYQ3kw8NBd/eAPCTDxFHKyJY523cJZnV+ch7SSkQ==
X-ARC-Message-Signature: i=3; d=subspace.kernel.org; s=arc20261015;
	a=rsa-sha256; c=relaxed/relaxed; t=1793081681;
	h=X-Original-To:Received:DMARC-Filter:Received:DKIM-Signature:
	 X-Google-DKIM-Signature:X-Gm-Message-State:X-Gm-Gg:X-Received:
	 X-Mailing-List:List-Id:List-Post:List-Help:List-Subscribe:
	 List-Unsubscribe:List-Owner:Precedence:MIME-Version:References:
	 In-Reply-To:From:Date:X-Gm-Features:Message-ID:Subject:To:Cc:
	 Content-Type:Content-Transfer-Encoding;
	bh=Aj57gDgkYoxrbL3zRJ5xxNDor6hGOsBG1Hto8fARzGQ=;
	b=PjQSKrchnA0aS/A09lR2uvPaQiIzj86PvV+VdQiXfBlSHkMQeOZ5cxS+VwuqJciC8Gon
	 2DqKTSMNIIumq1Cu4YVc2+EW+a7Srar/pEIIE8Fc+Gh0/+wy4jkcx3lyy3uIWNE03jvxG
	 nU4di1a86l2CLb+vVlq61H/UsraAaJpEirL9MUF5VeHk3Y9rqy3dHufyYlxuEpoimDu1+
	 Sz4Tlz6eCAL2S5gFArLtp+K+6meL5f06pCb1Frhro4J6Ah+AsdgRC8g3NH5t5Inft5/KW
	 3t9x1YxRtHhGpxE6MqYTmwOpP0rGGHhWqthfArthBWhzb2nDLC9HhCg2Ydzq+akE2Eg==
X-ARC-Authentication-Results: i=3; smtp.subspace.kernel.org; 
	dkim=pass header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20251104 header.b=jujt5EfL;
	dmarc=pass header.from=gmail.com;
	spf=pass smtp.mailfrom=gmail.com;
	arc=pass header.oldest-pass=0 smtp.remote-ip=127.0.0.1
X-Received: from localhost.localdomain (localhost [127.0.0.1])
	by smtp.subspace.kernel.org (Postfix) with ESMTP id 61550606A324;
	Tue, 27 Oct 2026 06:14:41 +0000 (UTC)
X-Authentication-Results: smtp.subspace.kernel.org;
	dkim=pass (2048-bit key, unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20251104 header.b=jujt5EfL
X-Authentication-Results: smtp.subspace.kernel.org; arc=pass header.oldest-pass=0 smtp.remote-ip=209.85.167.54
X-ARC-Seal: i=2; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=pass;
	t=1793081675;
	b=Q5oA5GQlx4mJlRtJwWZIz6P4Tm0FqKhM5PcKNRx23mAFhX9hy+lh27tHSh+yNpZ/w+ET
	 CijPSU3ld14hWXsfReuiE3qdPpg87uirIyEa74K9C0FznQfeDe+qR6MwRISe3Sn8zNlY3
	 g1eozzhntYyTVlhDPURvkxkjinXEMNi1xKX7+8hARa45F+nxH4A+gSVcdwmZ0mzegulNc
	 G665LuznrQlP2SoXx9qQ9mj5fotgwC5tvHMSIoO43Lrez7eabmbMRHOdtAsr9jg54sCPZ
	 7IqeNlNIZiDHJPfwDLHmf8VerACC9ECoY/nyZmgz+f6Wg2jp2o7iVppwlj3nJiKoIlQ==
X-ARC-Message-Signature: i=2; d=subspace.kernel.org; s=arc20261015;
	a=rsa-sha256; c=relaxed/relaxed; t=1793081675;
	h=DMARC-Filter:Received:DKIM-Signature:X-Google-DKIM-Signature:
	 X-Gm-Message-State:X-Gm-Gg:X-Received:MIME-Version:References:
	 In-Reply-To:From:Date:X-Gm-Features:Message-ID:Subject:To:Cc:
	 Content-Type:Content-Transfer-Encoding;
	bh=Aj57gDgkYoxrbL3zRJ5xxNDor6hGOsBG1Hto8fARzGQ=;
	b=wP+R2UuLiFUe/4o8PxXG9cjEN8aW6hPqh6BV0JWwQmVc+Aw2kmrlLhsLZ2EzUSwNueUm
	 Fr2vhNH45hVVtRzI84YBQKitk8B2+Kxp6wTGR7aqJ+/VFCKZZKD5vyPywvFJlxC8Yb98N
	 S1/V32MTe4jJficboVwhM12OQPFdrZBbgzwzuDG2r9ZLfr2e+HIspbrexVSblYtE+MyQl
	 tCsrtFIb6O53Y1c/D607ipVslnlv1Jmb1shT+Q4jByHvYrk6sgG0cNZr4Mo00EaB5FWrW
	 eNOdc8nhVukI2Eqv6Kxb61WuMCOeQHBrTliJAb6WpyLme+TmM2XuRIMW8gsnuRCQ8IQ==
X-ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; 
	dmarc=pass header.from=gmail.com;
	spf=pass smtp.mailfrom=gmail.com;
	dkim=pass header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20251104 header.b=jujt5EfL;
	arc=pass header.oldest-pass=0 smtp.remote-ip=209.85.167.54
X-Received: from mail-lf1-f54.google.com (mail-lf1-f54.google.com [209.85.167.54])
	(using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits)
	 key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256)
	(No client certificate requested)
	by smtp.subspace.kernel.org (Postfix) with ESMTPS id 203B6606A31B
	for <netdev@vger.kernel.org>; Tue, 27 Oct 2026 06:14:35 +0000 (UTC)
X-DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 203B6606A31B
X-Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com
X-Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com
X-Received: by mail-lf1-f54.google.com with SMTP id 2adb3069b0e04-5be4d648aacso3489304e87.3
        for <netdev@vger.kernel.org>; Mon, 26 Oct 2026 23:14:34 -0700 (PDT)
X-ARC-Seal: i=1; a=rsa-sha256; t=1793081673; cv=none;
        d=google.com; s=arc-20260327;
        b=Ke0frcwmdyBk5+Xqsj76GFYbPJL4EiEIFlYLoxez9NKgva6hObQPfo9x3xo6ZXj6ch
         PzuD6741YfRGKdezeOdOxBfU6/L8f92HPT/UDcNNMWDStJqHKhdiymr83rSRO2b5kBLf
         c+k/mbue9MMD30HcqA2mvMA8BprGKYPlDrgciTLuiz7N6p8S4wwixDUgv0iPyzM/i5uZ
         Vfjme1/u1zqnRNI+lxvgskw17PVPcRwxrQwgj/rehfwuCp3hjHqw9UsM0FAnm93saB2U
         POXW28dtmKFF+LBOi8+m777RKkQ0u70AkWCBmxivJQk9Y9QEMB3bG0fqAw1ZEEquWRCO
         fEaA==
X-ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20260327;
        h=content-transfer-encoding:cc:to:subject:message-id:date:from
         :in-reply-to:references:mime-version:dkim-signature;
        bh=Aj57gDgkYoxrbL3zRJ5xxNDor6hGOsBG1Hto8fARzGQ=;
        fh=kCrkluS/Id7P58oqhawor+XLhL1t5FE/zMZ0XEG+W7I=;
        b=fcRNtRF97E57gP6Q3bJw/kCL2YIkvnRuZEMrFr0sx15na32SLKIMHy5k0NIYWQTqzl
         yD8AAP417x9dsbkWDFqpsiBxIdWqO4Z1loI2kLC1dSXhZ0WN7qrovfc83Ub9yB2eSJNu
         Z10BKNRebbGG7xVI5EOKUJSO5PUJsHOwwfHVBI+jaZcF//a8zLPajFm9Lz+lgQRDNn/A
         6R87fzD0PjeaJutIIjCwq65f5wckVC0s9FXeUxBxJR65KGhKi6TN5u0E4Ul2v5PM8FUC
         T6PdN0LKvQ8nfHLH0NPZ3M/VzIPmUrpR3kVt60BmhCCKkos0UdqcVdD8jPsxaFMLw0XR
         1HSA==;
        darn=vger.kernel.org
X-ARC-Authentication-Results: i=1; mx.google.com; arc=none
X-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
        d=gmail.com; s=20251104; t=1793081673; x=1793686473; darn=vger.kernel.org;
        h=content-transfer-encoding:content-type:cc:to:subject:message-id
         :date:from:in-reply-to:references:mime-version:from:to:cc:subject
         :date:message-id:reply-to:content-type;
        bh=Aj57gDgkYoxrbL3zRJ5xxNDor6hGOsBG1Hto8fARzGQ=;
        b=jujt5EfLxkWfiU9Y4LvukWaGftjve6T81Pji1vz5Co5DA0S7dnvzB4wcmrcapqnPFY
         uHN2zOVjKMVDva+RzQWTQ7s7XpRm9IUxWnQ1ncEFt/NX2/bAIpgqIIS9d5+zb8uaBNRd
         u66QVycfeiGTQxRmzNPJW3WuBdHRZBUZeC+gJmW5xrVOzlESZ1T95qbydRaheqpvkO3J
         fcTGZ5NllHVChKMNOWQyUqVQ+WowGNwN4poykAPAJS7Ow1xwV89azF4nau3dDGt6pI1K
         d7lxZbkOBlukE7M841WRhcX04jaTj4wMAVQoI2nANEMUaMSJ7EsJ3/aht8F3X8xR6nc/
         wRog==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
        d=1e100.net; s=20260707; t=1793081673; x=1793686473;
        h=content-transfer-encoding:content-type:cc:to:subject:message-id
         :date:from:in-reply-to:references:mime-version:x-gm-gg
         :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to
         :content-type;
        bh=Aj57gDgkYoxrbL3zRJ5xxNDor6hGOsBG1Hto8fARzGQ=;
        b=rJbZWXepuya+6gIVwvNh0weMi6bbCqyyLU0/5eCx35aipgx+ya+vLbZyUSAWJ/QyiJ
         ms4JfHZDB5mitNjVbE8soi+t/23J6ypHhzT+DNQSwAPEFazyTwcA6DjrX/wlpglCnuWR
         r/npjwGccONz+RdZyLVNzc05+2rZlXRJNp6dnDmMHWR2hEhC+qZeLa6eg7QE0rweCts8
         +c90TDSZBXBdtZnP/AbFINtbky9nNuyH0RYc+pX/996yo7pfqrzk18qihgMite3LlbsC
         spjs00ZrqWYoJx1d4zn5aCBQKWf+yxGl+281zd48ib1BJ8JoeU3zpUn+24ejXr9xq8VK
         jUtg==
X-Gm-Message-State: AFq9FYIrT6kz6DgpwCznzqLtwiLJTqhNxJpiMTgw2b6mauz0s5Cciv4c
	ydPOz+ShlJWdT4KZQdbQ10A9kciR0EnJBY7aGRxpWCzIH1uOMMMFaD5mXY4V8I3O3XyNRig6VlK
	VdkhZzv2ACiR7zvVdjas7uadAPftfP04=
X-Gm-Gg: AYBFou2dF9hz5rRJD1ozWmjlSebN6JSYxX/Yt+WV3p8kMcm3xlu06lC7UkdrNEoJs1A
	2IHTYAaQ0o5525pJVgLRqhHFEV1I9FJ7GZlc92MxIpT9pBQtI2verZuHN5CXLUQt56emzRi+pBh
	9mSs+IQGCNaQNVb/PAhh8dILGyOng7aQvfpeJY8t/zSAju9nu5wPjNbDWsKxfXn8SBUi2OfbuWf
	Vp0AOAVC4ZF+mOD04IFd295agCzHF/Oni9grw+p7BsJWkCX4x/llbFo9wnuS7uEphP2j3+TPBFa
	iQCg/fp0nQ9wVQVAXXa0QWttc9gT29g5WwpqGjRZxUFZC9l0WzgtD8S1ko2tMH9+/Ctijw+xVzD
	SAlK0p03W4OUi9zVNaiXV5VsqBajqwar3jVfNdapv5e+pDjUS7BYUu7qV4Zlx8CYFsL+raBEdus
	3QzNHAHmwaeVKMQ+lpc33WWbGvQIjP/iwZGOiVaueNuXMrkzyPmfc=
X-Received: by 2002:a05:6512:1247:b0:5bc:f2d3:f940 with SMTP id
 2adb3069b0e04-5bfb71f7292mr3160287e87.56.1793081673092; Mon, 26 Oct 2026
 23:14:33 -0700 (PDT)
X-Mailing-List: netdev@vger.kernel.org
X-List-Post: <mailto:netdev@vger.kernel.org>
X-List-Help: <mailto:netdev+help@vger.kernel.org>
X-List-Subscribe: <mailto:netdev+subscribe@vger.kernel.org>
X-List-Unsubscribe: <mailto:netdev+unsubscribe@vger.kernel.org>
X-List-Owner: <mailto:netdev+owner@vger.kernel.org>
X-Precedence: list
X-In-Reply-To: <20261026095208.58504-1-yzwlhm@gmail.com>
X-Gm-Features: AclHuK_cgrQyrWKFQVlhzabXNnx79zQhN2Alc0sBaVdOJyWNDAmLNbsinkEAfZw
X-Cc: netdev@vger.kernel.org, linux-kernel@vger.kernel.org, 
	Eric Dumazet <edumazet@kernel.org>, Neal Cardwell <ncardwell@google.com>, 
	Kuniyuki Iwashima <kuniyu@google.com>, "David S. Miller" <davem@davemloft.net>, 
	Jakub Kicinski <kuba@kernel.org>, Paolo Abeni <pabeni@redhat.com>, Simon Horman <horms@kernel.org>