From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-pf1-f175.google.com (mail-pf1-f175.google.com [209.85.210.175]) (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 CABCA2ECE86 for ; Fri, 12 Jun 2026 03:59:11 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.210.175 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1781236753; cv=none; b=oRdk/fMqjeh1RjjtwU5BS2lefZjn9QpwL24M+prMy53EHC/DMmBlPmv5hF8d4VYbEGOrhzH2paV5DyBAObluOBP4aD0bspaym+cAewDfkhomW1ivLn2ke5M7zkpq4A+UuojOJMm4jw9cwvcYswYKOVJI8PO0PP3+191Fe7zbU+I= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1781236753; c=relaxed/simple; bh=UpwtZ5ZVA+Nc9ZY2lvhas1N7wTO1lCV8FT8c0eRRQuk=; h=From:To:Cc:Subject:Date:Message-ID:MIME-Version; b=kLhE9tj/54JtB8QjzrCRA8pkHmn/hXP/w2j0q/RFtSKjETT7T61RAEjz+07Wpgnglam0dihFsQpfWrCJxwzAaPPFB0hxLW6vYsMWz2y+KZYoW6ql91uzHfnZQe/flmqWjmMtea5PWuUklKWzkgWHP2PIB8IYpMOPYkmfqd13Cug= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=bytedance.com; spf=pass smtp.mailfrom=bytedance.com; dkim=pass (2048-bit key) header.d=bytedance.com header.i=@bytedance.com header.b=PliCFt/n; arc=none smtp.client-ip=209.85.210.175 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=bytedance.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=bytedance.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=bytedance.com header.i=@bytedance.com header.b="PliCFt/n" Received: by mail-pf1-f175.google.com with SMTP id d2e1a72fcca58-842288702fbso288403b3a.1 for ; Thu, 11 Jun 2026 20:59:11 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bytedance.com; s=google; t=1781236751; x=1781841551; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=qXrTtpT2gfzfA9UVBfYwsqqZhVEbHAXGcBbRyTvn7RE=; b=PliCFt/nKoL6D2nehYDynAqezAD1Z6GTU+N0aT3mvt+fDX2bsvkX038K6Zp00YZXnt UIPl7lf3YSJAoJAC9uhT5Iy0ha3diJe1wOrzHnCWFmq+kNCQvhEw4TR5c/gRDLgCu3Iy 85ln40weKlWvOGpZTwaVOX7zkaHIqmrGRwuMKP+zuYYpKD6IjVA/vxjimXaXnvUlvUVs +D+dcxsJG5SPeLLlwJf9JzG3Bbrozrm6wKgBCBwMsuwOOhEs+QzA1ewr74V3nVoVtddf CHkDmqzSRDQHzu3483y7ga0OpNaqZdKt/aaoioVJvSwJtiYPq1TKWTkmPAaSsJDKOnHv DgNg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1781236751; x=1781841551; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-gg:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=qXrTtpT2gfzfA9UVBfYwsqqZhVEbHAXGcBbRyTvn7RE=; b=tHvSG7K9MO39NPdynVBV0p0j7q4+GXlLNA1oQ/BJjtix1uNLKEgcdUdVTBK0sitM1w Cw+VgG8H/Bv0kftEuG5/WltCzPaDvtnoBz0690R6T0WxkLOBxhFbknvDmxCRWDUpBWQj AjW42b5gQyyWQyZA5tTOGUQv8E6cRrP85CPD0ieBfbTm1MYlzAuDkj2Dlf/aZF3NGpFU 7N9Sio8c3xiB5pE5bzllmgBU28Y189Bwud0A67Lbz4Bf9Cw1hCTmxl37eR+gkfzYRJXe gKHobV6mAibGi4GZ5Q2WEFWAvwBcEkXGSDjTOBJe3wbIcEW/LvoWTYJMjnjJC7CFFzyg XPgw== X-Forwarded-Encrypted: i=1; AFNElJ/r59k8YeRByko4VI6nuw5CFEh25eeChKJreiaTBOmF/UciQhA1RP7/Kd5ql5mBrAplv/5D3Q86s9II0yg=@vger.kernel.org X-Gm-Message-State: AOJu0YyU/S1U3GwVJazx+Cf1OoIYbeZ4HGYtB4yR6r5Ckg8pNTeGKQgV nFSxm9cTiOByPAwX76xR95c5QYAlvRTTV/9b+Cfl3aLC1LpCyirNepO9P0/a8kS9qS4= X-Gm-Gg: Acq92OHkGXHDV/7ByGk6nXlBTgpC3npz0Du/ez8P1zNzU4eHaXlUMD6gQepC7Byw/EG NpNexlcW9LgrJ5fRJUZ+udaIT8hvLg5Bf5ycF1R4oN8BcqMjOocckFf8CsSKId+0TK0QedJyerv 817WLdT36ajoYan/WUKrig4QjIPpeFxba6teP0DKHQuHpnxq6b5i2iBMYqWrK8SStIPFeicAFpJ wmP6YvguFyipYeBFt4utWNmMcrh8ekXUV2joXwdOW3C1lq5PWP+BZgqxJr/Myy6l++FC03fPL2w LyKvkw0FRUxrxBO5rtiDj+fY6+P/e3G+ndJxCamoBPwfkWoCWjElxsgoM2TYCIOP+Hs+yo3OGqb JnYR1LbObgaHFIMfyBzw6948Bc61a5NKdnQx/8WhtDR52XV15Wwg4u+NJOwVeUoXpBxOHo7Aclu 3sauav0Q6LUD0k6v1qxuAiggJ7drqC7JD4WHTI3dGsLJE= X-Received: by 2002:a05:6a00:3a29:b0:842:5b63:6118 with SMTP id d2e1a72fcca58-8434cd0b6e4mr980556b3a.3.1781236750991; Thu, 11 Jun 2026 20:59:10 -0700 (PDT) Received: from n232-176-004.byted.org ([36.110.163.99]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-8434ad03fdcsm643352b3a.24.2026.06.11.20.59.06 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 11 Jun 2026 20:59:10 -0700 (PDT) From: Muchun Song To: Oscar Salvador , David Hildenbrand , Andrew Morton , Madhavan Srinivasan , Michael Ellerman Cc: Muchun Song , Mike Rapoport , Lorenzo Stoakes , "Liam R . Howlett" , Vlastimil Babka , linux-mm@kvack.org, linux-kernel@vger.kernel.org, Nicholas Piggin , Christophe Leroy , Ritesh Harjani , "Aneesh Kumar K . V" , linuxppc-dev@lists.ozlabs.org, Mike Kravetz , Muchun Song Subject: [PATCH v4 00/19] mm: Refactor bootmem gigantic hugepage allocation Date: Fri, 12 Jun 2026 11:58:44 +0800 Message-ID: <20260612035903.2468601-1-songmuchun@bytedance.com> X-Mailer: git-send-email 2.54.0 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit This series is split out from the earlier larger series "mm: Generalize HVO for HugeTLB and device DAX" [1]. It collects the first 19 patches of that series as a standalone set of fixes and preparatory cleanups around bootmem HugeTLB handling, sparse initialization ordering, and related vmemmap setup. The first patches fix a few bugs found while reviewing the existing code, including incorrect bootmem HVO handling, wrong vmemmap registration arguments, a powerpc compound-vmemmap tracking bug, and too-late initialization of gigantic bootmem HugeTLB struct pages. The rest of the series reorders early memory initialization so the relevant zone state is available before sparse and HugeTLB boot-time setup runs, then simplifies the remaining bootmem gigantic hugepage allocation path and removes code made obsolete by that rework. At a high level: - patches [1-4] fix boot-time and arch-specific bugs - patches [5-12] reorder and simplify sparse/mm/hugetlb early init - patches [13-19] refactor bootmem gigantic hugepage allocation and remove obsolete helpers and state Changes since v3: - patches 2-4: add Cc: stable@vger.kernel.org to the applicable fixes - patch 3: collect Reviewed-by from Ritesh Harjani - patch 15: move pfn_to_zone() before hugetlb_vmemmap_init_early() instead of using a forward declaration - patches 15-17: collect Acked-by from Mike Rapoport where applicable - patch 15: collect Acked-by from Usama Arif - patch 18: clarify that the changelog also covers the early CMA bootmem allocation fallback refactoring - patch 19: initialize pgdat at declaration in __init_deferred_page() and collect Reviewed-by from Mike Rapoport [1] https://lore.kernel.org/linux-mm/20260513130542.35604-1-songmuchun@bytedance.com/ Muchun Song (19): mm/hugetlb: Fix boot panic with CONFIG_DEBUG_VM and HVO bootmem pages mm/hugetlb_vmemmap: Fix __hugetlb_vmemmap_optimize_folios() powerpc/mm: Fix wrong addr_pfn tracking in compound vmemmap population mm/hugetlb: Initialize gigantic bootmem hugepage struct pages earlier mm/mm_init: Simplify deferred_free_pages() migratetype init mm/sparse: Panic on memmap and usemap allocation failure mm/sparse: Move subsection_map_init() into sparse_init() mm/mm_init: Defer sparse_init() until after zone initialization mm/mm_init: Defer hugetlb reservation until after zone initialization mm/mm_init: Remove set_pageblock_order() call from sparse_init() mm/sparse: Move sparse_vmemmap_init_nid_late() into sparse_init_nid() mm/hugetlb_cma: Validate hugetlb CMA range by zone at reserve time mm/hugetlb: Refactor early boot gigantic hugepage allocation mm/hugetlb: Free cross-zone bootmem gigantic pages after allocation mm/hugetlb_vmemmap: Move bootmem HVO setup to early init mm/hugetlb: Remove obsolete bootmem cross-zone checks mm/sparse-vmemmap: Remove sparse_vmemmap_init_nid_late() mm/hugetlb: Remove unused bootmem cma field mm/mm_init: Fold __init_page_from_nid() into __init_deferred_page() arch/powerpc/mm/book3s64/radix_pgtable.c | 7 +- arch/powerpc/mm/hugetlbpage.c | 13 +- include/linux/hugetlb.h | 24 +-- include/linux/mmzone.h | 7 - mm/cma.c | 3 +- mm/hugetlb.c | 259 +++++++++++------------ mm/hugetlb_cma.c | 44 ++-- mm/hugetlb_cma.h | 8 +- mm/hugetlb_vmemmap.c | 120 +++-------- mm/hugetlb_vmemmap.h | 5 - mm/internal.h | 14 +- mm/mm_init.c | 86 +++----- mm/sparse-vmemmap.c | 26 ++- mm/sparse.c | 48 +---- 14 files changed, 251 insertions(+), 413 deletions(-) base-commit: ec039126b7fac4e3af35ebccaa7c6f9b6875ba81 -- 2.54.0