1 /* SPDX-License-Identifier: GPL-2.0 */
2 #ifndef __LINUX_BOOTMEM_INFO_H
3 #define __LINUX_BOOTMEM_INFO_H
6 #include <linux/kmemleak.h>
9 * Types for free bootmem stored in the low bits of page->private.
12 MEMORY_HOTPLUG_MIN_BOOTMEM_TYPE
= 1,
13 SECTION_INFO
= MEMORY_HOTPLUG_MIN_BOOTMEM_TYPE
,
16 MEMORY_HOTPLUG_MAX_BOOTMEM_TYPE
= NODE_INFO
,
19 #ifdef CONFIG_HAVE_BOOTMEM_INFO_NODE
20 void __init
register_page_bootmem_info_node(struct pglist_data
*pgdat
);
22 void get_page_bootmem(unsigned long info
, struct page
*page
,
23 enum bootmem_type type
);
24 void put_page_bootmem(struct page
*page
);
26 static inline enum bootmem_type
bootmem_type(const struct page
*page
)
28 return (unsigned long)page
->private & 0xf;
31 static inline unsigned long bootmem_info(const struct page
*page
)
33 return (unsigned long)page
->private >> 4;
37 * Any memory allocated via the memblock allocator and not via the
38 * buddy will be marked reserved already in the memmap. For those
39 * pages, we can call this function to free it to buddy allocator.
41 static inline void free_bootmem_page(struct page
*page
)
43 enum bootmem_type type
= bootmem_type(page
);
46 * The reserve_bootmem_region sets the reserved flag on bootmem
49 VM_BUG_ON_PAGE(page_ref_count(page
) != 2, page
);
51 if (type
== SECTION_INFO
|| type
== MIX_SECTION_INFO
)
52 put_page_bootmem(page
);
54 VM_BUG_ON_PAGE(1, page
);
57 static inline void register_page_bootmem_info_node(struct pglist_data
*pgdat
)
61 static inline void put_page_bootmem(struct page
*page
)
65 static inline enum bootmem_type
bootmem_type(const struct page
*page
)
70 static inline unsigned long bootmem_info(const struct page
*page
)
75 static inline void get_page_bootmem(unsigned long info
, struct page
*page
,
76 enum bootmem_type type
)
80 static inline void free_bootmem_page(struct page
*page
)
82 kmemleak_free_part_phys(PFN_PHYS(page_to_pfn(page
)), PAGE_SIZE
);
83 free_reserved_page(page
);
87 #endif /* __LINUX_BOOTMEM_INFO_H */