summaryrefslogtreecommitdiff
path: root/include/linux/bootmem_info.h
diff options
context:
space:
mode:
Diffstat (limited to 'include/linux/bootmem_info.h')
-rw-r--r--include/linux/bootmem_info.h28
1 files changed, 27 insertions, 1 deletions
diff --git a/include/linux/bootmem_info.h b/include/linux/bootmem_info.h
index 4ed6dee1adc9..2bc8b1f69c93 100644
--- a/include/linux/bootmem_info.h
+++ b/include/linux/bootmem_info.h
@@ -2,7 +2,7 @@
#ifndef __LINUX_BOOTMEM_INFO_H
#define __LINUX_BOOTMEM_INFO_H
-#include <linux/mmzone.h>
+#include <linux/mm.h>
/*
* Types for free bootmem stored in page->lru.next. These have to be in
@@ -22,6 +22,27 @@ void __init register_page_bootmem_info_node(struct pglist_data *pgdat);
void get_page_bootmem(unsigned long info, struct page *page,
unsigned long type);
void put_page_bootmem(struct page *page);
+
+/*
+ * Any memory allocated via the memblock allocator and not via the
+ * buddy will be marked reserved already in the memmap. For those
+ * pages, we can call this function to free it to buddy allocator.
+ */
+static inline void free_bootmem_page(struct page *page)
+{
+ unsigned long magic = (unsigned long)page->freelist;
+
+ /*
+ * The reserve_bootmem_region sets the reserved flag on bootmem
+ * pages.
+ */
+ VM_BUG_ON_PAGE(page_ref_count(page) != 2, page);
+
+ if (magic == SECTION_INFO || magic == MIX_SECTION_INFO)
+ put_page_bootmem(page);
+ else
+ VM_BUG_ON_PAGE(1, page);
+}
#else
static inline void register_page_bootmem_info_node(struct pglist_data *pgdat)
{
@@ -35,6 +56,11 @@ static inline void get_page_bootmem(unsigned long info, struct page *page,
unsigned long type)
{
}
+
+static inline void free_bootmem_page(struct page *page)
+{
+ free_reserved_page(page);
+}
#endif
#endif /* __LINUX_BOOTMEM_INFO_H */