File Index
Files and directories
Sign in
FILE

bootmem_info.h

File preview with syntax highlighting.

linux-6.19.14/include/linux/bootmem_info.h C
 1/* SPDX-License-Identifier: GPL-2.0 */
 2#ifndef __LINUX_BOOTMEM_INFO_H
 3#define __LINUX_BOOTMEM_INFO_H
 4
 5#include <linux/mm.h>
 6#include <linux/kmemleak.h>
 7
 8/*
 9 * Types for free bootmem stored in the low bits of page->private.
10 */
11enum bootmem_type {
12	MEMORY_HOTPLUG_MIN_BOOTMEM_TYPE = 1,
13	SECTION_INFO = MEMORY_HOTPLUG_MIN_BOOTMEM_TYPE,
14	MIX_SECTION_INFO,
15	NODE_INFO,
16	MEMORY_HOTPLUG_MAX_BOOTMEM_TYPE = NODE_INFO,
17};
18
19#ifdef CONFIG_HAVE_BOOTMEM_INFO_NODE
20void __init register_page_bootmem_info_node(struct pglist_data *pgdat);
21void register_page_bootmem_memmap(unsigned long section_nr, struct page *map,
22				  unsigned long nr_pages);
23
24void get_page_bootmem(unsigned long info, struct page *page,
25		enum bootmem_type type);
26void put_page_bootmem(struct page *page);
27
28static inline enum bootmem_type bootmem_type(const struct page *page)
29{
30	return (unsigned long)page->private & 0xf;
31}
32
33static inline unsigned long bootmem_info(const struct page *page)
34{
35	return (unsigned long)page->private >> 4;
36}
37
38/*
39 * Any memory allocated via the memblock allocator and not via the
40 * buddy will be marked reserved already in the memmap. For those
41 * pages, we can call this function to free it to buddy allocator.
42 */
43static inline void free_bootmem_page(struct page *page)
44{
45	enum bootmem_type type = bootmem_type(page);
46
47	/*
48	 * The reserve_bootmem_region sets the reserved flag on bootmem
49	 * pages.
50	 */
51	VM_BUG_ON_PAGE(page_ref_count(page) != 2, page);
52
53	if (type == SECTION_INFO || type == MIX_SECTION_INFO)
54		put_page_bootmem(page);
55	else
56		VM_BUG_ON_PAGE(1, page);
57}
58#else
59static inline void register_page_bootmem_info_node(struct pglist_data *pgdat)
60{
61}
62
63static inline void register_page_bootmem_memmap(unsigned long section_nr,
64		struct page *map, unsigned long nr_pages)
65{
66}
67
68static inline void put_page_bootmem(struct page *page)
69{
70}
71
72static inline enum bootmem_type bootmem_type(const struct page *page)
73{
74	return SECTION_INFO;
75}
76
77static inline unsigned long bootmem_info(const struct page *page)
78{
79	return 0;
80}
81
82static inline void get_page_bootmem(unsigned long info, struct page *page,
83				    enum bootmem_type type)
84{
85}
86
87static inline void free_bootmem_page(struct page *page)
88{
89	kmemleak_free_part_phys(PFN_PHYS(page_to_pfn(page)), PAGE_SIZE);
90	free_reserved_page(page);
91}
92#endif
93
94#endif /* __LINUX_BOOTMEM_INFO_H */
~/ Read-only file preview.