linux/mm/sparse.h
David Hildenbrand (Arm) 0632840dba mm/sparse: remove flags parameter from sparse_init_one_section()
The last user of the flags parameter that used to pass SECTION_IS_EARLY
was removed, so let's remove the parameter.

Link: https://lore.kernel.org/20260921-b4-sparsemem_cleanups-v2-11-54d81d65e125@kernel.org
Signed-off-by: David Hildenbrand (Arm) <david@kernel.org>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Acked-by: Oscar Salvador <osalvador@suse.de>
Reviewed-by: Lorenzo Stoakes (ARM) <ljs@kernel.org>
Reviewed-by: Mike Rapoport (Microsoft) <rppt@kernel.org>
Cc: Liam R. Howlett <liam@infradead.org>
Cc: Vlastimil Babka <vbabka@kernel.org>
Cc: Suren Baghdasaryan <surenb@google.com>
Cc: Michal Hocko <mhocko@suse.com>
Cc: Kairui Song <kasong@tencent.com>
Cc: Qi Zheng <qi.zheng@linux.dev>
Cc: Shakeel Butt <shakeel.butt@linux.dev>
Cc: Barry Song <baohua@kernel.org>
Cc: Axel Rasmussen <axelrasmussen@google.com>
Cc: Yuanchu Xie <yuanchu@google.com>
Cc: Wei Xu <weixugc@google.com>
Cc: Baoquan He <baoquan.he@linux.dev>
Cc: Baolin Wang <baolin.wang@linux.alibaba.com>
Cc: Brendan Jackman <brendan.jackman@linux.dev>
Cc: Johannes Weiner <hannes@cmpxchg.org>
Cc: Zi Yan <ziy@nvidia.com>
Cc: Jan Kiszka <jan.kiszka@siemens.com>
Cc: Kieran Bingham <kbingham@kernel.org>
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Cc: Rafael J. Wysocki <rafael@kernel.org>
Cc: Danilo Krummrich <dakr@kernel.org>
2026-10-24 01:56:09 -07:00

74 lines
2.0 KiB
C

/* 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 <linux/mmzone.h>
#include <linux/vmemmap-optimization.h>
/*
* mm/sparse.c
*/
#ifdef CONFIG_SPARSEMEM
void sparse_init(void);
void sparse_sections_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 section_nr, struct page *mem_map,
struct mem_section_usage *usage)
{
unsigned long coded_mem_map;
BUILD_BUG_ON(SECTION_MAP_LAST_BIT > PFN_SECTION_SHIFT);
VM_WARN_ON_ONCE(section_nr > __highest_used_section_nr);
/*
* 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(section_nr));
VM_WARN_ON_ONCE(coded_mem_map & ~SECTION_MAP_MASK);
ms->section_mem_map &= ~SECTION_MAP_MASK;
ms->section_mem_map |= coded_mem_map | SECTION_HAS_MEM_MAP;
ms->usage = usage;
}
static inline size_t mem_section_usage_size(void)
{
return struct_size_t(struct mem_section_usage, pageblock_flags,
BITS_TO_LONGS(SECTION_BLOCKFLAGS_BITS));
}
static inline bool section_vmemmap_optimizable(const struct mem_section *ms)
{
return vmemmap_optimizable_order(section_compound_order(ms));
}
#else
static inline void sparse_init(void) {}
static inline void sparse_sections_init(void) {}
#endif /* CONFIG_SPARSEMEM */
/*
* mm/sparse-vmemmap.c
*/
#ifdef CONFIG_SPARSEMEM_VMEMMAP
void sparse_init_subsection_map(void);
int section_nr_vmemmap_pages(unsigned long pfn, unsigned long nr_pages);
#else
static inline void sparse_init_subsection_map(void) {}
static inline int section_nr_vmemmap_pages(unsigned long pfn, unsigned long nr_pages)
{
return DIV_ROUND_UP(nr_pages * sizeof(struct page), PAGE_SIZE);
}
#endif /* CONFIG_SPARSEMEM_VMEMMAP */
#endif /* __MM_SPARSE_H */