From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 7DAD8C43458 for ; Thu, 9 Jul 2026 06:42:12 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:List-Subscribe:List-Help :List-Post:List-Archive:List-Unsubscribe:List-Id:Cc:To:In-Reply-To:References :Message-Id:Content-Transfer-Encoding:Content-Type:MIME-Version:Subject:Date: From:Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=lk6NZKSyfvP8qY4wirUwcY/CWU1GrxzbQKJbKa4/tds=; b=EFx3EZaXMb9BBJOFc82WasxQAt SorVP6XFsVqNF9NVtyoAoGidSDn0FnqdiJ3fw+L/7NhD1U0d0/FMNBu1EOU9brO4gD9S8frbC3p9j wzWItLzehOmTBb1iaFemb0VF7MiZUxgHg70bgO/0MUohayUW0+EaZlzOMBKXsWcw5gQZIuZPqfru+ +T0hG3q3JK1XPkiDNTZC9nnhyrgG+6eR46KiFU/rlQFQays2C4KHD5taWAekpedJhZqg3JUnrdfRV F6TJXDg4J+9Mr2L4gPPJv97Fxe4t+UsovvM8unJZH7/MBZs6ue/4FRwbHNcPE7rHf2cftiPzP3DMB 6Szl1aoA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.99.1 #2 (Red Hat Linux)) id 1whiSZ-00000001Cjm-2Q38; Thu, 09 Jul 2026 06:42:11 +0000 Received: from sea.source.kernel.org ([172.234.252.31]) by bombadil.infradead.org with esmtps (Exim 4.99.1 #2 (Red Hat Linux)) id 1whiSY-00000001CjR-1405 for kexec@lists.infradead.org; Thu, 09 Jul 2026 06:42:10 +0000 Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18]) by sea.source.kernel.org (Postfix) with ESMTP id E22BD43A64; Thu, 9 Jul 2026 06:42:09 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id DCD371F000E9; Thu, 9 Jul 2026 06:42:03 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1783579329; bh=lk6NZKSyfvP8qY4wirUwcY/CWU1GrxzbQKJbKa4/tds=; h=From:Date:Subject:References:In-Reply-To:To:Cc; b=EpKq0rX7j2v6MtATxB+UWMtaxum0UBPfNHtUKOFC6l3Y+pu8mEO5XvDRFxYNOuXIx RgZnflhXOiREfmPzwGfxsAH2d/iTNnT/BBdI3fEy9hVir3o24KZf1HcwfRQyG9vFmX BOZ3npTlhD3nJ0Y95D0UtoS+w9nfKqcLqSyp3V208hVS2G2ptal4MazxYphmbe5QwQ luIJYN1vnMUvGcVXhbejBGv6I4lT8IzswgZHIfqHDqlIO0XmnQbfZ7VCnScInGMu4t UqmbLTJ+whhhgTL001YHj8fRCuVoRLmWqFQnh81hmVUD6EIvTpaDzuNpd2+srIQGdG nsJI0BA+SOTiA== From: "Mike Rapoport (Microsoft)" Date: Thu, 09 Jul 2026 09:41:48 +0300 Subject: [PATCH 2/3] mm: split out sparse declarations from internal.h MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit Message-Id: <20260709-internal-h-v1-2-956d5092782d@kernel.org> References: <20260709-internal-h-v1-0-956d5092782d@kernel.org> In-Reply-To: <20260709-internal-h-v1-0-956d5092782d@kernel.org> To: Andrew Morton , David Hildenbrand Cc: Alexander Graf , Alexander Potapenko , Brendan Jackman , Christoph Lameter , Dennis Zhou , Dmitry Vyukov , Johannes Weiner , "Liam R. Howlett" , Lorenzo Stoakes , Marco Elver , Michal Hocko , Mike Rapoport , Muchun Song , Oscar Salvador , Pasha Tatashin , Pratyush Yadav , Suren Baghdasaryan , Tejun Heo , Uladzislau Rezki , Vlastimil Babka , Zi Yan , kasan-dev@googlegroups.com, kexec@lists.infradead.org, linux-cxl@vger.kernel.org, linux-kernel@vger.kernel.org, linux-mm@kvack.org X-Mailer: b4 0.16-dev X-BeenThere: kexec@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "kexec" Errors-To: kexec-bounces+kexec=archiver.kernel.org@lists.infradead.org mm/internal.h becomes more and more bloated. Move declarations related to SPARSE and SPARSE_VMEMMAP memory models to a new mm/sparse.h header. No functional changes. Signed-off-by: Mike Rapoport (Microsoft) --- MAINTAINERS | 1 + mm/internal.h | 52 ------------------------------------------- mm/mm_init.c | 1 + mm/sparse-vmemmap.c | 1 + mm/sparse.c | 2 ++ mm/sparse.h | 63 +++++++++++++++++++++++++++++++++++++++++++++++++++++ 6 files changed, 68 insertions(+), 52 deletions(-) diff --git a/MAINTAINERS b/MAINTAINERS index 537dbfd01362..406ccfe63974 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -16999,6 +16999,7 @@ F: mm/pgtable-generic.c F: mm/ptdump.c F: mm/sparse-vmemmap.c F: mm/sparse.c +F: mm/sparse.h F: mm/util.c F: mm/vmpressure.c F: mm/vmstat.c diff --git a/mm/internal.h b/mm/internal.h index c514b17c61b8..860cd31c3da5 100644 --- a/mm/internal.h +++ b/mm/internal.h @@ -807,58 +807,6 @@ static inline void init_compound_tail(struct page *tail, prep_compound_tail(tail, head, order); } -/* - * mm/sparse.c - */ -#ifdef CONFIG_SPARSEMEM -void sparse_init(void); -int sparse_index_init(unsigned long section_nr, int nid); - -static inline void sparse_init_one_section(struct mem_section *ms, - unsigned long pnum, struct page *mem_map, - struct mem_section_usage *usage, unsigned long flags) -{ - unsigned long coded_mem_map; - - BUILD_BUG_ON(SECTION_MAP_LAST_BIT > PFN_SECTION_SHIFT); - - /* - * We encode the start PFN of the section into the mem_map such that - * page_to_pfn() on !CONFIG_SPARSEMEM_VMEMMAP can simply subtract it - * from the page pointer to obtain the PFN. - */ - coded_mem_map = (unsigned long)(mem_map - section_nr_to_pfn(pnum)); - VM_WARN_ON_ONCE(coded_mem_map & ~SECTION_MAP_MASK); - - ms->section_mem_map &= ~SECTION_MAP_MASK; - ms->section_mem_map |= coded_mem_map; - ms->section_mem_map |= flags | SECTION_HAS_MEM_MAP; - ms->usage = usage; -} - -static inline void __section_mark_present(struct mem_section *ms, - unsigned long section_nr) -{ - if (section_nr > __highest_present_section_nr) - __highest_present_section_nr = section_nr; - - ms->section_mem_map |= SECTION_MARKED_PRESENT; -} -#else -static inline void sparse_init(void) {} -#endif /* CONFIG_SPARSEMEM */ - -/* - * mm/sparse-vmemmap.c - */ -#ifdef CONFIG_SPARSEMEM_VMEMMAP -void sparse_init_subsection_map(void); -#else -static inline void sparse_init_subsection_map(void) -{ -} -#endif /* CONFIG_SPARSEMEM_VMEMMAP */ - #if defined CONFIG_COMPACTION || defined CONFIG_CMA /* diff --git a/mm/mm_init.c b/mm/mm_init.c index 39583c028e34..b557e5fe35f3 100644 --- a/mm/mm_init.c +++ b/mm/mm_init.c @@ -35,6 +35,7 @@ #include "internal.h" #include "mm_init.h" #include "page_alloc.h" +#include "sparse.h" #include "slab.h" #include "shuffle.h" diff --git a/mm/sparse-vmemmap.c b/mm/sparse-vmemmap.c index 10dd4a9b591b..458b0b9570ff 100644 --- a/mm/sparse-vmemmap.c +++ b/mm/sparse-vmemmap.c @@ -42,6 +42,7 @@ #include "internal.h" #include "mm_init.h" +#include "sparse.h" /* * Allocate a block of memory to be used to back the virtual memory map diff --git a/mm/sparse.c b/mm/sparse.c index 058ef9300367..4b21dd8c7dfb 100644 --- a/mm/sparse.c +++ b/mm/sparse.c @@ -16,6 +16,8 @@ #include #include #include "internal.h" +#include "mm_init.h" +#include "sparse.h" #include /* diff --git a/mm/sparse.h b/mm/sparse.h new file mode 100644 index 000000000000..95aa031213f2 --- /dev/null +++ b/mm/sparse.h @@ -0,0 +1,63 @@ +/* SPDX-License-Identifier: GPL-2.0-or-later */ +/* + * sparse.h: + * + * mm/ internal sparse and sparse-vmemmap declarations + */ + +#ifndef __MM_SPARSE_H +#define __MM_SPARSE_H + +#include + +/* + * mm/sparse.c + */ +#ifdef CONFIG_SPARSEMEM +void sparse_init(void); +int sparse_index_init(unsigned long section_nr, int nid); + +static inline void sparse_init_one_section(struct mem_section *ms, + unsigned long pnum, struct page *mem_map, + struct mem_section_usage *usage, unsigned long flags) +{ + unsigned long coded_mem_map; + + BUILD_BUG_ON(SECTION_MAP_LAST_BIT > PFN_SECTION_SHIFT); + + /* + * We encode the start PFN of the section into the mem_map such that + * page_to_pfn() on !CONFIG_SPARSEMEM_VMEMMAP can simply subtract it + * from the page pointer to obtain the PFN. + */ + coded_mem_map = (unsigned long)(mem_map - section_nr_to_pfn(pnum)); + VM_WARN_ON_ONCE(coded_mem_map & ~SECTION_MAP_MASK); + + ms->section_mem_map &= ~SECTION_MAP_MASK; + ms->section_mem_map |= coded_mem_map; + ms->section_mem_map |= flags | SECTION_HAS_MEM_MAP; + ms->usage = usage; +} + +static inline void __section_mark_present(struct mem_section *ms, + unsigned long section_nr) +{ + if (section_nr > __highest_present_section_nr) + __highest_present_section_nr = section_nr; + + ms->section_mem_map |= SECTION_MARKED_PRESENT; +} +#else +static inline void sparse_init(void) {} +#endif /* CONFIG_SPARSEMEM */ + +/* + * mm/sparse-vmemmap.c + */ +#ifdef CONFIG_SPARSEMEM_VMEMMAP +void sparse_init_subsection_map(void); +#else +static inline void sparse_init_subsection_map(void) {} +#endif /* CONFIG_SPARSEMEM_VMEMMAP */ + +#endif /* __MM_SPARSE_H */ -- 2.53.0