Received: by 2002:a05:6358:11c7:b0:104:8066:f915 with SMTP id i7csp1869474rwl; Sun, 26 Mar 2023 10:39:02 -0700 (PDT) X-Google-Smtp-Source: AKy350YCKFnBP7kXE8turVkvPAULs7boY09ZxrMXCGJvww8IfDmrta/ONbSvBh21cMHGeRkRHnTV X-Received: by 2002:a17:907:a485:b0:8b2:abcd:624 with SMTP id vp5-20020a170907a48500b008b2abcd0624mr11657226ejc.0.1679852342310; Sun, 26 Mar 2023 10:39:02 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1679852342; cv=none; d=google.com; s=arc-20160816; b=YtHIPTcxJUxKuV4+yndupYbwuNwsEg1lodVjv+XeynNIYRdq7rH9XYZm6k00IEdIrM sdPACE8NQFxP/cRjEqv2p4rdp9mugPWC6vG8EG7u+0wJpuplK43gsdSeO4Tb0z7S362h ptpPPG2187Xq48dNpFjaJEppIhRNPD/wW4d3Un3YsLQMicR7Gr3STVh6xFGg7klUkp5D V7Pbx6YGoJF24RKrdjwR8AoBIeEiLfhm2Dum2Gta4FwS1F/FMM8coFAtCWitf3Xi2CUo rqdnt+gGDSROvqojzKl+Iz35hSHj27GAlGIylfLs7V0ZnblFAMeFfk4LyEooiAw39lD3 pW4w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:subject:message-id:date:from:in-reply-to :references:mime-version:dkim-signature; bh=NojTvT3AXHtvvs9ppwBWCeC4I9iRNB3PHK8sTr2cGn8=; b=bimBP1uSIoVvuFBi7eijKGSuSmVAFp1mzc0rd20PvYgLpmpk3OYOtDEj4SkHUFMmSC Jti7EQz6MH2grfUWR0te4IDkvkMA3HrNx3HeR0V1gcO6PDXkpYVJAJQx300jjdzaTXOv sh0O7KSSZ0auzIVlYcfDKKGl1GJAU2uouCGl7EH3vHk/YYTChxxKlnjef+oQvw38/nVA jDrCK5J9w/O7M/nejE2sRrwz+q479TnOxx1UKUO2Us+rqZeB2PomVUZiU9d+FbSklE5J deauE5k+sdxzrwGYCvBV/yzTh1jbZ0EAuvQ+VHi1aX+T3b9qztBY+7DrAae0YPdGAsUv j/hA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=aaLFp9eK; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id d16-20020a056402517000b004fd2b0b6f16si18730489ede.355.2023.03.26.10.38.38; Sun, 26 Mar 2023 10:39:02 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=aaLFp9eK; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231881AbjCZRgE (ORCPT + 99 others); Sun, 26 Mar 2023 13:36:04 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38550 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231764AbjCZRgB (ORCPT ); Sun, 26 Mar 2023 13:36:01 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1FE187688; Sun, 26 Mar 2023 10:35:41 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 09D4360F0E; Sun, 26 Mar 2023 17:35:41 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 31ECFC4339E; Sun, 26 Mar 2023 17:35:40 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1679852140; bh=PZxpnhhZbamFTT/t8UtmIePJbWohJuSJJo9g/CgKKm4=; h=References:In-Reply-To:From:Date:Subject:To:Cc:From; b=aaLFp9eKj+TikZo2dNBgiqoL+9HrESCrhfi8ylmml7TbWLt0zFtgLzc8C0BekqPIT eHgqf//uV4Lv2lWFG7NXrhgG8VahcIzW5e7LcKGykw8b3+jfdjE/iT+OgZC/w++wpc dcrE2nXSD+U1zTLaFvbZ7wDmWPEh0STpkSsMwVEyVwnC927ljjsXTzt122cs79iuwB jkBj7M5ucP/2eWRm0zXHERilFMY9SOp74PlsNHAVVR7AJfxoT3cnN04IUCU0wYFuUo qTLXuGaQ5PtflMkAWrXutCvx2x9tAnPPJ1j0BfGvjNwVtXUql9qCUhYOmL7e4T4Znu AW+daCSx42gtw== Received: by mail-lf1-f54.google.com with SMTP id c29so8388642lfv.3; Sun, 26 Mar 2023 10:35:40 -0700 (PDT) X-Gm-Message-State: AO0yUKXE4KD4Kpr5rLoY/lI01UpDzYHI+ZGvDGWOkmF223VcBAtQLz5a Nq7Noy2jiIrZ7DuNBoRGnEgABiz/0EVSaBpFGeg= X-Received: by 2002:a05:6512:b8a:b0:4e8:4409:bb76 with SMTP id b10-20020a0565120b8a00b004e84409bb76mr8435400lfv.2.1679852138126; Sun, 26 Mar 2023 10:35:38 -0700 (PDT) MIME-Version: 1.0 References: <20230326170756.3021936-1-sdonthineni@nvidia.com> In-Reply-To: <20230326170756.3021936-1-sdonthineni@nvidia.com> From: Ard Biesheuvel Date: Sun, 26 Mar 2023 19:35:26 +0200 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: [PATCH] arm64: mm: Increase MODULES_VSIZE to 512MB To: Shanker Donthineni Cc: Catalin Marinas , Will Deacon , Jonathan Corbet , Mark Rutland , Anshuman Khandual , Kalesh Singh , Zhou Guanghui , linux-arm-kernel@lists.infradead.org, linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org, Vikram Sethi , Thierry Reding Content-Type: text/plain; charset="UTF-8" X-Spam-Status: No, score=-5.2 required=5.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI,SPF_HELO_NONE, SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Sun, 26 Mar 2023 at 19:08, Shanker Donthineni wrote: > > The allocation of modules occurs in two regions: the first region > MODULES_VSIZE (128MB) is shared with the core kernel, while the > the second region (2GB) is shared with other vmalloc callers. > Depending on the size of the core kernel, the 128MB region may > quickly fill up after loading a few modules, causing the system > to switch to the 2GB region. How much module space are you actually using? This 128 MiB region is not shared with vmalloc() so it should be dedicated to modules entirely. If you are doing EFI boot, you may need to following patch to ensure that the 128 MiB region is actually the one being used. commit 010338d729c1090036eb40d2a60b7b7bce2445b8 Author: Ard Biesheuvel Date: Thu Feb 23 21:41:01 2023 +0100 arm64: kaslr: don't pretend KASLR is enabled if offset < MIN_KIMG_ALIGN > Unfortunately, even the 2GB region > can run out of space if previously loaded modules and the other > kernel subsystems consume the entire area, leaving no space for > additional modules. > > This issue usually occurs when the system has a large number of > CPU cores, PCIe host-brigde controllers, and I/O devices. For > instance, the ECAM region of one host-bridge controller can use > up to 256MB of vmalloc space, while eight controllers can occupy > the entire 2GB. > > One potential solution to address this issue is to increase the > size of the MODULES_VSIZE region to 512MB, which would enhance > the system's ability to support a greater number of dynamically > loaded modules and drivers. > > Signed-off-by: Shanker Donthineni > --- > > I am seeking your guidance and feedback on the proposed solution > to address the module load failures, specifically regarding any > potential side effects that I need to be aware of. Additionally, > I would appreciate your suggestions on any alternative solutions > to resolve the issue. > > On a NVIDIA T241 system with Ubuntu-22.04, hitting boot failures > due to vmalloc/vmap allocation errors when loading modules. > dmesg: > [ 64.181308] ipmi_ssif: IPMI SSIF Interface driver > [ 64.184494] usbcore: registered new interface driver r8152 > [ 64.242492] vmap allocation for size 393216 failed: use vmalloc= to increase size > [ 64.242499] systemd-udevd: vmalloc error: size 327680, vm_struct allocation failed, mode:0xcc0(GFP_KERNEL), nodemask=(null),cpuset=/,mems_allowed=0-3 > [ 64.242510] CPU: 32 PID: 2910 Comm: systemd-udevd Tainted: G OE 6.2-generic-64k > [ 64.242513] Hardware name: NVIDIA T241, BIOS v1.1.0 2023-03-18T21:32:31+00:00 > [ 64.242515] Call trace: > [ 64.242516] dump_backtrace+0xe0/0x130 > [ 64.242523] show_stack+0x20/0x60 > [ 64.242525] dump_stack_lvl+0x68/0x84 > [ 64.242530] dump_stack+0x18/0x34 > [ 64.242532] warn_alloc+0x11c/0x1b0 > [ 64.242537] __vmalloc_node_range+0xe0/0x20c > [ 64.242540] module_alloc+0x118/0x160 > [ 64.242543] move_module+0x2c/0x190 > [ 64.242546] layout_and_allocate+0xfc/0x160 > [ 64.242548] load_module+0x260/0xbc4 > [ 64.242549] __do_sys_finit_module+0xac/0x130 > [ 64.242551] __arm64_sys_finit_module+0x28/0x34 > [ 64.242552] invoke_syscall+0x78/0x100 > [ 64.242553] el0_svc_common.constprop.0+0x170/0x194 > [ 64.242555] do_el0_svc+0x38/0x4c > [ 64.242556] el0_svc+0x2c/0xc0 > [ 64.242558] el0t_64_sync_handler+0xbc/0x13c > [ 64.242560] el0t_64_sync+0x1a0/0x1a4 > > Documentation/arm64/memory.rst | 8 ++++---- > arch/arm64/include/asm/memory.h | 2 +- > 2 files changed, 5 insertions(+), 5 deletions(-) > > diff --git a/Documentation/arm64/memory.rst b/Documentation/arm64/memory.rst > index 2a641ba7be3b..76c2fd8bbbf7 100644 > --- a/Documentation/arm64/memory.rst > +++ b/Documentation/arm64/memory.rst > @@ -33,8 +33,8 @@ AArch64 Linux memory layout with 4KB pages + 4 levels (48-bit):: > 0000000000000000 0000ffffffffffff 256TB user > ffff000000000000 ffff7fffffffffff 128TB kernel logical memory map > [ffff600000000000 ffff7fffffffffff] 32TB [kasan shadow region] > - ffff800000000000 ffff800007ffffff 128MB modules > - ffff800008000000 fffffbffefffffff 124TB vmalloc > + ffff800000000000 ffff80001fffffff 512MB modules > + ffff800020000000 fffffbffefffffff 124TB vmalloc > fffffbfff0000000 fffffbfffdffffff 224MB fixed mappings (top down) > fffffbfffe000000 fffffbfffe7fffff 8MB [guard region] > fffffbfffe800000 fffffbffff7fffff 16MB PCI I/O space > @@ -50,8 +50,8 @@ AArch64 Linux memory layout with 64KB pages + 3 levels (52-bit with HW support): > 0000000000000000 000fffffffffffff 4PB user > fff0000000000000 ffff7fffffffffff ~4PB kernel logical memory map > [fffd800000000000 ffff7fffffffffff] 512TB [kasan shadow region] > - ffff800000000000 ffff800007ffffff 128MB modules > - ffff800008000000 fffffbffefffffff 124TB vmalloc > + ffff800000000000 ffff80001fffffff 512MB modules > + ffff800020000000 fffffbffefffffff 124TB vmalloc > fffffbfff0000000 fffffbfffdffffff 224MB fixed mappings (top down) > fffffbfffe000000 fffffbfffe7fffff 8MB [guard region] > fffffbfffe800000 fffffbffff7fffff 16MB PCI I/O space > diff --git a/arch/arm64/include/asm/memory.h b/arch/arm64/include/asm/memory.h > index 78e5163836a0..dd5d634e235f 100644 > --- a/arch/arm64/include/asm/memory.h > +++ b/arch/arm64/include/asm/memory.h > @@ -46,7 +46,7 @@ > #define KIMAGE_VADDR (MODULES_END) > #define MODULES_END (MODULES_VADDR + MODULES_VSIZE) > #define MODULES_VADDR (_PAGE_END(VA_BITS_MIN)) > -#define MODULES_VSIZE (SZ_128M) > +#define MODULES_VSIZE (SZ_512M) > #define VMEMMAP_START (-(UL(1) << (VA_BITS - VMEMMAP_SHIFT))) > #define VMEMMAP_END (VMEMMAP_START + VMEMMAP_SIZE) > #define PCI_IO_END (VMEMMAP_START - SZ_8M) > -- > 2.25.1 >