On 4/12/23 14:16, Baolin Wang wrote: > > > On 4/12/2023 7:25 PM, David Hildenbrand wrote: >> On 12.04.23 12:45, Baolin Wang wrote: >>> Now the __pageblock_pfn_to_page() is used by set_zone_contiguous(), >>> which checks whether the given zone contains holes, and uses pfn_valid() >>> to check if the end pfn is valid. However pfn_valid() can not make sure >>> the end pfn is not a hole if the size of a pageblock is larger than the >>> size of a sub-mem_section, since the struct page getting by pfn_to_page() >>> may represent a hole or an unusable page frame, which may cause incorrect >>> zone contiguous is set. >>> >>> Though another user of pageblock_pfn_to_page() in compaction seems work >>> well now, it is better to avoid scanning or touching these offline pfns. >>> So like commit 2d070eab2e82 ("mm: consider zone which is not fully >>> populated to have holes"), we should also use pfn_to_online_page() for >>> the end pfn to make sure it is a valid pfn with usable page frame. >>> Meanwhile the pfn_valid() for end pfn can be dropped now. >>> >>> Moreover we've already used pfn_to_online_page() for start pfn to make >>> sure it is online and valid, so the pfn_valid() for the start pfn is >>> unnecessary, drop it. >> >> pageblocks are supposed to fall into a single memory section, so in mos > cases, if the start is online, so is the end. > > Yes, the granularity of memory hotplug is a mem_section. > > However, suppose the pageblock order is MAX_ORDER-1, and the size of a > sub-section is 2M, that means a pageblock will fall into 2 sub > mem-section, and if there is a hole in the zone, that means the 2nd sub > mem-section can be invalid without setting subsection_map bitmap. Can that really happen? I think the buddy merging in __free_one_page() would trip on that?