On Tue, May 12, 2026 at 05:05:16PM -0400, Michael S. Tsirkin wrote:
> When a reported free page is split via expand() to satisfy a
> smaller allocation, the sub-pages placed back on the free lists
> lose the PageReported flag.  This means they will be unnecessarily
> re-reported to the hypervisor in the next reporting cycle, wasting
> work.
> 
> While I was unable to quantify the performance difference, it is
> an obvious waste, even if small.
> 
> Propagate the PageReported flag to sub-pages during expand(),
> both in page_del_and_expand() and try_to_claim_block(), so
> that they are recognized as already-reported.
> 
> Signed-off-by: Michael S. Tsirkin <[email protected]>
> Assisted-by: Claude:claude-opus-4-6
... snip ...
> @@ -1731,9 +1740,10 @@ static __always_inline void page_del_and_expand(struct 
> zone *zone,
>                                               int high, int migratetype)
>  {
>       int nr_pages = 1 << high;
> +     bool was_reported = page_reported(page);
>  
>       __del_page_from_free_list(page, zone, high, migratetype);
> -     nr_pages -= expand(zone, page, low, high, migratetype);
> +     nr_pages -= expand(zone, page, low, high, migratetype, was_reported);
>       account_freepages(zone, -nr_pages, migratetype);
>  }
>  

Maybe mildly out of scope but worth asking:  Are there other flags that
should be retained/propogated on a split?  If so, rather than pass
was_reported, should we just take a temporary copy of the page flags and
pass them all in?

~Gregory

Reply via email to