Re: [PATCH] mm: fix panic in __alloc_pages

From: Matthew Wilcox
Date: Mon Nov 01 2021 - 16:41:06 EST


On Mon, Nov 01, 2021 at 01:13:12PM -0700, Alexey Makhalov wrote:
> +++ b/include/linux/gfp.h
> @@ -551,7 +551,8 @@ alloc_pages_bulk_array(gfp_t gfp, unsigned long nr_pages, struct page **page_arr
> static inline unsigned long
> alloc_pages_bulk_array_node(gfp_t gfp, int nid, unsigned long nr_pages, struct page **page_array)
> {
> - if (nid == NUMA_NO_NODE)
> + if (nid == NUMA_NO_NODE || (!node_online(nid) &&
> + !(gfp & __GFP_THISNODE)))
> nid = numa_mem_id();
>
> return __alloc_pages_bulk(gfp, nid, NULL, nr_pages, NULL, page_array);

I don't think it's a great idea to push node_online() and the gfp check
into the caller. Can't we put this check in __alloc_pages_bulk() instead?