Re: [PATCH v7 1/1] mm/page_alloc.c: refactor initialization of struct page for holes in memory layout

From: Vlastimil Babka
Date: Thu Feb 25 2021 - 13:41:45 EST


On 2/25/21 7:05 PM, Mike Rapoport wrote:
> On Thu, Feb 25, 2021 at 06:51:53PM +0100, Vlastimil Babka wrote:
>> >
>> > unset zone link in struct page will trigger
>> >
>> > VM_BUG_ON_PAGE(!zone_spans_pfn(page_zone(page), pfn), page);
>>
>> ... in set_pfnblock_flags_mask() when called with a struct page from the
>> "Unknown E820 type" range.
>
> "... in set_pfnblock_flags_mask() when called with a struct page from a range
> other than E820_TYPE_RAM"
>
> then :)

Better :)

>> > because there are pages in both ZONE_DMA32 and ZONE_DMA (unset zone link
>> > in struct page) in the same pageblock.
>>
>> I would say "there are apparently pages" ... "and ZONE_DMA does not span this range"
>
> I'd rephrase it differently, something like
>
> "because there are pages in the range of ZONE_DMA32 but the unset zone link
> in struct page makes them appear as a part of ZONE_DMA"

Much better, thanks!

>> > Interleave initialization of the unavailable pages with the normal
>> > initialization of memory map, so that zone and node information will be
>> > properly set on struct pages that are not backed by the actual memory.
>> >
>> > With this change the pages for holes inside a zone will get proper
>> > zone/node links and the pages that are not spanned by any node will get
>> > links to the adjacent zone/node.
>>
>> What if two zones are adjacent? I.e. if the hole was at a boundary between two
>> zones.
>
> What do you mean by "adjacent zones"? If there is a hole near the zone
> boundary, zone span would be clamped to exclude the hole.

Yeah, zone span should exclude those pages, but you still somehow handle them?
That's how I read "pages that are not spanned by any node will get links to the
adjacent zone/node."
So is it always a unique zone/node can be determined?

Let's say we have:

<memory on node 0>
---- pageblock boundary ----
<more memory on node 0>
<a hole>
<memory on node 1>
---- pageblock boundary ----

Now I hope such configurations don't really exist :) But if we simulated them in
QEMU, what would be the linkage in struct pages in that hole?