/* RETURNS: Pointer to temp pages array on success, NULL on failure.  */
static struct page** pcpu_get_pages_and_bitmap(struct pcpu_chunk *chunk, unsigned long **bitmapp, bool may_alloc)
/* RETURNS: Pointer to temp pages array on success, NULL on failure.  */
static struct page** pcpu_get_pages_and_bitmap(struct pcpu_chunk *chunk, unsigned long **bitmapp, bool may_alloc)
{
	static struct page **pages;
	static unsigned long *bitmap;
	size_t pages_size = pcpu_nr_units * pcpu_unit_pages * sizeof(pages[0]);
	size_t bitmap_size = BITS_TO_LONGS(pcpu_unit_pages) *
			     sizeof(unsigned long);
	if (!pages || !bitmap) {
		if (may_alloc && !pages)
			pages = pcpu_mem_alloc(pages_size);
		if (may_alloc && !bitmap)
			bitmap = pcpu_mem_alloc(bitmap_size);
		if (!pages || !bitmap)
			return NULL;
	}
	memset(pages, 0, pages_size);
	bitmap_copy(bitmap, chunk->populated, pcpu_unit_pages);
	*bitmapp = bitmap;
	return pages;
}