printf: Remove unused 'bprintf'
[drm/drm-misc.git] / include / linux / bootmem_info.h
blobd8a8d245824a264c6c7a47c111fb0617ededeaf5
1 /* SPDX-License-Identifier: GPL-2.0 */
2 #ifndef __LINUX_BOOTMEM_INFO_H
3 #define __LINUX_BOOTMEM_INFO_H
5 #include <linux/mm.h>
6 #include <linux/kmemleak.h>
8 /*
9 * Types for free bootmem stored in the low bits of page->private.
11 enum 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,
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
47 * pages.
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);
53 else
54 VM_BUG_ON_PAGE(1, page);
56 #else
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)
67 return SECTION_INFO;
70 static inline unsigned long bootmem_info(const struct page *page)
72 return 0;
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);
85 #endif
87 #endif /* __LINUX_BOOTMEM_INFO_H */