On 14 May 2025, at 10:12, David Hildenbrand wrote: > On 14.05.25 15:45, Zi Yan wrote: >> On 14 May 2025, at 7:15, David Hildenbrand wrote: >> >>> This is a requirement for making PageOffline pages not have a refcount >>> in the long future ("frozen"), and for reworking non-folio page migration >>> in the near future. >>> >>> I have patches mostly ready to go to handle the latter. For turning all >>> PageOffline() pages frozen, the non-folio page migration and memory >>> ballooning drivers will have to be reworked first, to no longer rely on >>> the refcount of PageOffline pages. >>> >>> Introduce PG_offline_skippable that only applies to PageOffline() pages -- >>> of course, reusing one of the existing PG_ flags for now -- and convert >>> virtio-mem to make use of the new way: to allow for skipping PageOffline >>> pages during memory offlining, treating them as if they would not be >>> allocated. >> > > Thanks for taking a look! > >> IIUC, based on Documentation/admin-guide/mm/memory-hotplug.rst, >> to offline a page, the page first needs to be set PageOffline() to be > > PageOffline is not mentioned in there. :) Sorry, I was mixing the code with the documentation as I was reading both. > > Note that PageOffline() is a bit confusing because it's "Memory block online but page is logically offline (e.g., has a memmap that can be touched, but the page content should not be touched)". So PageOffline() is before memory block offline, which is the first phase of memory hotunplug. > > (memory block offline -> all pages offline and have effectively no state because the memmap is stale) What do you mean by memmap is stale? When a memory block is offline, memmap is still present, so pfn scanner can see these pages. pfn scanner checks memmap to know that it should not touch these pages, right? > >> removed from page allocator. > > Usually, all pages are freed back to the buddy (isolated pageblock -> put onto the isolated list). Memory offlining code can then simply grab these "free" pages from the buddy -- no PageOffline involved. > > If something fails during memory offlining, these isolated pages are simply put back on the appropriate migratetype list and become ordinary free pages that can be allocated immediately. I am familiar with this part. Then, when PageOffline is used?