Article View: linux.kernel.netdev
Article #24689Re: [PATCH] mm/mm_init: don't shrink large system hash tables below low_limit
From: Christian Brauner
Date: Mon, 30 Nov 2026 16:14
Date: Mon, 30 Nov 2026 16:14
63 lines
10706 bytes
10706 bytes
On Thu, Nov 26, 2026 at 03:02:02PM +0200, Mike Rapoport wrote:
> (added Christian)
>
> On Mon, Nov 23, 2026 at 08:15:49PM +0000, Amir Hosseini via B4 Relay wrote:
> > From: Amir Hosseini <me@amir.fyi>
> >
> > When an allocation fails, alloc_large_system_hash() halves the table and
> > retries until it is down to a single page. It does not stop at
> > low_limit, although commit 31fe62b95866 ("mm: add a low limit to
> > alloc_large_system_hash") added low_limit precisely so that callers need
> > not check the size they get back.
> >
> > The TCP source port perturbation table depends on that. It passes
> > low_limit == high_limit == INET_TABLE_PERTURB_SIZE and neither
> > _hash_shift nor _hash_mask, so it cannot learn the real size, and
> > __inet_hash_connect() fills and indexes INET_TABLE_PERTURB_SIZE entries.
> > On a single node system hashdist is off and the table needs one order-6
> > GFP_ATOMIC allocation. If that fails, e.g. because most memory was
> > reserved for HugeTLB at boot, the situation commit e67b72b90b7e ("tcp:
> > use alloc_large_system_hash() to allocate table_perturb") was meant to
> > handle, the table is silently halved and the first connect() writes up
> > to 240 KiB of random bytes past its end, typically into the TCP
> > established hash table:
>
> This is hard to read :/
>
> > Table-perturb hash table entries: 32768 (order: 5, 131072 bytes, linear)
> > ...
> > Oops: general protection fault, probably for non-canonical address 0xe480dbf6b420b3d9: 0000 [#1] SMP KASAN
> > RIP: 0010:__inet_lookup_established+0x168/0x5d0
> > Call Trace:
> > <IRQ>
> > tcp_v4_rcv
> > ip_protocol_deliver_rcu
> > ip_local_deliver
> >
> > Stop halving at low_limit. If the linear allocation still fails, retry
> > the same size with vmalloc_huge(), which this function already uses for
> > tables that are too large for the page allocator or when hashdist is
> > set, and which does not need physically contiguous memory. If that
> > fails too, panic as before.
>
> So, AFAIU the gist is here is that page allocator fails, let's fallback to
> vmalloc_huge().
>
> The large hashes are normally allocated at boot time when memory is not yet
> fragmented, so it's very unlikely that page allocator would fail.
>
> But there is another question: do we really need physically contiguous
> memory for the hashes we get from alloc_large_system_hash()?
>
> AFAIU, we can just drop the alloc_pages_exact() case and keep memblock for
> HASH_EARLY and vmalloc_huge() for the rest.
>
> Eric, Christian, what do you think?
I think the dentry and inode cache are unchanged by what you suggest.
Tables under 2 mb would get mapped with 4 k pages instead of direct-map
huge pages. That would affect mnt_init() and move it to vmalloc_huge().
Would probably mean a few tlb misses in lookup_mnt()? That needs to be
really really fast on mount crossings. So if this doesn't degrade lookup
performance I don't care that much.
Technical Details
Message-ID:
<20261130-parklandschaft-barhocker-riefen-42cadc405795@brauner>Path:
mbox-mo1.pugleaf.net!srv.newsdeef.eu!news.mb-net.net!open-news-network.org!news.nntp4.net!nntp.xenet.de!news.neodome.net!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-374310-linux-kernel-netdev=dewy.ruReferences:
<20261123-mm-hash-low-limit-v1-1-8a803aa8ac70@amir.fyi> <awgtymEawotNXV8f@kernel.org>Show Full Headers
Complete Article Headers
Path: mbox-mo1.pugleaf.net!srv.newsdeef.eu!news.mb-net.net!open-news-network.org!news.nntp4.net!nntp.xenet.de!news.neodome.net!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-374310-linux-kernel-netdev=dewy.ru From: brauner@kernel.org (Christian Brauner) Newsgroups: linux.kernel.netdev Subject: Re: [PATCH] mm/mm_init: don't shrink large system hash tables below low_limit Date: Mon, 30 Nov 2026 17:14:14 +0100 Organization: Usenet Network Message-ID: <20261130-parklandschaft-barhocker-riefen-42cadc405795@brauner> References: <20261123-mm-hash-low-limit-v1-1-8a803aa8ac70@amir.fyi> <awgtymEawotNXV8f@kernel.org> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Injection-Info: usenet.network; logging-data="1465432"; mail-complaints-to="abuse@usenet.network" Cancel-Lock: sha1:JjzdS5uCSeVkHHEopQDoV58NR5A= sha256:yNsKsDDIKvKqKmL4f6mlVGO86I4gj7eBl0ea8vVzQGo= sha1:GcWrUpI9iVGIRwcp2BkgMT+cioI= sha256:S52mxmDitr1jiBFhFvbi+QxtS3yA0poWnpVedPCn664= 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 2503D125FF2; Mon, 30 Nov 2026 19:14:38 +0300 (MSK) X-Virus-Scanned: Debian amavisd-new at usenet.network X-Spam-Flag: NO X-Spam-Score: -3.501 X-Spam-Status: No, score=-3.501 tagged_above=-9999 required=6.31 tests=[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 6ZxQACK84OwT; Mon, 30 Nov 2026 19:14:35 +0300 (MSK) X-Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=172.105.105.114; helo=tor.lore.kernel.org; envelope-from=netdev+bounces-374310-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 11EA3125FF4; Mon, 30 Nov 2026 19:14:26 +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 58A6028E3D; Mon, 30 Nov 2026 16:14:23 +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=1796055260; b=Vqt/v3PB9xaufvnPisGffhZKaCwRlFUHKebAamzg4qDuCT3atf/TCRqw5mf2W5muELZM 1c8XItGjzRH9wZojWen1M9TydqvoGLZ7gleomNJtKupFKTixiHipKyNxm/QBkDO6ft+1b zb7bgXykrhzsaoF1PpWg3J+Rd/Y9H/ry20U92bW2hrwcSWw3mPr2cN+C2Fcl1301YLNG7 RIGTCTmxZFSvMmhFWRm5KnF6edfKbwgtBBrwlJztpL7Lx1kBbkQbtoFScUHsZxVWMlFID Yna8Dk7G5DT50EVRCjFKcIw6QePPJRxvWEdLc8jdZiLxMPH2f9m1peOytzPh4agcOpQ== X-ARC-Message-Signature: i=2; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796055260; 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=n3yPeXd+yzKvrZQwxUiV+J1BaKn0evyxllHIREv/7P0=; b=udOia+yTDNNDEgENqPSKLKXSRYeAEE0zpxOvgaPbjkIvbKQr9yGweb0OWagtJitrDiNf JV+xoyNWYPDZkPAaUrJcW+ukbWrf8EyEwDM/Ek4gUsqqsJxLBUzTK8ZJl47irlZz82CWo oTTuZBxFiyp9n+sXea+FvM4X5zMN++yTgbgTSn1CYETvdCZKbtLm1yu0yav+aLNYXRqRF TWntzi59mEV/USHu1eLh6NefdAbMhY3o33MsFC1g3mChHBGf6AKigt7O9osQQHxnglZ5Y I6SQP+R2e5W2g45QiMU4cx2dY3YaEHQvtpBmKXf6PW7d/lMquDuwFr6W+dM5reZGxqg== 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="Z/6sA+EQ"; 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 615E6606A33D; Mon, 30 Nov 2026 16:14:20 +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=Z/6sA+EQ 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=1796055259; b=HXxCqUvHpXhoSdAcvJZNFhDf69fgG933pivIg+1yWtWdyMy4+w2R6TM0hEUMr7T/0Vyq 1HSXTPEkPShfwJSlOJLfdYxp4b9bMdQ2YCjC0o51NvhwQ6Zb9Fj7JnaR2+gEGy6o3kq7h ZTZWA67bPC1NyfppXbsEwJo2dmCoDJuLUdhQSmQ6RFQnQ/64Ez+SztdgofgGT5hI7zf/N jfCzvphbK9jckBm5zEqgwGdVGSRvvlEeLlONC2bQTv8d662P/UU1g5iiD9plmOhROBtne +JMIeqYE/LURGmIcYAdMMUlqVSUMiiu0l1q5EMXYGrSJxlDYj/6LRwroYBudRd7DJKQ== X-ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796055259; h=Received:DKIM-Signature:Date:From:To:Cc:Subject:Message-ID: References:MIME-Version:Content-Type:Content-Disposition:In-Reply-To; bh=n3yPeXd+yzKvrZQwxUiV+J1BaKn0evyxllHIREv/7P0=; b=A0NCYHgdD0xu0UOhLnCYso7P+oNDD8ePywWZf09FiWR3KtAXIRLix4t/GvaQmrILUTAv oA8ZU19fAReUsI83SLTX/O8KOmSXswFwFZSoFPbWkogdTDpwGbD7zieP0lCSozbwCuZh7 udxUACT1t5cAqEQwSiPnhM4zDkF6U62mdBcTtdldDJGRNn5GGHDx8i39LGptx1+xtqJTr Gc615QBADO2ObOV9iYuCzwuZJnebklZhWs0GLXBUnJJ61Re1gM8fgX+jlaBdK2WPG6I6k MROwYl/9kT/09JAKw5sZC+ceGcZBl2po1emwQDSLrTZBKOFx6p7QRtTeSwjusr+tzVQ== 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="Z/6sA+EQ"; 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 7E1A2606A32E for <netdev@vger.kernel.org>; Mon, 30 Nov 2026 16:14:19 +0000 (UTC) X-Received: by smtp.kernel.org (Postfix) with ESMTPSA id C42C41F00926; Mon, 30 Nov 2026 16:14:16 +0000 (UTC) X-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1796055258; bh=n3yPeXd+yzKvrZQwxUiV+J1BaKn0evyxllHIREv/7P0=; h=Date:From:To:Cc:Subject:References:In-Reply-To; b=Z/6sA+EQ76u3aVIgAg8efdEsZIkwZ9jB8Cq63QcGNlgceIc/xZhGveWvD5Ogk79AG X/g9TNjL8V1f3IEyWzRVidKVRhIfmCfGgEPND0KusQ9zTWRBNbVTqh5MHcoTnylrIm P+UxbvzJeI9yNfqPxtRaGS/eOoVn7KoyPrh1/aqcZFi5KIAbJjscZdV4bWnfeYvvbs vG3EFOxHFXk/Xo2B86K+3GoCMV7+NNwsgsTMFw/zO6j/aEFAj9p/MXINSYcxuGNZ26 YxwBluVkF7zbYcBk7kSS0FjlMuO9Rlr+kgM2PYhB6pz6ir3G5GJ8uGxGhVAK1K6gH5 ilsJ+BTuiGMzg== X-Cc: me@amir.fyi, Andrew Morton <akpm@linux-foundation.org>, Eric Dumazet <edumazet@kernel.org>, "David S. Miller" <davem@davemloft.net>, linux-mm@kvack.org, Muchun Song <muchun.song@linux.dev>, netdev@vger.kernel.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: <awgtymEawotNXV8f@kernel.org>