Skip to contentSkip to conversation

mm/page_alloc: add alloc_contig_pages()

PATCH In review [email protected] 1 participant 1 message Dec 1, 2019

Subsystems (4)
lore
Share & tools
lore

[email protected]

author maintainer
#0 lore raw

PATCH 97/158 mm/page_alloc: add alloc_contig_pages()

From: Anshuman Khandual <[email protected]>
Subject: mm/page_alloc: add alloc_contig_pages()

HugeTLB helper alloc_gigantic_page() implements fairly generic allocation method where it scans over various zones looking for a large contiguous pfn range before trying to allocate it with alloc_contig_range(). Other than deriving the requested order from 'struct hstate', there is nothing HugeTLB specific in there. This can be made available for general use to allocate contiguous memory which could not have been allocated through the buddy allocator.

alloc_gigantic_page() has been split carving out actual allocation method which is then made available via new alloc_contig_pages() helper wrapped under CONFIG_CONTIG_ALLOC. All references to 'gigantic' have been replaced with more generic term 'contig'. Allocated pages here should be freed with free_contig_range() or by calling __free_page() on each allocated page.

Cc Mike Kravetz <[email protected]>
Cc Vlastimil Babka <[email protected]>
Cc Michal Hocko <[email protected]>
Cc David Rientjes <[email protected]>
Cc Andrea Arcangeli <[email protected]>
Cc Oscar Salvador <[email protected]>
Cc Mel Gorman <[email protected]>
Cc Mike Rapoport <[email protected]>
Cc Dan Williams <[email protected]>
Cc Pavel Tatashin <[email protected]>
Cc Matthew Wilcox <[email protected]>
Cc David Hildenbrand <[email protected]>

---

 include/linux/gfp.h |    2 
 mm/hugetlb.c        |   77 --------------------------------
 mm/page_alloc.c     |  101 ++++++++++++++++++++++++++++++++++++++++++
 3 files changed, 105 insertions(+), 75 deletions(-)
include/linux/gfp.h renamed from include/linux/gfp.h~mm-page_alloc-add-alloc_contig_pages +2 -0
@@ -612,6 +612,8 @@ static inline bool pm_suspended_storage(
 /* The below functions must be run on a range from a single zone. */
 extern int alloc_contig_range(unsigned long start, unsigned long end,
 			      unsigned migratetype, gfp_t gfp_mask);
+extern struct page *alloc_contig_pages(unsigned long nr_pages, gfp_t gfp_mask,
+				       int nid, nodemask_t *nodemask);
 #endif
 void free_contig_range(unsigned long pfn, unsigned int nr_pages);
 
mm/hugetlb.c renamed from mm/hugetlb.c~mm-page_alloc-add-alloc_contig_pages +2 -75

87 lines not on this page · raw message

mm/page_alloc.c renamed from mm/page_alloc.c~mm-page_alloc-add-alloc_contig_pages +101 -0

107 lines not on this page · raw message

_