linux-loongson/include/linux/bootmem_info.h
Frank van der Linden 243a75e236 mm/bootmem_info: export register_page_bootmem_memmap
If other mm code wants to use this function for early memmap inialization
(on the platforms that have it), it should be made available properly, not
just unconditionally in mm.h

Make this function available for such cases.

Link: https://lkml.kernel.org/r/20250228182928.2645936-10-fvdl@google.com
Signed-off-by: Frank van der Linden <fvdl@google.com>
Cc: Alexander Gordeev <agordeev@linux.ibm.com>
Cc: Andy Lutomirski <luto@kernel.org>
Cc: Arnd Bergmann <arnd@arndb.de>
Cc: Dan Carpenter <dan.carpenter@linaro.org>
Cc: Dave Hansen <dave.hansen@linux.intel.com>
Cc: David Hildenbrand <david@redhat.com>
Cc: Heiko Carstens <hca@linux.ibm.com>
Cc: Joao Martins <joao.m.martins@oracle.com>
Cc: Johannes Weiner <hannes@cmpxchg.org>
Cc: Madhavan Srinivasan <maddy@linux.ibm.com>
Cc: Michael Ellerman <mpe@ellerman.id.au>
Cc: Muchun Song <muchun.song@linux.dev>
Cc: Oscar Salvador <osalvador@suse.de>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Roman Gushchin (Cruise) <roman.gushchin@linux.dev>
Cc: Usama Arif <usamaarif642@gmail.com>
Cc: Vasily Gorbik <gor@linux.ibm.com>
Cc: Yu Zhao <yuzhao@google.com>
Cc: Zi Yan <ziy@nvidia.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
2025-03-16 22:06:27 -07:00

95 lines
2.3 KiB
C

/* SPDX-License-Identifier: GPL-2.0 */
#ifndef __LINUX_BOOTMEM_INFO_H
#define __LINUX_BOOTMEM_INFO_H
#include <linux/mm.h>
#include <linux/kmemleak.h>
/*
* Types for free bootmem stored in the low bits of page->private.
*/
enum bootmem_type {
MEMORY_HOTPLUG_MIN_BOOTMEM_TYPE = 1,
SECTION_INFO = MEMORY_HOTPLUG_MIN_BOOTMEM_TYPE,
MIX_SECTION_INFO,
NODE_INFO,
MEMORY_HOTPLUG_MAX_BOOTMEM_TYPE = NODE_INFO,
};
#ifdef CONFIG_HAVE_BOOTMEM_INFO_NODE
void __init register_page_bootmem_info_node(struct pglist_data *pgdat);
void register_page_bootmem_memmap(unsigned long section_nr, struct page *map,
unsigned long nr_pages);
void get_page_bootmem(unsigned long info, struct page *page,
enum bootmem_type type);
void put_page_bootmem(struct page *page);
static inline enum bootmem_type bootmem_type(const struct page *page)
{
return (unsigned long)page->private & 0xf;
}
static inline unsigned long bootmem_info(const struct page *page)
{
return (unsigned long)page->private >> 4;
}
/*
* Any memory allocated via the memblock allocator and not via the
* buddy will be marked reserved already in the memmap. For those
* pages, we can call this function to free it to buddy allocator.
*/
static inline void free_bootmem_page(struct page *page)
{
enum bootmem_type type = bootmem_type(page);
/*
* The reserve_bootmem_region sets the reserved flag on bootmem
* pages.
*/
VM_BUG_ON_PAGE(page_ref_count(page) != 2, page);
if (type == SECTION_INFO || type == MIX_SECTION_INFO)
put_page_bootmem(page);
else
VM_BUG_ON_PAGE(1, page);
}
#else
static inline void register_page_bootmem_info_node(struct pglist_data *pgdat)
{
}
static inline void register_page_bootmem_memmap(unsigned long section_nr,
struct page *map, unsigned long nr_pages)
{
}
static inline void put_page_bootmem(struct page *page)
{
}
static inline enum bootmem_type bootmem_type(const struct page *page)
{
return SECTION_INFO;
}
static inline unsigned long bootmem_info(const struct page *page)
{
return 0;
}
static inline void get_page_bootmem(unsigned long info, struct page *page,
enum bootmem_type type)
{
}
static inline void free_bootmem_page(struct page *page)
{
kmemleak_free_part_phys(PFN_PHYS(page_to_pfn(page)), PAGE_SIZE);
free_reserved_page(page);
}
#endif
#endif /* __LINUX_BOOTMEM_INFO_H */