On Tue, Jun 09, 2026 at 04:58:14AM +0100, Matthew Wilcox wrote: > OK, here's how I'd structure this: > > 1. Introduce PG_zeroed for buddy pages > 2. Set it if init_on_free is set > 3. Set it from balloon driver > > https://lore.kernel.org/lkml/c7094de807c0e963526686e1d245bc76193b1a92.1776689093.git....@redhat.com/ > > > but add FPI_ZEROED instead of an extra bool parameter. > > 4. Introduce page_is_zeroed like this: > > static inline bool page_is_zeroed(const struct page *page) > { > /* > * lru.next has bit 2 set if the page is already zeroed. > * Callers may simply overwrite it once they no longer > * need to preserve that information. > */ > return (unsigned long)page->lru.next & BIT(2); > } > > (you'll notice this is similar to page_is_pfmemalloc() but it doesn't > need to be in mm.h) > > This step is going to be a bit fiddly. We weren't expecting to return > multiple flags in page->lru.next, so clear_page_pfmemalloc() just sets > page->lru.next to NULL. So somewhere we need to make sure that > page->lru.next is definitely NULL, and then allow both the zeroed and > pfmemalloc flags to be set in it. > > The important part of this is that it allows the zeroed flag to be > returned from the page allocator without introducing pghint_t like you > did in v2. >
Are you suggesting leaking the flags out entirely, or just to the boundaries of page_alloc.c (__alloc_frozen_pages_noproft and etc). I assume the latter, but worth clarifying. Otherwise this seems reasonable. If we're just going to pile more stuff in lru.next you might as well either add the alias to mm.h but keep the bits defined in page_alloc.c to prevent them from escaping (even if they end up set, nothing outside page_alloc.c knows what any of them mean). Unless my read on this is mistaken, let me know if i've misunderstood anything. > 5. Now you can start skipping various zeroing steps higher in the call > chain. > > I understand David's disgust with vma_alloc_zeroed_movable_folio() > but that is surely a separate cleanup and nothing to do with this > patchset.

