Re: [PATCH v2 1/1] mm: page_alloc: skip over regions of invalid pfns on UMA

From: Matthew Wilcox
Date: Sun Jan 21 2018 - 20:23:09 EST



I like the patch. I think it could be better.

> +++ b/mm/page_alloc.c
> @@ -5344,7 +5344,7 @@ void __meminit memmap_init_zone(unsigned long size, int nid, unsigned long zone,
> goto not_early;
>
> if (!early_pfn_valid(pfn)) {
> -#ifdef CONFIG_HAVE_MEMBLOCK_NODE_MAP
> +#ifdef CONFIG_HAVE_MEMBLOCK
> /*
> * Skip to the pfn preceding the next valid one (or
> * end_pfn), such that we hit a valid pfn (or end_pfn)

This ifdef makes me sad. Here's more of the context:

if (!early_pfn_valid(pfn)) {
#ifdef CONFIG_HAVE_MEMBLOCK_NODE_MAP
/*
* Skip to the pfn preceding the next valid one (or
* end_pfn), such that we hit a valid pfn (or end_pfn)
* on our next iteration of the loop.
*/
pfn = memblock_next_valid_pfn(pfn, end_pfn) - 1;
#endif
continue;
}

This is crying out for:

#ifdef CONFIG_HAVE_MEMBLOCK
unsigned long memblock_next_valid_pfn(unsigned long pfn, unsigned long max_pfn);
#else
static inline unsigned long memblock_next_valid_pfn(unsigned long pfn,
unsigned long max_pfn)
{
return pfn + 1;
}
#endif

in a header file somewhere.