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 7C1442ECE86 for ; Fri, 12 Jun 2026 03:59:47 +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=1781236788; cv=none; b=j9OmXCxMYETvK8e9eaA7Z0FLICfMEy5K+74QKxT9qTyAHKlfiOpniI+WNpXBZtl2iHPsO4Wiq2q0pSM1zm66+wUSKZqG4mLpAyZsJEBVyTI96g89wRI0umoqRu6hbDAhggXcc5/yuW4EMgoKcbui00905nuOakkqlQ2gcD4W8wo= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1781236788; c=relaxed/simple; bh=ow74BBuCE385gaDYcvGhO2IeGlQ+gdl3WM/ewdsx7Gw=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=s48LCCkTlXIcWegYCSTOupkV/gsK802pFEH1IYngGWLxgxZC7KJzFL8siwQRFDjmUp7JC7LI/hwx4YwGZbGKtTT4JDO1Mn1j4K5MeCGyvtfBBxdMxJCJSf6EbG5UhXFfch53c4Mq2q+EjwE9DlswLgdyYnTCUju08nY9cdqQnS0= 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=U64aOvO+; 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="U64aOvO+" Received: by mail-pf1-f175.google.com with SMTP id d2e1a72fcca58-8422524cb38so266834b3a.0 for ; Thu, 11 Jun 2026 20:59:47 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bytedance.com; s=google; t=1781236787; x=1781841587; 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=okNQn7jBY8GYg30w4rV+l+0LtWk7klxQgPQSIxA5238=; b=U64aOvO+hmYO/AEvLiqNYYw7QC4j1IgE00pjwLJOEj82AY3gJvY/6lZhXaKNIfC8kT qxpxBhjExHjZC+v5tgRIybwuSLKSuEq3BYe8hw0SS0diB7nK7PgxeqOJTwmrkwZFilbo Z/V+MJPfPBzXhk/qvtUXF80US2OdSyd66RFqUXHI7x/Mv9ZNDwP55W02U9B5etOtVd3o ohzZ+ZN48mVyHXeAJDksWYAIUCV4shzC3S/DuGPuwXDubrVZmpQw13RmH6dhd/Y4QasU L1g7AjFzyGazJL1cxZFLhP/TTC2HWETS4eQyhBw3W9Wp2rc8H0eFuLQUP6gi5Xgcz0OW sDjA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1781236787; x=1781841587; 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=okNQn7jBY8GYg30w4rV+l+0LtWk7klxQgPQSIxA5238=; b=gmX0WCC773Ci3bcolt87O7yJwYctBAh62iP4fGbxEeIrLr+Y/ocNzhUO1T7IMtKP66 9izWLU7p5BY1FBxL2p+f1KBggxqVtoamfDon3sNNeIhK1BlvNO36s89QapbVEoGNB8ZB ffty3dHZgldJHkB2hviCb/cHClM0QTXBu+nxwbtiZXPE8/fM3voD9mN8ezXrTuWne6+y 2HkmUUm+4vcTshodih8Y9JsB9u6yCCyaN711Mj//b8qVL5jfbIupaFRCWIys7i//ua3c /byttaRgI+3RKVieuUisseg1uwmAhEZmLTVY8j7oyjGiKvlcAzt8VNbyU287uT6Fb2WT RqTA== X-Forwarded-Encrypted: i=1; AFNElJ/CLYotrKNYn8+TpbdHBlxVjOGmq2oo7SO1czW5B3PIqT/OjNbipW68mWFcMVKg0o5BPi/f7lvx5aW5gP8=@vger.kernel.org X-Gm-Message-State: AOJu0YxZAejoUyGyUqpl8QLRV94Hw+AiqgJpS2AJ33qW5epwIyCvZn6u 9lNwKLrICjXMwpMXlHt3OBOf2NTqQ57Lp2hcf1lLa4SuoOyyKQ47vL7IKhiFFG3PEBg= X-Gm-Gg: Acq92OFLBZH/LTvn1cm58pNpQf0mQpbk7Q7gRX3Wb4IKU+50Gba1K76S4Sn6din66hA qlI0UN/nLFDN+x7OcKpT584KhXzenYs+2JmSuJlVd56sVEdL1uZMSWfgSGnSBpitBgxVVdc7UCV Gjk08Z0fimhEHCfIfc9k4Q8Z5NSbYaNns84FJxoGylx23lxKUTvd0k2u/g+SklJdziHOPoMMdIq k0hOzafooVSZvNCyTflNC54SAa3Zrfyf1eacxYfdgRqopy2krPoqSA1W5skG/fs/Iysih8S8YPs cEMRIvild4hch9d9DODKDP25WdMBz+jIq0IwcWBiod5bhdxbmI9Dwle9pk7cY6FoHcXBVtA2ZQc g/RuA0m1X9iwAmydrLOPyOyO9QJ/gLTaE2FdbvftLOTdX3zmCVZbaHYx2FnUxBabcJy64F/Rcr9 wQAsOqaZVYWNr5iJxXRC8cCo8HaR6pnwX9bUCCjzyf49zJooWim1k73w== X-Received: by 2002:a05:6a00:4207:b0:842:5a8d:3036 with SMTP id d2e1a72fcca58-8434ced1de3mr1125462b3a.35.1781236786557; Thu, 11 Jun 2026 20:59:46 -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.42 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 11 Jun 2026 20:59:46 -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 07/19] mm/sparse: Move subsection_map_init() into sparse_init() Date: Fri, 12 Jun 2026 11:58:51 +0800 Message-ID: <20260612035903.2468601-8-songmuchun@bytedance.com> X-Mailer: git-send-email 2.54.0 In-Reply-To: <20260612035903.2468601-1-songmuchun@bytedance.com> References: <20260612035903.2468601-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 subsection_map_init() is part of sparse memory initialization, but it is currently called from free_area_init(). Move it into sparse_init() so the sparse-specific setup stays together instead of being split across the generic free_area_init() path. Signed-off-by: Muchun Song Acked-by: Mike Rapoport (Microsoft) Acked-by: Oscar Salvador --- mm/internal.h | 5 ++--- mm/mm_init.c | 10 ++-------- mm/sparse-vmemmap.c | 11 ++++++++++- mm/sparse.c | 1 + 4 files changed, 15 insertions(+), 12 deletions(-) diff --git a/mm/internal.h b/mm/internal.h index 181e79f1d6a2..dccd4727de46 100644 --- a/mm/internal.h +++ b/mm/internal.h @@ -994,10 +994,9 @@ static inline void sparse_init(void) {} * mm/sparse-vmemmap.c */ #ifdef CONFIG_SPARSEMEM_VMEMMAP -void sparse_init_subsection_map(unsigned long pfn, unsigned long nr_pages); +void sparse_init_subsection_map(void); #else -static inline void sparse_init_subsection_map(unsigned long pfn, - unsigned long nr_pages) +static inline void sparse_init_subsection_map(void) { } #endif /* CONFIG_SPARSEMEM_VMEMMAP */ diff --git a/mm/mm_init.c b/mm/mm_init.c index 5c7359693ba2..dbcd60a38c49 100644 --- a/mm/mm_init.c +++ b/mm/mm_init.c @@ -1864,18 +1864,12 @@ static void __init free_area_init(void) (u64)zone_movable_pfn[i] << PAGE_SHIFT); } - /* - * Print out the early node map, and initialize the - * subsection-map relative to active online memory ranges to - * enable future "sub-section" extensions of the memory map. - */ + /* Print out the early node map. */ pr_info("Early memory node ranges\n"); - for_each_mem_pfn_range(i, MAX_NUMNODES, &start_pfn, &end_pfn, &nid) { + for_each_mem_pfn_range(i, MAX_NUMNODES, &start_pfn, &end_pfn, &nid) pr_info(" node %3d: [mem %#018Lx-%#018Lx]\n", nid, (u64)start_pfn << PAGE_SHIFT, ((u64)end_pfn << PAGE_SHIFT) - 1); - sparse_init_subsection_map(start_pfn, end_pfn - start_pfn); - } /* Initialise every node */ mminit_verify_pageflags_layout(); diff --git a/mm/sparse-vmemmap.c b/mm/sparse-vmemmap.c index 6e09000ed3e1..0b4019a93188 100644 --- a/mm/sparse-vmemmap.c +++ b/mm/sparse-vmemmap.c @@ -601,7 +601,7 @@ static void subsection_mask_set(unsigned long *map, unsigned long pfn, bitmap_set(map, idx, end - idx + 1); } -void __init sparse_init_subsection_map(unsigned long pfn, unsigned long nr_pages) +static void __init sparse_init_subsection_map_range(unsigned long pfn, unsigned long nr_pages) { int end_sec_nr = pfn_to_section_nr(pfn + nr_pages - 1); unsigned long nr, start_sec_nr = pfn_to_section_nr(pfn); @@ -624,6 +624,15 @@ void __init sparse_init_subsection_map(unsigned long pfn, unsigned long nr_pages } } +void __init sparse_init_subsection_map(void) +{ + int i, nid; + unsigned long start, end; + + for_each_mem_pfn_range(i, MAX_NUMNODES, &start, &end, &nid) + sparse_init_subsection_map_range(start, end - start); +} + #ifdef CONFIG_MEMORY_HOTPLUG /* Mark all memory sections within the pfn range as online */ diff --git a/mm/sparse.c b/mm/sparse.c index c92bbc3f3aa3..85557ef387c7 100644 --- a/mm/sparse.c +++ b/mm/sparse.c @@ -361,5 +361,6 @@ void __init sparse_init(void) } /* cover the last node */ sparse_init_nid(nid_begin, pnum_begin, pnum_end, map_count); + sparse_init_subsection_map(); vmemmap_populate_print_last(); } -- 2.54.0