Article View: linux.kernel.netdev
Article #25723Re: [PATCH net] tcp: avoid table_perturb overflow on single node hosts
From: Mike Rapoport
Date: Wed, 02 Dec 2026 09:51
Date: Wed, 02 Dec 2026 09:51
74 lines
10619 bytes
10619 bytes
Hi Amir,
On Tue, Dec 01, 2026 at 07:31:32PM +0000, Amir Hosseini wrote:
>
> From: Amir Hosseini <me@amir.fyi>
>
> Since commit e67b72b90b7e ("tcp: use alloc_large_system_hash() to
> allocate table_perturb"), table_perturb is allocated with
> alloc_large_system_hash(). On NUMA hosts it uses vmalloc(), but on
> single node hosts it needs one contiguous 256KB block.
It's vmalloc_huge() and it's used when hashdist is set, i.e. on 64-bit
with more than one node with memory.
> When there is no such block, for example after many HugeTLB pages were
> reserved at boot, the table is made smaller without telling the caller.
It's worth mentioning that alloc_large_system_hash() ignores low_limit
when it retries with smaller sizes.
...
> - table_perturb = alloc_large_system_hash("Table-perturb",
> - sizeof(*table_perturb),
> - INET_TABLE_PERTURB_SIZE,
> - 0, 0, NULL, NULL,
> - INET_TABLE_PERTURB_SIZE,
> - INET_TABLE_PERTURB_SIZE);
> + if (num_online_nodes() > 1) {
> + /* Use vmalloc() to allow NUMA policy to spread pages
> + * on all available nodes if desired.
> + */
> + table_perturb = vmalloc_array(INET_TABLE_PERTURB_SIZE,
> + sizeof(*table_perturb));
> + }
I don't think the special case for NUMA makes sense.
Since commit a061578043993 ("mm/vmalloc: request large order pages from
buddy allocator") vmalloc takes large order blocks from the buddy
allocator, so vmalloc_array() gets the whole table as one block from one
node when it's available.
With the existing code, if there's a free order-6 block, it comes from
alloc_pages() with hashdist=0 and with hashdist=1 it's a single block
from vmalloc mapped with 4k pages.
If there's no such block, with hashdist=0 alloc_large_system_hash()
continues the loop and returns the largest block alloc_pages() can get,
and with hashdist=1 vmalloc is likely to succeed with several blocks
spread across the nodes and mapped with 4k pages.
With kvmalloc_array() a free order-6 block comes from kmalloc() ->
alloc_pages() and if there is no such block, several smaller blocks
come from vmalloc(), spread across the nodes and mapped with 4k pages.
So kvmalloc_array() never shrinks the table, prefers the linear map
when there's a contiguous block and spreads the table across the nodes
exactly in the case where hashdist=1 actually spreads it now.
Please drop the NUMA branch and just use kvmalloc_array().
> + if (!table_perturb)
> + table_perturb = kvmalloc_array(INET_TABLE_PERTURB_SIZE,
> + sizeof(*table_perturb),
> + GFP_KERNEL);
> + if (!table_perturb)
> + panic("TCP: failed to alloc table_perturb");
> }
--
Sincerely yours,
Mike.
Technical Details
Message-ID:
<aw_qJSpnJCmOAUgz@kernel.org>Path:
mbox-mo1.pugleaf.net!srv.newsdeef.eu.MISMATCH!feed-us-txt.newsdeef.eu!feed-us-ny.newsdeef.eu!srv.newsdeef.eu!newsfeed.bofh.team!news.nntp4.net!nntp.xenet.de!news.neodome.net!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-375706-linux-kernel-netdev=dewy.ruReferences:
<20261201-tcp-perturb-kvmalloc-v1-1-deee7c745fa3@amir.fyi>Show Full Headers
Complete Article Headers
Path: mbox-mo1.pugleaf.net!srv.newsdeef.eu.MISMATCH!feed-us-txt.newsdeef.eu!feed-us-ny.newsdeef.eu!srv.newsdeef.eu!newsfeed.bofh.team!news.nntp4.net!nntp.xenet.de!news.neodome.net!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-375706-linux-kernel-netdev=dewy.ru From: rppt@kernel.org (Mike Rapoport) Newsgroups: linux.kernel.netdev Subject: Re: [PATCH net] tcp: avoid table_perturb overflow on single node hosts Date: Wed, 2 Dec 2026 11:51:33 +0200 Organization: Usenet Network Message-ID: <aw_qJSpnJCmOAUgz@kernel.org> References: <20261201-tcp-perturb-kvmalloc-v1-1-deee7c745fa3@amir.fyi> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Injection-Info: usenet.network; logging-data="1940498"; mail-complaints-to="abuse@usenet.network" Cancel-Lock: sha1:CBa5GJBclzokIFHXzsOWXQOKqQk= sha256:j03W031fmzBOS4O6k40EwSq78LVkI6ymSbRHOJsuwSc= sha1:Fz6075LDtfLq2ZXJA4vfOH2cISo= sha256:059b2InUJnSnbcWw0BnN8ruanWrFX3CNI78luMz7PWw= Content-Disposition: inline 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 1CB271175EF; Wed, 2 Dec 2026 12:52:05 +0300 (MSK) X-Virus-Scanned: Debian amavisd-new at usenet.network X-Spam-Flag: NO X-Spam-Score: -3.401 X-Spam-Status: No, score=-3.401 tagged_above=-9999 required=6.31 tests=[DCC_REPUT_70_89=0.1, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, 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=kernel.org 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 JZOTYZMDg8gV; Wed, 2 Dec 2026 12:52:02 +0300 (MSK) X-Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=172.105.105.114; helo=tor.lore.kernel.org; envelope-from=netdev+bounces-375706-linux-kernel-netdev=dewy.ru@vger.kernel.org; receiver=<UNKNOWN> X-Authentication-Results: OpenDMARC; dmarc=pass (p=quarantine dis=none) header.from=kernel.org X-Received: from tor.lore.kernel.org (tor.lore.kernel.org [172.105.105.114]) by mail.dewy.ru (Postfix) with ESMTPS id AD4011175E9; Wed, 2 Dec 2026 12:51:53 +0300 (MSK) X-Received: from smtp.subspace.kernel.org (conduit.subspace.kernel.org [100.77.114.92]) by tor.lore.kernel.org (Postfix) with ESMTP id 88C1D2B24E; Wed, 2 Dec 2026 09:51:51 +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=2; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=pass; t=1796205111; b=1BdSu6vjLqRikIckMvs13rni+9BfQ0/WDbxvR4SLhMFTJzR4J7REDFfA3lNcG5F2nwtF okQ01Bicc0vXR6fDSw+1pp/+wFXcPzJwWmOtNjVevIvBPKUq6qgLdIVokI4EgL9+Yck7F 6Yp8KFhnQbs6QZ2XeHxsRRb9Q68H/66l3AeImIoZAAVld/k4QN36PHtHHdl0jSaA3rqWk o1l8EE5OoZ43nUiQQg/nMfcmJyDu9xs8JBANXHCF4M2tuPgv1hIb33NEVUGw5b+3+IiFA AWaRtKWeNmjZrpPyJS7G1Na/p2jBzqKDo2WV3dCELmkBR54vjLoGM9ZYayNuZlk3Iyg== X-ARC-Message-Signature: i=2; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796205111; h=X-Original-To:Received:Received:DKIM-Signature:Date:From:To:Cc: Subject:Message-ID:References:X-Mailing-List:List-Id:List-Post: List-Help:List-Subscribe:List-Unsubscribe:List-Owner:Precedence: MIME-Version:Content-Type:Content-Disposition:In-Reply-To; bh=b2WXVW9kyVSQ7mCJNqfR3+X3W2khE/Qicg+A7KdCWgc=; b=MeJDEhzrMz32GZi+8hL3QkGv++kxkfKgvihyH0NzZzwmXDu5LgE7oFjg/l5YVmo+RSL1 4DepxI6vmrP5imbw45Cf5jvqzCh+AVSU0NEJhSNm9uG1PyqLV1amUe/IX0DgIad+BbIoW GRtAudD0Lwt66yX92msTv62B2bwqr9DrZKdtqhFMXNvMwx000R1aK/vxkdLmVgESa5kie gT3UmZP3xyIuA7JGELj9DilW1D1Y5Mrn0cGv6fMImnz5gyxJLW42rB0ln4l4OWVuejwB7 pyoBSKKbfJ/cLJYdzyf34eNsKxDFp1PzAD41SncyELbGMr09pb0xYHHN/qvFejGJ4hg== X-ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dkim=pass header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=HiveoKxg; 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 05278606A683; Wed, 2 Dec 2026 09:51:51 +0000 (UTC) X-Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=HiveoKxg X-Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=100.103.45.18 X-ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796205110; b=5OuWGuXtDxqIsuCizyGMINNgzopcNbx3Y1G+qIYIQZH7yTP9DZgF62uo6CPjoKQ74NVR jFPQCCb5TOwdm0cnwARcSLe+D1bSDraP6qVbume8gP5BUuLZG7a1GMCTtyMWHubCqglfV 0ltYdmPDKVb3NcuqhVGeg4Udf0rxVFESh+OCn6AUdz988BGI3azSGX2QcbMZ62CXpQ8y5 NLr+OgeW9rHbHMKNAGktiHa04U1qmWsdSQUddsnAP1AsJBjSGJIF8EVib8+39RglPz0RE 6Seu9RkBeFCbVafooUrzzplTQ2+QyToZhM6sXxcVdPa6YpK7jpFCLYwGX8Z1ODhXRYw== X-ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796205110; h=Received:DKIM-Signature:Date:From:To:Cc:Subject:Message-ID: References:MIME-Version:Content-Type:Content-Disposition:In-Reply-To; bh=b2WXVW9kyVSQ7mCJNqfR3+X3W2khE/Qicg+A7KdCWgc=; b=lFLTjltCyHsQ86WjMvZFz6ph+4wSLq7CmpjZ5gZLYQDDdcN8sxh9hlQlQUuHsT9Sqe03 jSQl5doAqkg9e8qofClyCGyIeXlEhJXfAW5cqMDuYikTJVb26RxXRz5tQtYv+bnKOj5iv 9a/19oX/JaHs23sXg53qfLSUefh0IWJSgSmTKIpTCRVoqE9k8D3PgZoKJ34dK46YAbpN7 tEI5+gN8doBSLDZAlGw1KwPWyqIOxsE/FuhP/VdhTdqMPb0qKHoFSp+tnW8sAxNEnHZEG T/MPTioe+Jdx6mBNUrM9Z7GutqSX0K64kiDw7NcX4fivK6ZRF+g3FHQLH8jtunoHhTQ== X-ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=HiveoKxg; arc=none smtp.remote-ip=100.103.45.18 X-Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 25EF5606A33B for <netdev@vger.kernel.org>; Wed, 2 Dec 2026 09:51:49 +0000 (UTC) X-Received: by smtp.kernel.org (Postfix) with ESMTPSA id 38DD61F00931; Wed, 2 Dec 2026 09:51:38 +0000 (UTC) X-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1796205109; bh=b2WXVW9kyVSQ7mCJNqfR3+X3W2khE/Qicg+A7KdCWgc=; h=Date:From:To:Cc:Subject:References:In-Reply-To; b=HiveoKxgz4woC5gumjwR0uPNYWoK+caPJYQOdxPfLCVYH0zQ/Lp4YVHwYRc4AECeu aVo1gLBf5MqFBLZfSQ3BhHc25h/2/IcCbPiy3E3BBi710n51Xm1iJ5jsHK0s+H5fkU kpcNQcPx5MuOyMoxdkuzRisPbyMNdfabfB9yLbx8HFjRhthjioO0pMuY2zqVwFWT0K 0Rda50CWJcVgH5bZdxvH9HxaM3SZOd8oRv5QN++daMEcCl6HJ9DuJV0OELrVLVfh6K T3kQAoGmhYivAvnHsW1PQw0bT0U8/NBDtaMK613z2RfT5xAGXbxxHHo/5EUsSTeHoE bpcfpF4n1aveg== X-Cc: 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>, Willem de Bruijn <willemb@google.com>, Simon Horman <horms@kernel.org>, Muchun Song <muchun.song@linux.dev>, netdev@vger.kernel.org, linux-mm@kvack.org 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: <20261201-tcp-perturb-kvmalloc-v1-1-deee7c745fa3@amir.fyi>