From patchwork Mon Aug 26 06:55:26 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mike Rapoport X-Patchwork-Id: 13777230 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id 6E763C5321E for ; Mon, 26 Aug 2024 07:02:22 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id EECF66B0163; Mon, 26 Aug 2024 03:02:21 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id E9C438D0040; Mon, 26 Aug 2024 03:02:21 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id CC7628D0029; Mon, 26 Aug 2024 03:02:21 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0016.hostedemail.com [216.40.44.16]) by kanga.kvack.org (Postfix) with ESMTP id AC1A36B0163 for ; Mon, 26 Aug 2024 03:02:21 -0400 (EDT) Received: from smtpin08.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay10.hostedemail.com (Postfix) with ESMTP id 62880C0C86 for ; Mon, 26 Aug 2024 07:02:21 +0000 (UTC) X-FDA: 82493502882.08.F749079 Received: from nyc.source.kernel.org (nyc.source.kernel.org [147.75.193.91]) by imf08.hostedemail.com (Postfix) with ESMTP id B8934160026 for ; Mon, 26 Aug 2024 07:02:19 +0000 (UTC) Authentication-Results: imf08.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=fnaG1q6R; spf=pass (imf08.hostedemail.com: domain of rppt@kernel.org designates 147.75.193.91 as permitted sender) smtp.mailfrom=rppt@kernel.org; dmarc=pass (policy=quarantine) header.from=kernel.org ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1724655697; 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-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=4+/ziKRuaKuWojekn/jGc5BdErtoYihuf167rUpztYo=; b=AMUiCw333Q6OMq7ihP+IvBpP7cgO/hW4MFssQPAWF/SGEJ/EhxWnXxxI2lUiIxhq/H8EiG PPyiZYRKwoESvJ82qRq+Sdr2mPnpksHkcwbbVVljOXh6xhcjZLocl7uyV/oFL+nmfGBklU doaZ17rWD+Yjq4AabgKQWcMAJlbPEok= ARC-Authentication-Results: i=1; imf08.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=fnaG1q6R; spf=pass (imf08.hostedemail.com: domain of rppt@kernel.org designates 147.75.193.91 as permitted sender) smtp.mailfrom=rppt@kernel.org; dmarc=pass (policy=quarantine) header.from=kernel.org ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1724655697; a=rsa-sha256; cv=none; b=UTxDTp4RbjED1hjedrcqW8KZKmamazXu9GlpDHcEst5l9bBpA5ICyD8e2G8QbVZgCXICX2 OwBFEM113O/9y0tbT5V9O2s2RNw0oNUe9uokqGysEg1sZ85d4HTaRHaU2KNZt8MJyBsB5W GJWHH4k2kkcv6RqDxq0dzyL6CgiwqVU= Received: from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58]) by nyc.source.kernel.org (Postfix) with ESMTP id 85AD6A41349; Mon, 26 Aug 2024 07:02:11 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 4E492C51CA1; Mon, 26 Aug 2024 06:56:12 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1724655386; bh=diG+Fv3wDftGRjrnWBdO8lGUovRExvU5pHk1HsKnyW0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=fnaG1q6R4qlIaSK/fWkGnB06BhXbyowHMLkXN+Wa/EmI8MXCHyCRZspeqUfjxlFn8 I5lAr0mBOGk6Pt3c7iaZXbNbgEWcTB2h0HEGHe4mQWtVg4kIYBz60y4INpqUCOObQh snsW+ukoJgEDrqZbxOJXvgYwpT1mdmaXAK0KgEiHeSDv0S/jdqlA7izDk1dLlRr7T2 JvFAUL1avz8KDvpXtlCDFgtgmsVTawfWmOS9mj/Sm91+tuowTK8XuuK95GWPjy8VKl t+6xvbWV5dUVQztjsq3xx57LLL9mOi//qHDE6IYxAExuUD3vx++wbsh6uwKeNHOBbT TnTRQT6DCjzuA== From: Mike Rapoport To: Andrew Morton Cc: Andreas Larsson , Andy Lutomirski , Arnd Bergmann , Borislav Petkov , Brian Cain , Catalin Marinas , Christoph Hellwig , Christophe Leroy , Dave Hansen , Dinh Nguyen , Geert Uytterhoeven , Guo Ren , Helge Deller , Huacai Chen , Ingo Molnar , Johannes Berg , John Paul Adrian Glaubitz , Kent Overstreet , "Liam R. Howlett" , Luis Chamberlain , Mark Rutland , Masami Hiramatsu , Matt Turner , Max Filippov , Michael Ellerman , Michal Simek , Mike Rapoport , Oleg Nesterov , Palmer Dabbelt , Peter Zijlstra , Richard Weinberger , Russell King , Song Liu , Stafford Horne , Steven Rostedt , Thomas Bogendoerfer , Thomas Gleixner , Uladzislau Rezki , Vineet Gupta , Will Deacon , bpf@vger.kernel.org, linux-alpha@vger.kernel.org, linux-arch@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-csky@vger.kernel.org, linux-hexagon@vger.kernel.org, linux-kernel@vger.kernel.org, linux-m68k@lists.linux-m68k.org, linux-mips@vger.kernel.org, linux-mm@kvack.org, linux-modules@vger.kernel.org, linux-openrisc@vger.kernel.org, linux-parisc@vger.kernel.org, linux-riscv@lists.infradead.org, linux-sh@vger.kernel.org, linux-snps-arc@lists.infradead.org, linux-trace-kernel@vger.kernel.org, linux-um@lists.infradead.org, linuxppc-dev@lists.ozlabs.org, loongarch@lists.linux.dev, sparclinux@vger.kernel.org, x86@kernel.org Subject: [PATCH v2 2/8] mm: vmalloc: don't account for number of nodes for HUGE_VMAP allocations Date: Mon, 26 Aug 2024 09:55:26 +0300 Message-ID: <20240826065532.2618273-3-rppt@kernel.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240826065532.2618273-1-rppt@kernel.org> References: <20240826065532.2618273-1-rppt@kernel.org> MIME-Version: 1.0 X-Rspamd-Server: rspam03 X-Rspam-User: X-Rspamd-Queue-Id: B8934160026 X-Stat-Signature: b3xt6rgkq1n1ex474ugi8a614uy99top X-HE-Tag: 1724655739-890490 X-HE-Meta: U2FsdGVkX19phLZschp4gU1FJktXOZxOsj8p787ONfyXCbzRYG68ydt2EWK0qJHksPU9wtDmW7ujRuLupO8AdIyXL/gY1SetAfSYdN5nTVT76rE9qeZtTHrufDn8TtTnGTxD0bh18qDDU7UXWVChKSp0ChkNg53fcRJVf+i+dW1xbCDktiKxrA30pu9cUM0XqDCis4quArScDDUnh6mt2qVcRY3xBIZZ1ybCInjeb7WqIFOlhUA/Y7XQSU5KA0A8ngryztSmK4O6i/bwWHnXomZaKy9DFfihxev1Ya4oT0egbA1huIHwnj7Kl8En/1o58EjQXcGBHcRcn+YKuf16lEuRVQxYTExSLhLqRDsZWuGhWbxyrvz8IJzDcsnSyCmpYgGuLO3/mO1bRdd2NINFr+InQeLZx2Lsjawk3DbtveXDlmcZWhSaXH5GQH194HxTcVOmLW/0zBmy3kFJF2pkLnkm6U/CJ+jf3dToMa5xjNbmBN17aEOlYZV/BQPVl5znc5KQ8ymlzFsi7AA25TRr2F5GDvp0zK0sPnmAlECKLf3Wx7vBt6HsGs1q3ocoXH6Zd53/qChcnGmpvnElcPjuKb1ULoky22ZkWGWZ3YhufCk2p/SFf+FkZfTpRSRKjsf4/ScqfjZCkSg7wBCEP2K8l/NuI1q0bTfiLJHvHPhyow05AOVHhzMqvsWVTBjO9cj7mFx8ero1dVPJhu5pzuxp4aBQhJByjBxJ2xzKMVQfdPs65HvSVmZvYof2dNFlzjqV/puqaR2jmA/mUXXeKrIcZqMz0om0uTIfRUCSXiK+wcGvkfWBVNf9hT495vpBQzH78hcTA8Rix0vF9DsowczVQ08WbOe3fT1rRVYbqF9MFQHAyGoAacZevULxC+N6MIhUBDudgc0RFepNNKem11HQIn3bUT2F+0YOgqrbf0Z+k5g01WB4ncMzPW/dIswjHaAd1W4DARvaBQOvA331sBu gCywqIJI Iye3AfHMpkjwIw7/n4jxD4ILV0Nk9N/6mfzgrvLPMPPV5ky/oN616j3Q6huJuBLcsBRonah0v8Aw4UNWStpHEqgIrVJl7fzGs3nIxgtoWiYN47c77YcMxyThQY9P1Hs4WG5RtyMinoWpLlyQ/HKmISg7FH1sW43p1qMIJ1Ok6lMQlUWcsE6eC4WvZYAIgFrEMsBEDJGmni83c9zdKqEG2Lkx2GzXT+qvRFz6wJMn7Kl4ISwHY2Mw/7U0ObcEjOiZGDWSdjEndx6OaBqZofhWANTi/0tLAJvCzu/w4 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: List-Subscribe: List-Unsubscribe: From: "Mike Rapoport (Microsoft)" vmalloc allocations with VM_ALLOW_HUGE_VMAP that do not explicitly specify node ID will use huge pages only if size_per_node is larger than a huge page. Still the actual allocated memory is not distributed between nodes and there is no advantage in such approach. On the contrary, BPF allocates SZ_2M * num_possible_nodes() for each new bpf_prog_pack, while it could do with a single huge page per pack. Don't account for number of nodes for VM_ALLOW_HUGE_VMAP with NUMA_NO_NODE and use huge pages whenever the requested allocation size is larger than a huge page. Signed-off-by: Mike Rapoport (Microsoft) --- mm/vmalloc.c | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) diff --git a/mm/vmalloc.c b/mm/vmalloc.c index af2de36549d6..d0fbe6b2b73c 100644 --- a/mm/vmalloc.c +++ b/mm/vmalloc.c @@ -3769,8 +3769,6 @@ void *__vmalloc_node_range_noprof(unsigned long size, unsigned long align, } if (vmap_allow_huge && (vm_flags & VM_ALLOW_HUGE_VMAP)) { - unsigned long size_per_node; - /* * Try huge pages. Only try for PAGE_KERNEL allocations, * others like modules don't yet expect huge pages in @@ -3778,13 +3776,10 @@ void *__vmalloc_node_range_noprof(unsigned long size, unsigned long align, * supporting them. */ - size_per_node = size; - if (node == NUMA_NO_NODE) - size_per_node /= num_online_nodes(); - if (arch_vmap_pmd_supported(prot) && size_per_node >= PMD_SIZE) + if (arch_vmap_pmd_supported(prot) && size >= PMD_SIZE) shift = PMD_SHIFT; else - shift = arch_vmap_pte_supported_shift(size_per_node); + shift = arch_vmap_pte_supported_shift(size); align = max(real_align, 1UL << shift); size = ALIGN(real_size, 1UL << shift);