Commit | Line | Data |
---|---|---|
426e5c42 MS |
1 | /* SPDX-License-Identifier: GPL-2.0 */ |
2 | #ifndef __LINUX_BOOTMEM_INFO_H | |
3 | #define __LINUX_BOOTMEM_INFO_H | |
4 | ||
f41f2ed4 | 5 | #include <linux/mm.h> |
028725e7 | 6 | #include <linux/kmemleak.h> |
426e5c42 MS |
7 | |
8 | /* | |
9 | * Types for free bootmem stored in page->lru.next. These have to be in | |
10 | * some random range in unsigned long space for debugging purposes. | |
11 | */ | |
12 | enum { | |
13 | MEMORY_HOTPLUG_MIN_BOOTMEM_TYPE = 12, | |
14 | SECTION_INFO = MEMORY_HOTPLUG_MIN_BOOTMEM_TYPE, | |
15 | MIX_SECTION_INFO, | |
16 | NODE_INFO, | |
17 | MEMORY_HOTPLUG_MAX_BOOTMEM_TYPE = NODE_INFO, | |
18 | }; | |
19 | ||
20 | #ifdef CONFIG_HAVE_BOOTMEM_INFO_NODE | |
21 | void __init register_page_bootmem_info_node(struct pglist_data *pgdat); | |
22 | ||
23 | void get_page_bootmem(unsigned long info, struct page *page, | |
24 | unsigned long type); | |
25 | void put_page_bootmem(struct page *page); | |
f41f2ed4 MS |
26 | |
27 | /* | |
28 | * Any memory allocated via the memblock allocator and not via the | |
29 | * buddy will be marked reserved already in the memmap. For those | |
30 | * pages, we can call this function to free it to buddy allocator. | |
31 | */ | |
32 | static inline void free_bootmem_page(struct page *page) | |
33 | { | |
c5e97ed1 | 34 | unsigned long magic = page->index; |
f41f2ed4 MS |
35 | |
36 | /* | |
37 | * The reserve_bootmem_region sets the reserved flag on bootmem | |
38 | * pages. | |
39 | */ | |
40 | VM_BUG_ON_PAGE(page_ref_count(page) != 2, page); | |
41 | ||
42 | if (magic == SECTION_INFO || magic == MIX_SECTION_INFO) | |
43 | put_page_bootmem(page); | |
44 | else | |
45 | VM_BUG_ON_PAGE(1, page); | |
46 | } | |
426e5c42 MS |
47 | #else |
48 | static inline void register_page_bootmem_info_node(struct pglist_data *pgdat) | |
49 | { | |
50 | } | |
51 | ||
52 | static inline void put_page_bootmem(struct page *page) | |
53 | { | |
54 | } | |
55 | ||
56 | static inline void get_page_bootmem(unsigned long info, struct page *page, | |
57 | unsigned long type) | |
58 | { | |
59 | } | |
f41f2ed4 MS |
60 | |
61 | static inline void free_bootmem_page(struct page *page) | |
62 | { | |
028725e7 | 63 | kmemleak_free_part(page_to_virt(page), PAGE_SIZE); |
f41f2ed4 MS |
64 | free_reserved_page(page); |
65 | } | |
426e5c42 MS |
66 | #endif |
67 | ||
68 | #endif /* __LINUX_BOOTMEM_INFO_H */ |