diff --git a/mm/percpu-vm.c b/mm/percpu-vm.c index ccd03cc152d4..7ed216192fc0 100644 --- a/mm/percpu-vm.c +++ b/mm/percpu-vm.c @@ -21,7 +21,8 @@ static struct page *pcpu_chunk_page(struct pcpu_chunk *chunk, /** * pcpu_get_pages - get temp pages array - * @gfp: allocation flags passed to the underlying allocator + * @gfp: allocation flags passed to the underlying allocator, 0 to only + * return the cached array * * Returns pointer to array of pointers to struct page which can be indexed * with pcpu_page_idx(). Note that there is only one array and accesses @@ -37,11 +38,16 @@ static struct page **pcpu_get_pages(gfp_t gfp) lockdep_assert_held(&pcpu_alloc_mutex); - if (!pages) + if (!pages && gfp) pages = pcpu_mem_zalloc(pages_size, gfp); return pages; } +static struct page **pcpu_get_pages_cached(void) +{ + return pcpu_get_pages(0); +} + /** * pcpu_free_pages - free pages which were allocated for @chunk * @chunk: chunk pages were allocated for @@ -333,7 +339,7 @@ static void pcpu_depopulate_chunk(struct pcpu_chunk *chunk, * successful population attempt so the temp pages array must * be available now. */ - pages = pcpu_get_pages(GFP_KERNEL); + pages = pcpu_get_pages_cached(); BUG_ON(!pages); /* unmap and free */