From patchwork Fri Feb 28 18:29:08 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Frank van der Linden X-Patchwork-Id: 13996906 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 1DA8CC282C6 for ; Fri, 28 Feb 2025 18:30:09 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 3CBA1280009; Fri, 28 Feb 2025 13:30:04 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 352DA280001; Fri, 28 Feb 2025 13:30:04 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 1CA90280009; Fri, 28 Feb 2025 13:30:04 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0012.hostedemail.com [216.40.44.12]) by kanga.kvack.org (Postfix) with ESMTP id E8EA4280001 for ; Fri, 28 Feb 2025 13:30:03 -0500 (EST) Received: from smtpin04.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay10.hostedemail.com (Postfix) with ESMTP id A4E0AC1159 for ; Fri, 28 Feb 2025 18:30:03 +0000 (UTC) X-FDA: 83170192686.04.0A9E04C Received: from mail-pl1-f201.google.com (mail-pl1-f201.google.com [209.85.214.201]) by imf20.hostedemail.com (Postfix) with ESMTP id C831A1C0018 for ; Fri, 28 Feb 2025 18:30:01 +0000 (UTC) Authentication-Results: imf20.hostedemail.com; dkim=pass header.d=google.com header.s=20230601 header.b=ksuBwtDx; spf=pass (imf20.hostedemail.com: domain of 3qADCZwQKCPUcsaidlldib.Zljifkru-jjhsXZh.lod@flex--fvdl.bounces.google.com designates 209.85.214.201 as permitted sender) smtp.mailfrom=3qADCZwQKCPUcsaidlldib.Zljifkru-jjhsXZh.lod@flex--fvdl.bounces.google.com; dmarc=pass (policy=reject) header.from=google.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1740767401; 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=e4fT3nl83EuvMS99kJHXSYdNG4GrpqXQFI3hJuJeA/Y=; b=X3EahZwXGfpAlmuLDZGX4GGSD58z9tXa0kTzgSsc72fKn9zII64SAb6w2GMNBip4pycoGp tB+0z89iZU/GCUoJB6VS8tF41WNawXYJesUpQ0mXyHsNG821Bj7Xf4d8soX3gqtAhm7AIy To93v8ySbG0KJ6DJj/2Wh3B9AKw7Bic= ARC-Authentication-Results: i=1; imf20.hostedemail.com; dkim=pass header.d=google.com header.s=20230601 header.b=ksuBwtDx; spf=pass (imf20.hostedemail.com: domain of 3qADCZwQKCPUcsaidlldib.Zljifkru-jjhsXZh.lod@flex--fvdl.bounces.google.com designates 209.85.214.201 as permitted sender) smtp.mailfrom=3qADCZwQKCPUcsaidlldib.Zljifkru-jjhsXZh.lod@flex--fvdl.bounces.google.com; dmarc=pass (policy=reject) header.from=google.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1740767401; a=rsa-sha256; cv=none; b=EzPSG67SAw7Tp0eDiw5k2pIHdHsUck6G7293XmJqG5rYbNZndV+1REqnGI2IXui0rFtqYC nzyhclO8Oj71SRYqwx8oi/awTO6h+t0Yg7mLroE6lsjlf6hip2PjWUVYRglWSMX6hFWjkD Ee9TpXUmRuNYfg6Cyz3ix6TNe8oy5VM= Received: by mail-pl1-f201.google.com with SMTP id d9443c01a7336-22355de1de8so39688285ad.1 for ; Fri, 28 Feb 2025 10:30:01 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1740767401; x=1741372201; darn=kvack.org; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:from:to:cc:subject:date:message-id:reply-to; bh=e4fT3nl83EuvMS99kJHXSYdNG4GrpqXQFI3hJuJeA/Y=; b=ksuBwtDxd+NN5fEwoCGX77ZbhjPTdPIVou2glg2ekWDxyAl+CenzCjaqRaMVw0FAOA qFe+0i6FrdLnnZOOQIPVW7aFlo5zmrj54GSp6bDLWhhCfwESXwg9S6PONugErPVqdiiT 8IYIjGM3pYZLA62jBuQEv+vi7BDTZFluK607udML4JigHF9paDIuHHJUsM+ykVO6bEg1 RIhdW+zye1fT4+pX0awiNkrlG2M7CaJ+9ia7DW8i740gD2e7DSlvQmREIg/8HJQK6scC 4DwJ7K9vTym7eIa4xnOAsNIi/gzofu+KrbNS5wkzGwJWJj19hVqMxd6UCMrPXUs/tQqS 9kUg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1740767401; x=1741372201; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=e4fT3nl83EuvMS99kJHXSYdNG4GrpqXQFI3hJuJeA/Y=; b=AeUy940wFDHU64EU6vJ33nmhAP6aUWYkzQox9pE7vKyFJssu39BqpZySD2A7Q13dme 1KxONHhatoVAO8fe17CPtvFNcyqt/4DheLG8nxoPkOsb8qhj5vtbf0dKJ2iokNbiPYTO X5LQrBIeLna4YJJ+GajAqmUPcsj+w9fdj4/RfDFA9KXwHyZoaTSxxPozLJB52aUciCpc Hs/MjXOZF4Fhj7beDFrJeVSz/OYTpDsbAHCRElqMUirJfq4Hfzh+fNoc1KcPddx3NUfi ggXNKpwvGROHCv59CIxz1ylYP/or0hSPVOLguveP+5EeMMQsWPB6b++U0cQz5zwRQ85b 0Dmg== X-Forwarded-Encrypted: i=1; AJvYcCV46KPj0jc+AKf6tGK/jUXfdql7UHYQPn/mX+Muenv+aiV1Yr3mtVHQu8ExfJglGOm+pz47ReqfEw==@kvack.org X-Gm-Message-State: AOJu0YzAoNjMt8TlEHtV5EcTwv31I7m19LczpXD2gwBzk1uDyeLxbaPY d+sQATbtK1abBUbb5ii/FcJFWjcFAg4B++IOXXxgNA/id7lerI8HCoCRnC1d3Ewh84k/Zg== X-Google-Smtp-Source: AGHT+IGUAIYvgIF+BtbI5pOnkTpsWOz6nQUUqftXrAjuMRZR1VXxhKSR8/d7Qe0qOmWXJT+LI7VzDoQF X-Received: from pge11.prod.google.com ([2002:a05:6a02:2d0b:b0:ad5:4ccd:a656]) (user=fvdl job=prod-delivery.src-stubby-dispatcher) by 2002:a05:6a20:2449:b0:1ee:d418:f754 with SMTP id adf61e73a8af0-1f2f4e5a4b3mr8377121637.40.1740767400717; Fri, 28 Feb 2025 10:30:00 -0800 (PST) Date: Fri, 28 Feb 2025 18:29:08 +0000 In-Reply-To: <20250228182928.2645936-1-fvdl@google.com> Mime-Version: 1.0 References: <20250228182928.2645936-1-fvdl@google.com> X-Mailer: git-send-email 2.48.1.711.g2feabab25a-goog Message-ID: <20250228182928.2645936-8-fvdl@google.com> Subject: [PATCH v5 07/27] mm/hugetlb: convert cmdline parameters from setup to early From: Frank van der Linden To: akpm@linux-foundation.org, muchun.song@linux.dev, linux-mm@kvack.org, linux-kernel@vger.kernel.org Cc: yuzhao@google.com, usamaarif642@gmail.com, joao.m.martins@oracle.com, roman.gushchin@linux.dev, ziy@nvidia.com, david@redhat.com, Frank van der Linden X-Rspam-User: X-Rspamd-Queue-Id: C831A1C0018 X-Rspamd-Server: rspam09 X-Stat-Signature: nt145chsgcdxbw1zws4n6t8yfc1fauer X-HE-Tag: 1740767401-587635 X-HE-Meta: U2FsdGVkX1/XtvkzK5gGKqaumlTSawaE92usS1OE9BSdSoG9Bm8wUonOVX59qOoWoAYbx4BTaSKd4urIAehSRa1UzBOg0WouELhxBsD0+dXZ+PFlOe5rK0OeNjFPzSKs7Y240TEyfmpqNkSgOyoJWrP8KD/A26HqkQtKTff5W0w5gPFxx3YPuaR6HtVcURAD9sOnbUsn5YRYQW2eF64+JnKTbz11sXwtcHgFrnHQ8MWHOKV/8a/EuvfnrS+An29N2MCXZe3XVOGCgBKisc/kHYFCauj5mhf4Yr8doqsXjSLurQ9sTTLIjQq4avJEC7qX36b6sgl34SR9sTAz+9CqbHtkgcZmeSumNGKY48r7nVTT4sqSVHRz/+NhHGSvh28RnCYMCKogdeqF8FsLYGi7dfCdx5eiG0AzfTKXTnIr8lXTsT1DaKUqBfUrGuG8df+CmwjAnh14AoPC2nR2eOKmsM0DjuHgbZTzGxcp2c4sefoDO7g0owaO3r3Q2yjOk61YNGYnbQj0nja0fF3invqHyUrW0f2SremooV9Sc14Y93sdSTa5jIgiGrAMQTBcCDz+n4OmXt4KpgEJ4huLU3ZkjsiaqO+xcvtJf6y5WJyE8INALZc+8vNfQgvHcfv9mxK0ZVRhYHZm2RomtcX9mJA3wLHbLTfPSywmrrr4Vy3R9LTMlVjkZssGsfUNZwL/oOOvQTIWwUIcok3DbDlS9cuv3S5JiVH/F19+nfry/gSCJPpH+rslhhn7Uhi8x7u+Xx/CUXucnStKTXq9rOGN+4TBX3SSAJEc6XDG/hkxMup+A6PIUC6HG6v+6979qmoPtrlB152+pF4Zh/rlQrkqbABE4eZPyFcV7FCDqCb/AS/+ddugEzKZqHiFpwiOCvIYPdszaqvc52FgxeIVdHfNYILh7fjfo65yltQe3VZ4Sd7b57pN0v9GQZ60SGQCTurLXJ0dDBSaOq8zKrWPwz1bpir TpBiq5jM qjHwPHpKzbLSeUIKa312deSbVBtoajqo1zrlBbxm6wlyKjsnGYNxXLotoRwrDVrvuaMngJe6aakv1xH8VhVmBWynwaOwx98TFWNaDDF1KmaegW23Qv59IDgeWhLgzHMALF9J/x2Quz9tbUEMkkip/RMAzBF+hHrQw+lBAIfOj7Kh8RvYZ7yQ7Jc054fcjiWM9cvejMcKMPwzBQqJGbuov0zQIrIYnG8j0IoIXNun2eaDQGbVE9Pbvz2X0kwUg3MFR/UPJicc2MxeIY0v0aUpv1S9VaLwKEAtGNAOhEwfFKV9XZIgb61y4tEfpG/I25ND5vYP/Z48UMA52K/h0Z9o7E7joBfUz3IeBULay/PmwPVxQbFZ4Ykj46IV2cu1O/aNkUAlCVFh/iVdG5WZG7+HvZqpMOfV2YB1PgGyOG+FzhE7UlmMRdLBmu4eU+wEIgDz0sAgEdcnyupbwgkoDJyd/9b5far0Fs2YcgfLjh/X83s4PcOVTPp+HDVlnwUz+7Xfx/NysLX+JOYeywtaBNjXDV/bk0g== 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: Convert the cmdline parameters (hugepagesz, hugepages, default_hugepagesz and hugetlb_free_vmemmap) to early parameters. Since parse_early_param might run before MMU setups on some platforms (powerpc), validation of huge page sizes as specified in command line parameters would fail. So instead, for the hstate-related values, just record the them and parse them on demand, from hugetlb_bootmem_alloc. The allocation of hugetlb bootmem pages is now done in hugetlb_bootmem_alloc, which is called explicitly at the start of mm_core_init(). core_initcall would be too late, as that happens with memblock already torn down. This change will allow earlier allocation and initialization of bootmem hugetlb pages later on. No functional change intended. Signed-off-by: Frank van der Linden --- .../admin-guide/kernel-parameters.txt | 14 +- include/linux/hugetlb.h | 6 + mm/hugetlb.c | 133 ++++++++++++++---- mm/hugetlb_vmemmap.c | 6 +- mm/mm_init.c | 3 + 5 files changed, 126 insertions(+), 36 deletions(-) diff --git a/Documentation/admin-guide/kernel-parameters.txt b/Documentation/admin-guide/kernel-parameters.txt index fb8752b42ec8..ae21d911d1c7 100644 --- a/Documentation/admin-guide/kernel-parameters.txt +++ b/Documentation/admin-guide/kernel-parameters.txt @@ -1861,7 +1861,7 @@ hpet_mmap= [X86, HPET_MMAP] Allow userspace to mmap HPET registers. Default set by CONFIG_HPET_MMAP_DEFAULT. - hugepages= [HW] Number of HugeTLB pages to allocate at boot. + hugepages= [HW,EARLY] Number of HugeTLB pages to allocate at boot. If this follows hugepagesz (below), it specifies the number of pages of hugepagesz to be allocated. If this is the first HugeTLB parameter on the command @@ -1873,12 +1873,12 @@ :[,:] hugepagesz= - [HW] The size of the HugeTLB pages. This is used in - conjunction with hugepages (above) to allocate huge - pages of a specific size at boot. The pair - hugepagesz=X hugepages=Y can be specified once for - each supported huge page size. Huge page sizes are - architecture dependent. See also + [HW,EARLY] The size of the HugeTLB pages. This is + used in conjunction with hugepages (above) to + allocate huge pages of a specific size at boot. The + pair hugepagesz=X hugepages=Y can be specified once + for each supported huge page size. Huge page sizes + are architecture dependent. See also Documentation/admin-guide/mm/hugetlbpage.rst. Format: size[KMG] diff --git a/include/linux/hugetlb.h b/include/linux/hugetlb.h index ec8c0ccc8f95..9cd7c9dacb88 100644 --- a/include/linux/hugetlb.h +++ b/include/linux/hugetlb.h @@ -174,6 +174,8 @@ struct address_space *hugetlb_folio_mapping_lock_write(struct folio *folio); extern int sysctl_hugetlb_shm_group; extern struct list_head huge_boot_pages[MAX_NUMNODES]; +void hugetlb_bootmem_alloc(void); + /* arch callbacks */ #ifndef CONFIG_HIGHPTE @@ -1250,6 +1252,10 @@ static inline bool hugetlbfs_pagecache_present( { return false; } + +static inline void hugetlb_bootmem_alloc(void) +{ +} #endif /* CONFIG_HUGETLB_PAGE */ static inline spinlock_t *huge_pte_lock(struct hstate *h, diff --git a/mm/hugetlb.c b/mm/hugetlb.c index 0592c076cd36..1a200f89e21a 100644 --- a/mm/hugetlb.c +++ b/mm/hugetlb.c @@ -40,6 +40,7 @@ #include #include #include +#include #include #include @@ -62,6 +63,24 @@ static unsigned long hugetlb_cma_size __initdata; __initdata struct list_head huge_boot_pages[MAX_NUMNODES]; +/* + * Due to ordering constraints across the init code for various + * architectures, hugetlb hstate cmdline parameters can't simply + * be early_param. early_param might call the setup function + * before valid hugetlb page sizes are determined, leading to + * incorrect rejection of valid hugepagesz= options. + * + * So, record the parameters early and consume them whenever the + * init code is ready for them, by calling hugetlb_parse_params(). + */ + +/* one (hugepagesz=,hugepages=) pair per hstate, one default_hugepagesz */ +#define HUGE_MAX_CMDLINE_ARGS (2 * HUGE_MAX_HSTATE + 1) +struct hugetlb_cmdline { + char *val; + int (*setup)(char *val); +}; + /* for command line parsing */ static struct hstate * __initdata parsed_hstate; static unsigned long __initdata default_hstate_max_huge_pages; @@ -69,6 +88,20 @@ static bool __initdata parsed_valid_hugepagesz = true; static bool __initdata parsed_default_hugepagesz; static unsigned int default_hugepages_in_node[MAX_NUMNODES] __initdata; +static char hstate_cmdline_buf[COMMAND_LINE_SIZE] __initdata; +static int hstate_cmdline_index __initdata; +static struct hugetlb_cmdline hugetlb_params[HUGE_MAX_CMDLINE_ARGS] __initdata; +static int hugetlb_param_index __initdata; +static __init int hugetlb_add_param(char *s, int (*setup)(char *val)); +static __init void hugetlb_parse_params(void); + +#define hugetlb_early_param(str, func) \ +static __init int func##args(char *s) \ +{ \ + return hugetlb_add_param(s, func); \ +} \ +early_param(str, func##args) + /* * Protects updates to hugepage_freelists, hugepage_activelist, nr_huge_pages, * free_huge_pages, and surplus_huge_pages. @@ -3484,6 +3517,8 @@ static void __init hugetlb_hstate_alloc_pages(struct hstate *h) for (i = 0; i < MAX_NUMNODES; i++) INIT_LIST_HEAD(&huge_boot_pages[i]); + h->next_nid_to_alloc = first_online_node; + h->next_nid_to_free = first_online_node; initialized = true; } @@ -4546,8 +4581,6 @@ void __init hugetlb_add_hstate(unsigned int order) for (i = 0; i < MAX_NUMNODES; ++i) INIT_LIST_HEAD(&h->hugepage_freelists[i]); INIT_LIST_HEAD(&h->hugepage_activelist); - h->next_nid_to_alloc = first_online_node; - h->next_nid_to_free = first_online_node; snprintf(h->name, HSTATE_NAME_LEN, "hugepages-%lukB", huge_page_size(h)/SZ_1K); @@ -4572,6 +4605,42 @@ static void __init hugepages_clear_pages_in_node(void) } } +static __init int hugetlb_add_param(char *s, int (*setup)(char *)) +{ + size_t len; + char *p; + + if (hugetlb_param_index >= HUGE_MAX_CMDLINE_ARGS) + return -EINVAL; + + len = strlen(s) + 1; + if (len + hstate_cmdline_index > sizeof(hstate_cmdline_buf)) + return -EINVAL; + + p = &hstate_cmdline_buf[hstate_cmdline_index]; + memcpy(p, s, len); + hstate_cmdline_index += len; + + hugetlb_params[hugetlb_param_index].val = p; + hugetlb_params[hugetlb_param_index].setup = setup; + + hugetlb_param_index++; + + return 0; +} + +static __init void hugetlb_parse_params(void) +{ + int i; + struct hugetlb_cmdline *hcp; + + for (i = 0; i < hugetlb_param_index; i++) { + hcp = &hugetlb_params[i]; + + hcp->setup(hcp->val); + } +} + /* * hugepages command line processing * hugepages normally follows a valid hugepagsz or default_hugepagsz @@ -4591,7 +4660,7 @@ static int __init hugepages_setup(char *s) if (!parsed_valid_hugepagesz) { pr_warn("HugeTLB: hugepages=%s does not follow a valid hugepagesz, ignoring\n", s); parsed_valid_hugepagesz = true; - return 1; + return -EINVAL; } /* @@ -4645,24 +4714,16 @@ static int __init hugepages_setup(char *s) } } - /* - * Global state is always initialized later in hugetlb_init. - * But we need to allocate gigantic hstates here early to still - * use the bootmem allocator. - */ - if (hugetlb_max_hstate && hstate_is_gigantic(parsed_hstate)) - hugetlb_hstate_alloc_pages(parsed_hstate); - last_mhp = mhp; - return 1; + return 0; invalid: pr_warn("HugeTLB: Invalid hugepages parameter %s\n", p); hugepages_clear_pages_in_node(); - return 1; + return -EINVAL; } -__setup("hugepages=", hugepages_setup); +hugetlb_early_param("hugepages", hugepages_setup); /* * hugepagesz command line processing @@ -4681,7 +4742,7 @@ static int __init hugepagesz_setup(char *s) if (!arch_hugetlb_valid_size(size)) { pr_err("HugeTLB: unsupported hugepagesz=%s\n", s); - return 1; + return -EINVAL; } h = size_to_hstate(size); @@ -4696,7 +4757,7 @@ static int __init hugepagesz_setup(char *s) if (!parsed_default_hugepagesz || h != &default_hstate || default_hstate.max_huge_pages) { pr_warn("HugeTLB: hugepagesz=%s specified twice, ignoring\n", s); - return 1; + return -EINVAL; } /* @@ -4706,14 +4767,14 @@ static int __init hugepagesz_setup(char *s) */ parsed_hstate = h; parsed_valid_hugepagesz = true; - return 1; + return 0; } hugetlb_add_hstate(ilog2(size) - PAGE_SHIFT); parsed_valid_hugepagesz = true; - return 1; + return 0; } -__setup("hugepagesz=", hugepagesz_setup); +hugetlb_early_param("hugepagesz", hugepagesz_setup); /* * default_hugepagesz command line input @@ -4727,14 +4788,14 @@ static int __init default_hugepagesz_setup(char *s) parsed_valid_hugepagesz = false; if (parsed_default_hugepagesz) { pr_err("HugeTLB: default_hugepagesz previously specified, ignoring %s\n", s); - return 1; + return -EINVAL; } size = (unsigned long)memparse(s, NULL); if (!arch_hugetlb_valid_size(size)) { pr_err("HugeTLB: unsupported default_hugepagesz=%s\n", s); - return 1; + return -EINVAL; } hugetlb_add_hstate(ilog2(size) - PAGE_SHIFT); @@ -4751,17 +4812,33 @@ static int __init default_hugepagesz_setup(char *s) */ if (default_hstate_max_huge_pages) { default_hstate.max_huge_pages = default_hstate_max_huge_pages; - for_each_online_node(i) - default_hstate.max_huge_pages_node[i] = - default_hugepages_in_node[i]; - if (hstate_is_gigantic(&default_hstate)) - hugetlb_hstate_alloc_pages(&default_hstate); + /* + * Since this is an early parameter, we can't check + * NUMA node state yet, so loop through MAX_NUMNODES. + */ + for (i = 0; i < MAX_NUMNODES; i++) { + if (default_hugepages_in_node[i] != 0) + default_hstate.max_huge_pages_node[i] = + default_hugepages_in_node[i]; + } default_hstate_max_huge_pages = 0; } - return 1; + return 0; +} +hugetlb_early_param("default_hugepagesz", default_hugepagesz_setup); + +void __init hugetlb_bootmem_alloc(void) +{ + struct hstate *h; + + hugetlb_parse_params(); + + for_each_hstate(h) { + if (hstate_is_gigantic(h)) + hugetlb_hstate_alloc_pages(h); + } } -__setup("default_hugepagesz=", default_hugepagesz_setup); static unsigned int allowed_mems_nr(struct hstate *h) { diff --git a/mm/hugetlb_vmemmap.c b/mm/hugetlb_vmemmap.c index 7735972add01..5b484758f813 100644 --- a/mm/hugetlb_vmemmap.c +++ b/mm/hugetlb_vmemmap.c @@ -444,7 +444,11 @@ DEFINE_STATIC_KEY_FALSE(hugetlb_optimize_vmemmap_key); EXPORT_SYMBOL(hugetlb_optimize_vmemmap_key); static bool vmemmap_optimize_enabled = IS_ENABLED(CONFIG_HUGETLB_PAGE_OPTIMIZE_VMEMMAP_DEFAULT_ON); -core_param(hugetlb_free_vmemmap, vmemmap_optimize_enabled, bool, 0); +static int __init hugetlb_vmemmap_optimize_param(char *buf) +{ + return kstrtobool(buf, &vmemmap_optimize_enabled); +} +early_param("hugetlb_free_vmemmap", hugetlb_vmemmap_optimize_param); static int __hugetlb_vmemmap_restore_folio(const struct hstate *h, struct folio *folio, unsigned long flags) diff --git a/mm/mm_init.c b/mm/mm_init.c index 2630cc30147e..d2dee53e95dd 100644 --- a/mm/mm_init.c +++ b/mm/mm_init.c @@ -30,6 +30,7 @@ #include #include #include +#include #include "internal.h" #include "slab.h" #include "shuffle.h" @@ -2641,6 +2642,8 @@ static void __init mem_init_print_info(void) */ void __init mm_core_init(void) { + hugetlb_bootmem_alloc(); + /* Initializations relying on SMP setup */ BUILD_BUG_ON(MAX_ZONELISTS > 2); build_all_zonelists(NULL);