From patchwork Mon Jan 27 23:21:57 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: 13951858 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 11963C0218A for ; Mon, 27 Jan 2025 23:23:28 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id D677E2801C8; Mon, 27 Jan 2025 18:22:54 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id D144F28013A; Mon, 27 Jan 2025 18:22:54 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id BB6F62801C8; Mon, 27 Jan 2025 18:22:54 -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 97CB628013A for ; Mon, 27 Jan 2025 18:22:54 -0500 (EST) Received: from smtpin22.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay02.hostedemail.com (Postfix) with ESMTP id 57BAC12056D for ; Mon, 27 Jan 2025 23:22:54 +0000 (UTC) X-FDA: 83054809068.22.8D122D1 Received: from mail-pj1-f74.google.com (mail-pj1-f74.google.com [209.85.216.74]) by imf08.hostedemail.com (Postfix) with ESMTP id 768AE160004 for ; Mon, 27 Jan 2025 23:22:52 +0000 (UTC) Authentication-Results: imf08.hostedemail.com; dkim=pass header.d=google.com header.s=20230601 header.b=XaT9urBF; spf=pass (imf08.hostedemail.com: domain of 3SxWYZwQKCBo5L3B6EE6B4.2ECB8DKN-CCAL02A.EH6@flex--fvdl.bounces.google.com designates 209.85.216.74 as permitted sender) smtp.mailfrom=3SxWYZwQKCBo5L3B6EE6B4.2ECB8DKN-CCAL02A.EH6@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=1738020172; 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=gN6EK+U6QYIbP7rjA3kCmrFCSrq1dgfnRvyopAXhkYc=; b=mWQ17pjEvzQ0UKbein6KlaJcDXHbmNFi4Y+HqxMO9bVjaWEdkLXUuk6hxzi0zYn50VNccg YRAJ9JkWJFyS58xTeJzgz7hO6sh3tS7S3QGK89z0QS2SwdSxOIVQJrOAxC3mR4H1KI1bSD q11neDTSN6ACCazKhJ54CsgeXh0/Z/M= ARC-Authentication-Results: i=1; imf08.hostedemail.com; dkim=pass header.d=google.com header.s=20230601 header.b=XaT9urBF; spf=pass (imf08.hostedemail.com: domain of 3SxWYZwQKCBo5L3B6EE6B4.2ECB8DKN-CCAL02A.EH6@flex--fvdl.bounces.google.com designates 209.85.216.74 as permitted sender) smtp.mailfrom=3SxWYZwQKCBo5L3B6EE6B4.2ECB8DKN-CCAL02A.EH6@flex--fvdl.bounces.google.com; dmarc=pass (policy=reject) header.from=google.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1738020172; a=rsa-sha256; cv=none; b=Sfj4Fd7H5P9r/E6+ntsa9itPsZvdL/9vunEy0n7/vQKmeVFzc5W4gPCBbAF25sRH5Ls0ST NUo1LMRfVO2hWIWkAtIfGJlpxTEObdvkusHuoug57HxdmMifnAhfiqufOgK1/zCQ22UtO+ bZ3C9S+zjA04hGflcP6hfgvVwnSRFXM= Received: by mail-pj1-f74.google.com with SMTP id 98e67ed59e1d1-2ef9b9981f1so13980318a91.3 for ; Mon, 27 Jan 2025 15:22:52 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1738020171; x=1738624971; 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=gN6EK+U6QYIbP7rjA3kCmrFCSrq1dgfnRvyopAXhkYc=; b=XaT9urBFuWn2oowmF7Dv6cmGyAojyAsjEq9xFtyYu8yurpeXD/B/+3y9yjRhLaPRiS iT+ENkFLxmNkpwulJRHHPso9YpHc8ekqU77LxNw6RTY/uSEm3QeYqTr95iT4wrYmyRog Q4bqC/szBMvSqtdSFlkT4L0u176qaCgfUtpeWErdosxnoM+TWpo8XK/gRMeFp9qApVdz T0dBPu+rFrl8iaDeR42m9Nqrs3fql2V5X1eehwHubXyR6Ol0kEBoRFua3lSTReYwY5v8 D7eG5gCoj3AdX1B0ZkcZQ9K9tAHiU1UC+2TXWY+SnGEhxVP2RMeELAZhTKXTepZDwlvg pQHQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1738020171; x=1738624971; 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=gN6EK+U6QYIbP7rjA3kCmrFCSrq1dgfnRvyopAXhkYc=; b=MgRfBSo8ermIwv81oPWpsQEEzIXZYgp6wKQJVnAZPdzmBcVMl7CJ9t5rfPr/+E+6V6 pklIZKSTkK+yvEApkDBRXJ5GlxD8Bo4sYDilMNESaytIf82jOLQUx9WlueZ663PbNOBh wjP2rXvPS6CMp7+d2dznKIuPbzVWK/ywhKCfalTUMCituXJBYAGY/e3NsVBm/n3jD1nb YNl04ml4EBiIz3XB/mINUV15ntCUnJwFerYN/MAStSZbS6ojGw+QziB+azrt2HZm/Akj 9pOf8Tw35/4eqlID0CBgN6GswMa/mui1HzcG4fl44PxtvBCfTMD4PwZEsPeV29kjfIJG Ry8w== X-Forwarded-Encrypted: i=1; AJvYcCXyr0cpMGC3js0Eln8E/Qx5tA+cRdaZ49xjZBbzP7zbysn0b52kz731uTIK+E71nexAkINxMwichQ==@kvack.org X-Gm-Message-State: AOJu0Yx/WhV+DVARTkIcIKUXIjiMbWnxz2QmFSmcC6dhT2nmxS+fxoZy t/T7Ag8CbWqT96DlKjDgl7e3VQpE/XSrt6p/CYOruJdToomijg2Wee4NIzPrp3SgKVEOiA== X-Google-Smtp-Source: AGHT+IEB19lBmsSgcwC3AJjb1l49j6QqCp/duCIXB8+yga7ZxDp2FikGh4xF/oRa2YREpQLIMove+/qi X-Received: from pfbcg24.prod.google.com ([2002:a05:6a00:2918:b0:72a:bc54:8507]) (user=fvdl job=prod-delivery.src-stubby-dispatcher) by 2002:a05:6a00:4293:b0:727:3cd0:122f with SMTP id d2e1a72fcca58-72dafa04710mr55707205b3a.9.1738020171346; Mon, 27 Jan 2025 15:22:51 -0800 (PST) Date: Mon, 27 Jan 2025 23:21:57 +0000 In-Reply-To: <20250127232207.3888640-1-fvdl@google.com> Mime-Version: 1.0 References: <20250127232207.3888640-1-fvdl@google.com> X-Mailer: git-send-email 2.48.1.262.g85cc9f2d1e-goog Message-ID: <20250127232207.3888640-18-fvdl@google.com> Subject: [PATCH 17/27] mm/hugetlb: move huge_boot_pages list init to hugetlb_bootmem_alloc 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, usama.arif@bytedance.com, joao.m.martins@oracle.com, roman.gushchin@linux.dev, Frank van der Linden X-Rspamd-Server: rspam02 X-Rspamd-Queue-Id: 768AE160004 X-Stat-Signature: azfsxxcosu37cpw4x7jxze5q1ea1cx5m X-Rspam-User: X-HE-Tag: 1738020172-728579 X-HE-Meta: U2FsdGVkX1+1Sc0FnxeJShwIe4qkciADlV5dSTC9vk52bZsCFkrNA37aPp9pFmsLAymndcJe8nHcIS7puApY8kdDVuz39WG1HrK9a4e3N2isiWG46Q2Uaqvo91xB3nA4BqW5haJ/75ot3Lm3jPc4mhtdQqZy5LeLnH9qwvYFL/Y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j6YLRooHbFJ9GVLbEsx1EBAYDKxIY5ktMJ+hvHsyFMWnxtDyj8AQyRmQrDvKtTIROFn1N5XzdyWI5Wudybf/qmvn2JolmmYCCCYYGiPWb9f1C0DwhUUqs2az1bLHbOxPonuiigTmAOzYQmPdGe+yuAkeCy6+OHjUwA+OPeby5lui9oGRAZHZaskRNFaPRmUACyHeloG34hX4vOAGhb6xelPzKVhYBGICw65AdhptQMEwBLz1LIY1ZcZufAGlHg1VjUa1q4wPEVtkrhsQnsWjEACkpLtuluVGTjMGxDhCjj0KvUxbWrEHMm6jFzgjRsWoRvECvoVIKJ8RFoBV4ggYrDFSQ= 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: Instead of initializing the per-node hugetlb bootmem pages list from the alloc function, we can now do it in a somewhat cleaner way, since there is an explicit hugetlb_bootmem_alloc function. Initialize the lists there. Signed-off-by: Frank van der Linden --- mm/hugetlb.c | 19 +++++++------------ 1 file changed, 7 insertions(+), 12 deletions(-) diff --git a/mm/hugetlb.c b/mm/hugetlb.c index 18cd232b5df2..2aa35c1d112b 100644 --- a/mm/hugetlb.c +++ b/mm/hugetlb.c @@ -3579,7 +3579,6 @@ static unsigned long __init hugetlb_pages_alloc_boot(struct hstate *h) static void __init hugetlb_hstate_alloc_pages(struct hstate *h) { unsigned long allocated; - static bool initialized __initdata; /* skip gigantic hugepages allocation if hugetlb_cma enabled */ if (hstate_is_gigantic(h) && hugetlb_cma_size) { @@ -3587,17 +3586,6 @@ static void __init hugetlb_hstate_alloc_pages(struct hstate *h) return; } - /* hugetlb_hstate_alloc_pages will be called many times, initialize huge_boot_pages once */ - if (!initialized) { - int i = 0; - - 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; - } - /* do node specific alloc */ if (hugetlb_hstate_alloc_pages_specific_nodes(h)) return; @@ -4921,13 +4909,20 @@ bool __init hugetlb_bootmem_allocated(void) void __init hugetlb_bootmem_alloc(void) { struct hstate *h; + int i; if (__hugetlb_bootmem_allocated) return; + for (i = 0; i < MAX_NUMNODES; i++) + INIT_LIST_HEAD(&huge_boot_pages[i]); + hugetlb_parse_params(); for_each_hstate(h) { + h->next_nid_to_alloc = first_online_node; + h->next_nid_to_free = first_online_node; + if (hstate_is_gigantic(h)) hugetlb_hstate_alloc_pages(h); }