On Wed, May 21, 2025 at 03:44:32PM +0200, David Hildenbrand wrote:
> No, the code is confusing.
> 
> All pages are PageOffline. Only the ones that have not been onlined are *in
> addition* PageDirty.
> 
> The relevant bit is documented in page-flags.h:
> 
> "When a memory block gets onlined, all pages are initialized with a refcount
> of 1 and PageOffline(). generic_online_page() will take care of clearing
> PageOffline()."

Ah ok, I see it in __free_pages_core().


> > - If we want to release logically-offline pages belonging to an onlined 
> > memory-block,
> >    we ClearDirty them and be done
> 
> PageOffline gets cleared in both cases: See the comment in
> virtio_mem_clear_fake_offline()
> 
> "/* generic_online_page() will clear PageOffline(). */"
> 
> I'll note that I am planning on removing that PageDirty() handling
> completely, and also letting handling PageOffline() clearing be always
> performed by memory freeing core (the latter is easier to achieve).

Cool, I think that would be much clearer.

 
> When re-onlining, the core will set them all PageOffline, and virtio-mem
> will intercept page onlining using the page_online_cb.
> 
> virtio-mem will then online the actually plugged parts (->
> generic_online_page(), which clears PageOffline and exposes them to the
> buddy) and set the unplugged/hole parts as PageOfflineSkipabble again.
> 
> That logic resides in virtio_mem_online_page_cb().

Sorry, I had to re-cache this.
Ok, I think that now I caught up with the code.

I see that we mark it Offline in memmap_init_range(), and then
__free_pages_core() will clear the flag before releasing them to the
buddy.

Ok, I think it is much clear now, thanks for helping me out with the
details! 

-- 
Oscar Salvador
SUSE Labs

Reply via email to