From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-pl1-f181.google.com (mail-pl1-f181.google.com [209.85.214.181]) (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 D00ED370D6F for ; Wed, 13 May 2026 13:10:35 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.214.181 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1778677837; cv=none; b=KfWdppR7BMmKhtqxNVeOj8GpDxshIZnUAGjxbJWJlqvCtcXam0Go5MJVmjj3q2Z06bKDpWm920N9Isawo3vD1bfmF7VXX/AexPVC8b4+c1NuddP2Kmu1E6FhB6ShyI/M7zQzVl1jBeWYN1/35jlgJWrLuZajqk2STyrjLgZgcw8= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1778677837; c=relaxed/simple; bh=gKQ8Y3Wum3R2jqLu6RbfYttnTWPjt8JxcTLFA6EDSKM=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=TbiQUnIuW4biO2LCebr/mL1Q9g6McRrTrl+GBJBC+wHHxBOLjZxu2VY/oYb/kiY3TJJgzq4KcTVoExWsMdl8rjU+xy6kJOOkncfa+eedcI5JQYDIld1EFtnV/LmE1ImvWOoAx507EAM4IxQcB4PeiUf71ikdkUfDQ/2I4ZHpWuM= 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=I+vVZi9X; arc=none smtp.client-ip=209.85.214.181 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="I+vVZi9X" Received: by mail-pl1-f181.google.com with SMTP id d9443c01a7336-2babfd18435so34509285ad.1 for ; Wed, 13 May 2026 06:10:35 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bytedance.com; s=google; t=1778677835; x=1779282635; 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=UOmi79uUam5ycb0mnRYplgXKnDDShon/X8fwxFGausU=; b=I+vVZi9Xr7GMzgMim6WhJkjWpmWGxudfaheR2JyqVqutU+RGh0N7c+Xuw5OizmJ6Rc 5nINoK3w/3rCh8dS2a9GdGYBVJXaW9rn2hXwN0gPbtkNLSyL+tqQnn0MGIGIMIEpBEZF rijMcSgTN8bQ8LfcfdFgzbGoVCoCX2LtoQKnmszRImYOUstkLNVm9XOY2xexqtPZbv9f iW4dCm+9Wz2auL1m0veLPt8RCgBvNRtJRkcF3oK9P8bJ0+aQJyNlzjUd4mrRFvjIug/P VPw/pZFQJrPVXWeAhjcUk1fCfbTfevIGj/zsosd9rey3HRae4zFYDxSeCkN3LeeJcuE5 PdRA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1778677835; x=1779282635; 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=UOmi79uUam5ycb0mnRYplgXKnDDShon/X8fwxFGausU=; b=F4btteCP0ii3JDndCE/2KMJgA0LhvSeE44uCbWiEAeDEmbG7y5HmWEmdKpB68CDLVy 1LqAW5H7x3OePh4QkF8+PyTVwYBwyEQgV3HqmYYHf/jKBxLploS6GFZiRKecaGYUEaw1 4OZ+XZvBoYZsTQKJD7BNnDDQRduJHKwkWoDHl4ngdB+zlcT0CdLY3AzRzTxIZcFQhrTm X4n8h8RiEuBnOAilPzv+ltBBZ6POk1zlFzT8NFgzp05zhgBjC4tnOUChRmqXLmluifzL Iya1EutlPJZWPIg3SII0+u96Rd3SYKuMhwvuOCFMqQz4B83U4H7PwPZDbBBd+1ci2fFC EERQ== X-Forwarded-Encrypted: i=1; AFNElJ8uZrUpHEsxXF/dltR/EQ8A0XunSPQ/tvpmk09YD5N3ZivSzGlVWFWhfFGKOpMldosLk0Ab3/hDuIfgVwY=@vger.kernel.org X-Gm-Message-State: AOJu0YyQdwuStDDPFCVNQtqhe5VZqh/jHDGj0JXN7ZMmloQ3ewEOR0ca i1oI2Bfte6Q4owdPuSEMZLYrabCerc2FyJii6dRCX2pld1wfvGkbZM6z/lJ9Lp7VMtY= X-Gm-Gg: Acq92OElV/j6riqft1IMY1LZVh5eIMu8iQGvIp6H+RjWRIaAHG0NEQ1lzZlAUjvJRb2 rBumTNDf0HSTdYzghwAeq0+ptUKqNyHNOQLvx5QH0TRILopSWwwzjARrT8h7+GPzvIV1rW5t/5d DM8nG80aqxy1tqrDOVNQDdhaU1xFT7tk/OFD2a9OyPBuAE8qC7V68rU13dPMOsvQcGAO/XYpwnY Ox49HcqJyJ+xaUD0MPqFKBn0NlxIXUydxn0t+kEFTcuVMvsX2CXPJ2wXrGIHG/yMEP4/QzRUi9B Sd1ofHr9b/nLU7UDGQnlWDJFfppGXezxs0z0thNd1FTwd+Ga9kMLetYmCqL1ZJ0iY7NaMA6s3nv a5lxNrmBD28vnqycQx6mhSMWU4IAWcgrtApUanAaTmBnP3KqWs8QSJIVLnp00/AuZFBZMHl+nVk HVULDX7xrEPqcL4jrPxQ6PMC0fxXKFKl5PC4qmdnOoR8wN8Wc79FHhCZViqqI= X-Received: by 2002:a17:903:8cf:b0:2ae:ba5f:3ac3 with SMTP id d9443c01a7336-2bd27133c5fmr20492895ad.2.1778677834864; Wed, 13 May 2026 06:10:34 -0700 (PDT) Received: from PXLDJ45XCM.bytedance.net ([61.213.176.6]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-2baf1e90854sm166641925ad.66.2026.05.13.06.10.29 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Wed, 13 May 2026 06:10:34 -0700 (PDT) From: Muchun Song To: Andrew Morton , David Hildenbrand , Muchun Song , Oscar Salvador , Michael Ellerman , Madhavan Srinivasan Cc: Lorenzo Stoakes , "Liam R . Howlett" , Vlastimil Babka , Mike Rapoport , Suren Baghdasaryan , Michal Hocko , Nicholas Piggin , Christophe Leroy , Ackerley Tng , Frank van der Linden , aneesh.kumar@linux.ibm.com, joao.m.martins@oracle.com, linux-mm@kvack.org, linuxppc-dev@lists.ozlabs.org, linux-kernel@vger.kernel.org, Muchun Song Subject: [PATCH v2 33/69] mm/sparse: Remove SPARSEMEM_VMEMMAP_PREINIT Date: Wed, 13 May 2026 21:05:01 +0800 Message-ID: <20260513130542.35604-34-songmuchun@bytedance.com> X-Mailer: git-send-email 2.50.1 In-Reply-To: <20260513130542.35604-1-songmuchun@bytedance.com> References: <20260513130542.35604-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 was only there to support HugeTLB's early vmemmap optimization setup. Now that HugeTLB bootmem vmemmap optimization uses the common section-based sparse-vmemmap path, sparsemem no longer needs a separate pre-initialization mechanism. Remove the Kconfig symbols, section flag, and empty sparse-vmemmap early hook, and always initialize present sections 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 f24810015234..ed2aa0e4c472 100644 --- a/arch/x86/Kconfig +++ b/arch/x86/Kconfig @@ -148,7 +148,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 d6a5dd042c25..b9baef8cca91 100644 --- a/include/linux/mmzone.h +++ b/include/linux/mmzone.h @@ -2092,9 +2092,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, }; @@ -2106,9 +2103,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 @@ -2163,24 +2157,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)); @@ -2427,7 +2403,6 @@ static inline unsigned long next_present_section_nr(unsigned long section_nr) #endif #else -#define sparse_vmemmap_init_nid_early(_nid) do {} while (0) #define pfn_in_present_section pfn_valid static inline void section_set_order_range(unsigned long pfn, unsigned long nr_pages, unsigned int order) diff --git a/mm/Kconfig b/mm/Kconfig index bb0202cf8b15..c26d2d2050d5 100644 --- a/mm/Kconfig +++ b/mm/Kconfig @@ -410,8 +410,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. @@ -422,9 +420,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 f1c3b2d0f23c..dde4486195ad 100644 --- a/mm/sparse-vmemmap.c +++ b/mm/sparse-vmemmap.c @@ -548,19 +548,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 47349f6f463f..eab37504819d 100644 --- a/mm/sparse.c +++ b/mm/sparse.c @@ -316,27 +316,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