From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.subspace.kernel.org (Postfix) with ESMTP id CD470606A337 for ; Wed, 2 Dec 2026 09:51:54 +0000 (UTC) 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 Received: by kanga.kvack.org (Postfix) id 833196B05BA; Wed, 2 Dec 2026 04:51:53 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 80A376B05E2; Wed, 2 Dec 2026 04:51:53 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 747326B05F2; Wed, 2 Dec 2026 04:51:53 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0010.hostedemail.com [216.40.44.10]) by kanga.kvack.org (Postfix) with ESMTP id 55F8A6B05BA for ; Wed, 2 Dec 2026 04:51:53 -0500 (EST) Received: from smtpin16.hostedemail.com (lb01a-stub [10.200.18.249]) by unirelay10.hostedemail.com (Postfix) with ESMTP id 4632AC025B for ; Wed, 2 Dec 2026 09:51:52 +0000 (UTC) X-FDA: 85498576464.16.A266588 Received: from tor.source.kernel.org (tor.source.kernel.org [172.105.4.254]) by imf28.hostedemail.com (Postfix) with ESMTP id 9C9ABC000C for ; Wed, 2 Dec 2026 09:51:50 +0000 (UTC) Authentication-Results: imf28.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20260515 header.b=HiveoKxg; dmarc=pass (policy=quarantine) header.from=kernel.org; spf=pass (imf28.hostedemail.com: domain of rppt@kernel.org designates 172.105.4.254 as permitted sender) smtp.mailfrom=rppt@kernel.org ARC-Seal: i=1; a=rsa-sha256; d=hostedemail.com; s=arc-20220608; cv=none; t=1796205110; b=kSOcC8a8baIWKx5w1YDVb52+YPo/ghlI+HzdTTMzAMHR/Gr+dWfKkdzzzZqIgQ30M2iW9K OEMJntcvRzLwivDvmbGPtkhXqX6mNmVmD3v2ahHrSy6p4DKvM12sY7HWvNeQKgWh0DnewC vSfttezXrUGN/LZ5+tDSgfG7NvQB1R8= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1796205110; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=b2WXVW9kyVSQ7mCJNqfR3+X3W2khE/Qicg+A7KdCWgc=; b=E56ZQRvh85cwlCVSnibcbAyHhIBCxEN7nBeuSex80f8eLiC3NvA9uwe4uj/1fzbGvrrMkx fKCXpd8l67TFM03ocb4rPITLR9FvjznFRx0vFmAGydkxFyUucNnUIrqEAykzlmywxnu8go C/RbTqIm9cc7TZyHpHY8r1p+8BPFQII= ARC-Authentication-Results: i=1; imf28.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20260515 header.b=HiveoKxg; dmarc=pass (policy=quarantine) header.from=kernel.org; spf=pass (imf28.hostedemail.com: domain of rppt@kernel.org designates 172.105.4.254 as permitted sender) smtp.mailfrom=rppt@kernel.org Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18]) by tor.source.kernel.org (Postfix) with ESMTP id 1A42D6132F; Wed, 2 Dec 2026 09:51:50 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 38DD61F00931; Wed, 2 Dec 2026 09:51:38 +0000 (UTC) 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== Date: Wed, 2 Dec 2026 11:51:33 +0200 From: Mike Rapoport To: me@amir.fyi Cc: Eric Dumazet , Neal Cardwell , Kuniyuki Iwashima , "David S. Miller" , Jakub Kicinski , Paolo Abeni , Willem de Bruijn , Simon Horman , Muchun Song , netdev@vger.kernel.org, linux-mm@kvack.org Subject: Re: [PATCH net] tcp: avoid table_perturb overflow on single node hosts Message-ID: References: <20261201-tcp-perturb-kvmalloc-v1-1-deee7c745fa3@amir.fyi> X-Archived-By: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20261201-tcp-perturb-kvmalloc-v1-1-deee7c745fa3@amir.fyi> X-Stat-Signature: rzmh6676wfp8eh8p7sygsipxz1k8166e X-Rspam-User: X-Rspamd-Server: rspam01 X-Rspamd-Queue-Id: 9C9ABC000C X-Spam-Status: No, score=-5.8 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,SPF_HELO_PASS,SPF_PASS autolearn=no autolearn_force=no version=4.0.1 X-HE-Tag: 1796205110-155482 X-HE-Meta: U2FsdGVkX19PEXZo+H/1YC6HEb/qywiI1OpxOpx0BFsiQhLxkzB/xbQJI6Oe4UHnma85+DG0kuDZNVoOGtmPmLIQ0va56GGV4mKW9XIL2qTXTxJJe5SYZhfT+VFc1VJ1YC/bV5jILPqjR2MQ708ka7bUDbX/UXRQMO+u1cUOPKELuy3qZ5nZnOf6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po29N95O2UACi9DGawjVIdqjq37QgQmuoWJ1zizNsQMgMEgIxrgIfqLxznTAWVTmKDWZw2SDjaE5Wm4dy9K1JhP0r3nipt0O3k7LFp3yh3UhWaFB0mQMSxl78+/uhZAem9YYulkQSqxRCz9T9BjlWOsz9z15wHiQAPAROdlSviJSffKhk/Scz/hSofVVWd2mgPHlPrpV441pgl+fkbhCfvkZrkRziluQtBfj/HI4A0Mxc9YYGVytts9AeCesXFQ== Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: List-Subscribe: X-Spam-Checker-Version: SpamAssassin 4.0.1 (2024-03-26) on aws-us-west-2-korg-listserv-alma10-1 Hi Amir, On Tue, Dec 01, 2026 at 07:31:32PM +0000, Amir Hosseini wrote: > > From: Amir Hosseini > > 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.