From nobody Tue Feb 10 00:22:29 2026 Received: from mail-pj1-f73.google.com (mail-pj1-f73.google.com [209.85.216.73]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 0A8E31EE7A9 for ; Mon, 27 Jan 2025 23:22:51 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.216.73 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1738020173; cv=none; b=pKcCd2g7hE42KSjbY/9sk7IIK6vYBzsJwkXTR77yDQMZfpbL0JPdQ4v5H4Hwg97EtTcNgU6tH6VWU3iVwyxepnTN5BLdevnBgTqCTjrAJYUPynWSzAHBHnjer6Ee3icT8eALA4NAiRfWhLltlwWKoQWvHvI3uaYdeo4ZklBxQOw= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1738020173; c=relaxed/simple; bh=ZgxS1T7Wo27SMW5eTy1JaDNp4VOLIYnbl72z66JUhrU=; h=Date:In-Reply-To:Mime-Version:References:Message-ID:Subject:From: To:Cc:Content-Type; b=JnmM/snHNPOB7ZqFMPeW0AJqZsZivV2yRYPcB1R9jvxCvoGgXfvMLhzv5KHfHmTuW9gMqfBItRhn3qSdiEOQ++yWh62zR0/wIHHavMf8yAiBEFLb0ylmbVj9g/S/9nJLtkV0Gvp45uSOCh9jlm9QoJH+kij7dPdLXIkKLu7vkOE= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com; spf=pass smtp.mailfrom=flex--fvdl.bounces.google.com; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b=bYga3s9M; arc=none smtp.client-ip=209.85.216.73 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=flex--fvdl.bounces.google.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="bYga3s9M" Received: by mail-pj1-f73.google.com with SMTP id 98e67ed59e1d1-2ef9e4c5343so14036489a91.0 for ; Mon, 27 Jan 2025 15:22:51 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1738020171; x=1738624971; darn=vger.kernel.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=bYga3s9MwttUjV7tojMkwOPNNLdkGcgOBKyyPuwFwPIkhhdPw/cls43omEZZOvpzP3 URWrHyMPNXMc2JdGmORuBRte7BYvdVAu5F7hjRJYU9R20khfpbaDs9C48hVN6ruKoiTU 6grtg5L25k1xrjBurPRqPWiLjY3ZW8DGCcxMEL6hBakzqUoWEImS0EVJlKq+YyDouS9d 0QknghkQs+B8qHdqyRrIBwf82HYodoU3yznQ9N79Bi9/jJZXw1vy0+Z6/D9VMw8iqqe8 cb0+lKNhXFphP2HSlqTIjjLdLjtNW4JROGfwpuKiLz09u3vmloKRLMsChSsay4SmfNgW ecjQ== 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=xRXM/j5lv21q+fE7TI3zEIPtKFumVrHRfKDTLzT6CR9W0Oz/u/P03pEQOSKrpF60Bn fMn4q6G9Ic7yxUEEktfZwKoXlU4ujkoQPRP+/2W6tqImqE1YeXRl1frx9GDhIZjx9EDW 1U76GCWgGA5MFw5IQS9TbLWBRKmfTVOBz0U+KWTe68y1S/z5pcKWTvJS5u6OzQPQxxyi a1f397pF6UNZ3o78f0MFALbXIhSFDOUpJY/ik3doJjQKFHvytyi6RSinrAQA4j54Ttgv I0yL1CtGt2Vs5zqHbYD5BX2gJzhCaVBMFABAYl9NhA/TNlD67kPLiZTq4Jy3mLBmS1ZF Rvuw== X-Forwarded-Encrypted: i=1; AJvYcCWq4K30/HINN7nlBBN5o7PjmLjY4aO8iduiiSGRcUarWTk6+DbegoJBoKnJeqAba7Hy2Rx/3CteGHRm2OI=@vger.kernel.org X-Gm-Message-State: AOJu0YxLcVB4MvQUedLi7Oz8e+IIuYBgJjO8aGahpgp1br39xh0GLppH HMkVEgPfS77+Meapn5v0vtMFCNNjZsBEfCWoIRYhODS2N9g47fopG/z3+Zz6VkbOjH0yUg== 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> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: 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 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" 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; =20 /* 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; } =20 - /* hugetlb_hstate_alloc_pages will be called many times, initialize huge_= boot_pages once */ - if (!initialized) { - int i =3D 0; - - for (i =3D 0; i < MAX_NUMNODES; i++) - INIT_LIST_HEAD(&huge_boot_pages[i]); - h->next_nid_to_alloc =3D first_online_node; - h->next_nid_to_free =3D first_online_node; - initialized =3D 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; =20 if (__hugetlb_bootmem_allocated) return; =20 + for (i =3D 0; i < MAX_NUMNODES; i++) + INIT_LIST_HEAD(&huge_boot_pages[i]); + hugetlb_parse_params(); =20 for_each_hstate(h) { + h->next_nid_to_alloc =3D first_online_node; + h->next_nid_to_free =3D first_online_node; + if (hstate_is_gigantic(h)) hugetlb_hstate_alloc_pages(h); } --=20 2.48.1.262.g85cc9f2d1e-goog