Re: [PATCH] PM: hibernate: skip offline memory in mark_free_pages()
From: David Hildenbrand (Arm)
Date: Tue Oct 13 2026 - 03:06:00 EST
On 10/6/26 14:58, Yogesh Gaur wrote:
> mark_free_pages() walks every valid PFN of a zone and calls page_zone()
> on its struct page. A PFN in an offlined memory block is still valid,
> but its memmap is no longer initialised: offlining poisons it. With
> CONFIG_DEBUG_VM that is caught on the first such page:
>
> page:ffffea0005400000 is uninitialized and poisoned
> page dumped because: VM_BUG_ON_PAGE(PagePoisoned(page))
> kernel BUG at ./include/linux/mm.h:2402!
> RIP: 0010:mark_free_pages+0x49a/0x4b0 kernel/power/snapshot.c:1266
> count_data_pages kernel/power/snapshot.c:1417 [inline]
> hibernate_preallocate_memory+0x14f/0x750 kernel/power/snapshot.c:1859
> hibernation_snapshot+0xd5/0x3d0 kernel/power/hibernate.c:416
> hibernate+0x28f/0x680 kernel/power/hibernate.c:813
>
> syzbot's reproducer offlines memory42 and then writes "disk" to
> /sys/power/state; that page is the first one of memory42. Without
> CONFIG_DEBUG_VM the walk reads stale page flags instead.
>
> saveable_page() and saveable_highmem_page() already use
> pfn_to_online_page() for this since commit 5b56db37218e ("PM/Hibernate:
> use pfn_to_online_page()"). Do the same here. Offline pages are never
> on a free list, so the second loop in this function does not need it.
>
> Fixes: d33695b16a9f ("mm/memory_hotplug: poison memmap in remove_pfn_range_from_zone()")
That's very likely the wrong commit. Memory that was added but never onlined similarly
has garbage in its memmap.
Like similar commits, this should likely be
Fixes: f1dd2cd13c4b ("mm, memory_hotplug: do not associate hotadded memory to zones until online")
--
Cheers,
David