Merge tag 'kgdb-6.7-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/danielt...
[linux-2.6-microblaze.git] / include / linux / bootmem_info.h
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 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);
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 {
34         unsigned long magic = page->index;
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 }
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 }
60
61 static inline void free_bootmem_page(struct page *page)
62 {
63         kmemleak_free_part_phys(PFN_PHYS(page_to_pfn(page)), PAGE_SIZE);
64         free_reserved_page(page);
65 }
66 #endif
67
68 #endif /* __LINUX_BOOTMEM_INFO_H */