From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-pl1-f180.google.com (mail-pl1-f180.google.com [209.85.214.180]) (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 7882E4ADDB6 for ; Thu, 2 Jul 2026 09:42:04 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.214.180 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1782985326; cv=none; b=U3Cd1ZIMdB/QW24I1ZHNMW4lcP7gYdRPyKYQjseIfrvB3G9a3y9tLQv2lxbezTIE5QjegZAFO2GDubFkgMMNtKuyorX/a9ZZDPCAze6sN7sLZCcXxYDCQ8w9aCAiio0L7qq7FflO3iDXVey00V1GW4FC2yZbNQRs0piF7RHHkIA= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1782985326; c=relaxed/simple; bh=mE+3NlMRpem4dTPY1k+fBZ8KOCU/suMCi5nnQY/jeps=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=BRhbFAkL97nzJc3CbG3WuTnHxsiGX6mOaLkFPlogyvSNKIqgLQ5lb6jLvubQjc3+BUiEvBI/ubwp39VQ1qCawWx1VViHAL+bh4NKYUUqLtOSXz6rjicSmSdpD8YECTj+Wya2siqxyDdq2jgOdyfD2jz8fKlpItub3oKN5/hJ3FM= 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=U+xhemOL; arc=none smtp.client-ip=209.85.214.180 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="U+xhemOL" Received: by mail-pl1-f180.google.com with SMTP id d9443c01a7336-2ca70925c25so16926215ad.1 for ; Thu, 02 Jul 2026 02:42:04 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bytedance.com; s=google; t=1782985324; x=1783590124; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=t3h52ApKyEWVjkCM3iuLPksqHn2H9qJ9tGGII6Hv+Hc=; b=U+xhemOL6P600K8J97jizOjDlPs33KCSJ2HXeQxBboTZWkeBJ06rdvEj6AnmzsmDcG vyBvpeRUWmeadVTKLTY8pqLkfRh4UWSwkKc4OzOq9uBb1WLpvOzrswzSpeVNkQwFcDJm DKm+ml4alq9M42+F38UcTfkERpPV4fLHmiCaGLeCSh5SXNhJ/wV/RinvciqBVGgyaZYR oHNVnupIzXH9PPD2Dfa0cneBCjpDMKko172cW3Ckh2xPe5paw1osZRfD/A0Kevtofsso n87q2OlXtEJkHRU0AlbVlcKzBM5ZbuIThLD14tjDhbozHAXkjS1dTcXhwtM0GKbkOU6h SGuw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1782985324; x=1783590124; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to; bh=t3h52ApKyEWVjkCM3iuLPksqHn2H9qJ9tGGII6Hv+Hc=; b=fu8geElMCc/X2G/utu3wrNthyxYqIeV+toemWnjoXUi6cZOGt4UMbXSk4bMttxTLwn X60pZaFi6VlRQbO+psBuffzPmTAolzvK604QC53vplpUSpp3+E5iWuSPiDnq7Qj+gmE9 QUtXcUQDJF8IlZJxmXlhIx9/2UPpdIb/G3h0D3FkhNbRvH4jXJicAKfSGKWHL+pbEuRp IOE+4JOtvsatDgVfyeRj8E7xQvLxxB8E6LkQMnaEX0d+HlL0bMcjL68hUud5OJ1cb0xb nReEfueHenvlz5r4us0C/X7m3JQxea+ACb7SnnyRctQSmoHUTx+p1zflamM9tCFwilvW UXXg== X-Forwarded-Encrypted: i=1; AHgh+RrpMsouLMRUcMQUXl26osbKswUqhSNyRiwqmjZ8vU12+4dVEJOHMVgBHJVLEoJf+5rH8kyKMQ5wiAR/k2g=@vger.kernel.org X-Gm-Message-State: AOJu0YwMu4FjM7Zr9MTBGMF25Zke5qBMT08ZhtMEdAmPxX1wwKHeIA4w y7BDyNJrdxkgTdiRUNxTdLS5qPu2566U47NsRkmqb0k26d6rkAbTgOLp+6q8ZFNsKOY= X-Gm-Gg: AfdE7cls5gM7HE7B1Kv0HOTjjr5rjWyKZbIb0GqHZubVSFKwF6pCwapLUj/dsiNVU5a n0WUpH0ZPuP06B+mbrwhJFWS5TpEyt8j/54CU2rgM+7j0v3c+x/7tvCE+5xCs2Dos01UtQLoc0C 1gwNZoaRQ7jZRIzsieO/S6UKgUbq46n/bXu9JIq1GpjOsunme4nuRkdbUkqG8JDRHjzX0uRey/o 6eAjoVVInhYah9mFGVGHorjZTINKRgej1aiPNdbVSfws98/769Yy7m0t9aNg4gcM5NtR9xjA3D7 JMsZvwIL9jrvWo0ACQ5h2WwamMO/oeqNAMdj3MFFQEaWmkfA9VL0hsX7wpC0JDu5CXwmwmYJ2Rd EciVwOCj95IOVfk8ZKRH1O5mh5mbggtj/G/8aPc6h2SL+iITLq3wLoEN+aN6AGJpRqlhw9MorB5 VQNucKBj0EUA4U20PBPyXpbNVs4QmPoN7v X-Received: by 2002:a17:903:ac4:b0:2c9:d55d:2d1 with SMTP id d9443c01a7336-2ca9120069emr47974265ad.33.1782985323625; Thu, 02 Jul 2026 02:42:03 -0700 (PDT) Received: from n232-176-004.byted.org ([36.110.163.98]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-2ca9a8f8458sm10971085ad.18.2026.07.02.02.42.00 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 02 Jul 2026 02:42:03 -0700 (PDT) From: Muchun Song To: Andrew Morton , Oscar Salvador , David Hildenbrand , linux-mm@kvack.org Cc: Mike Rapoport , Vlastimil Babka , Lorenzo Stoakes , Michal Hocko , linux-kernel@vger.kernel.org, Muchun Song , muchun.song@linux.dev Subject: [PATCH 11/17] mm/sparse-vmemmap: remove SPARSEMEM_VMEMMAP_PREINIT support Date: Thu, 2 Jul 2026 17:38:15 +0800 Message-ID: <20260702093821.2740183-12-songmuchun@bytedance.com> X-Mailer: git-send-email 2.54.0 In-Reply-To: <20260702093821.2740183-1-songmuchun@bytedance.com> References: <20260702093821.2740183-1-songmuchun@bytedance.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit SPARSEMEM_VMEMMAP_PREINIT existed only to support HugeTLB's early vmemmap optimization setup. Now that HugeTLB bootmem vmemmap optimization uses the common section-based sparse-vmemmap path, the sparse initialization code no longer needs a separate pre-initialization mechanism for vmemmap population. Remove the related Kconfig symbols, section flag, and empty early hook, so present sections always go through the normal sparse setup path. Signed-off-by: Muchun Song --- arch/x86/Kconfig | 1 - fs/Kconfig | 1 - include/linux/mmzone.h | 25 ------------------------- mm/Kconfig | 5 ----- mm/sparse-vmemmap.c | 13 ------------- mm/sparse.c | 23 ++++++++--------------- 6 files changed, 8 insertions(+), 60 deletions(-) diff --git a/arch/x86/Kconfig b/arch/x86/Kconfig index bdad90f210e4..3cab495637c4 100644 --- a/arch/x86/Kconfig +++ b/arch/x86/Kconfig @@ -147,7 +147,6 @@ config X86 select ARCH_WANT_LD_ORPHAN_WARN select ARCH_WANT_OPTIMIZE_DAX_VMEMMAP if X86_64 select ARCH_WANT_OPTIMIZE_HUGETLB_VMEMMAP if X86_64 - select ARCH_WANT_HUGETLB_VMEMMAP_PREINIT if X86_64 select ARCH_WANTS_THP_SWAP if X86_64 select ARCH_HAS_PARANOID_L1D_FLUSH select ARCH_WANT_IRQS_OFF_ACTIVATE_MM diff --git a/fs/Kconfig b/fs/Kconfig index cf6ae64776e6..ccb9dd480523 100644 --- a/fs/Kconfig +++ b/fs/Kconfig @@ -278,7 +278,6 @@ config HUGETLB_PAGE_OPTIMIZE_VMEMMAP def_bool HUGETLB_PAGE depends on ARCH_WANT_OPTIMIZE_HUGETLB_VMEMMAP depends on SPARSEMEM_VMEMMAP - select SPARSEMEM_VMEMMAP_PREINIT if ARCH_WANT_HUGETLB_VMEMMAP_PREINIT config HUGETLB_PMD_PAGE_TABLE_SHARING def_bool HUGETLB_PAGE diff --git a/include/linux/mmzone.h b/include/linux/mmzone.h index fcbd8d26c5c2..dbd3efc53d56 100644 --- a/include/linux/mmzone.h +++ b/include/linux/mmzone.h @@ -2081,9 +2081,6 @@ enum { SECTION_IS_EARLY_BIT, #ifdef CONFIG_ZONE_DEVICE SECTION_TAINT_ZONE_DEVICE_BIT, -#endif -#ifdef CONFIG_SPARSEMEM_VMEMMAP_PREINIT - SECTION_IS_VMEMMAP_PREINIT_BIT, #endif SECTION_MAP_LAST_BIT, }; @@ -2095,9 +2092,6 @@ enum { #ifdef CONFIG_ZONE_DEVICE #define SECTION_TAINT_ZONE_DEVICE BIT(SECTION_TAINT_ZONE_DEVICE_BIT) #endif -#ifdef CONFIG_SPARSEMEM_VMEMMAP_PREINIT -#define SECTION_IS_VMEMMAP_PREINIT BIT(SECTION_IS_VMEMMAP_PREINIT_BIT) -#endif #define SECTION_MAP_MASK (~(BIT(SECTION_MAP_LAST_BIT) - 1)) #define SECTION_NID_SHIFT SECTION_MAP_LAST_BIT @@ -2152,24 +2146,6 @@ static inline int online_device_section(const struct mem_section *section) } #endif -#ifdef CONFIG_SPARSEMEM_VMEMMAP_PREINIT -static inline int preinited_vmemmap_section(const struct mem_section *section) -{ - return (section && - (section->section_mem_map & SECTION_IS_VMEMMAP_PREINIT)); -} - -void sparse_vmemmap_init_nid_early(int nid); -#else -static inline int preinited_vmemmap_section(const struct mem_section *section) -{ - return 0; -} -static inline void sparse_vmemmap_init_nid_early(int nid) -{ -} -#endif - static inline int online_section_nr(unsigned long nr) { return online_section(__nr_to_section(nr)); @@ -2373,7 +2349,6 @@ static inline unsigned long next_present_section_nr(unsigned long section_nr) #else struct mem_section; -#define sparse_vmemmap_init_nid_early(_nid) do {} while (0) #define pfn_in_present_section pfn_valid static inline struct mem_section *__pfn_to_section(unsigned long pfn) { diff --git a/mm/Kconfig b/mm/Kconfig index 9e0ca4824905..50fa9724f711 100644 --- a/mm/Kconfig +++ b/mm/Kconfig @@ -463,8 +463,6 @@ config SPARSEMEM_VMEMMAP pfn_to_page and page_to_pfn operations. This is the most efficient option when sufficient kernel resources are available. -config SPARSEMEM_VMEMMAP_PREINIT - bool # # Select this config option from the architecture Kconfig, if it is preferred # to enable the feature of HugeTLB/dev_dax vmemmap optimization. @@ -475,9 +473,6 @@ config ARCH_WANT_OPTIMIZE_DAX_VMEMMAP config ARCH_WANT_OPTIMIZE_HUGETLB_VMEMMAP bool -config ARCH_WANT_HUGETLB_VMEMMAP_PREINIT - bool - config HAVE_MEMBLOCK_PHYS_MAP bool diff --git a/mm/sparse-vmemmap.c b/mm/sparse-vmemmap.c index 37afd5ccf260..166fb95b5e6d 100644 --- a/mm/sparse-vmemmap.c +++ b/mm/sparse-vmemmap.c @@ -570,19 +570,6 @@ struct page * __meminit __populate_section_memmap(unsigned long pfn, return pfn_to_page(pfn); } -#ifdef CONFIG_SPARSEMEM_VMEMMAP_PREINIT -/* - * This is called just before initializing sections for a NUMA node. - * Any special initialization that needs to be done before the - * generic initialization can be done from here. Sections that - * are initialized in hooks called from here will be skipped by - * the generic initialization. - */ -void __init sparse_vmemmap_init_nid_early(int nid) -{ -} -#endif - static void subsection_mask_set(unsigned long *map, unsigned long pfn, unsigned long nr_pages) { diff --git a/mm/sparse.c b/mm/sparse.c index 2a1a1f5e97c4..eb841fe61f0a 100644 --- a/mm/sparse.c +++ b/mm/sparse.c @@ -327,27 +327,20 @@ static void __init sparse_init_nid(int nid, unsigned long pnum_begin, if (sparse_usage_init(nid, map_count)) panic("Failed to allocate usemap for node %d\n", nid); - sparse_vmemmap_init_nid_early(nid); - for_each_present_section_nr(pnum_begin, pnum) { - struct mem_section *ms; unsigned long pfn = section_nr_to_pfn(pnum); + struct page *map; if (pnum >= pnum_end) break; - ms = __nr_to_section(pnum); - if (!preinited_vmemmap_section(ms)) { - struct page *map; - - map = __populate_section_memmap(pfn, PAGES_PER_SECTION, - nid, NULL, NULL); - if (!map) - panic("Failed to allocate memmap for section %lu\n", pnum); - memmap_boot_pages_add(section_nr_vmemmap_pages(pfn, PAGES_PER_SECTION, - NULL, NULL)); - sparse_init_early_section(nid, map, pnum, 0); - } + map = __populate_section_memmap(pfn, PAGES_PER_SECTION, + nid, NULL, NULL); + if (!map) + panic("Failed to allocate memmap for section %lu\n", pnum); + memmap_boot_pages_add(section_nr_vmemmap_pages(pfn, PAGES_PER_SECTION, + NULL, NULL)); + sparse_init_early_section(nid, map, pnum, 0); } sparse_usage_fini(); } -- 2.54.0