Subject: Re: [PATCH RFC v2 02/18] mm: add pghint_t type and vma_alloc_folio_hints API

From: "Michael S. Tsirkin" <[email-masked]>
Date: Tue, 21 Apr 2026 09:03:12 -0400

On Tue, Apr 21, 2026 at 08:58:59AM +0800, Huang, Ying wrote:
> "Michael S. Tsirkin" <[email-masked]> writes:
> 
> > Add pghint_t, a bitwise type for communicating page allocation hints
> > between the allocator and callers.  Define PGHINT_ZEROED to indicate
> > that the allocated page contents are known to be zero.
> >
> > Add _hints variants of the allocation functions that accept a
> > pghint_t *hints output parameter:
> >
> >   vma_alloc_folio_hints()  -> folio_alloc_mpol_hints (internal)
> >                            -> __alloc_frozen_pages_hints()
> >
> > The existing APIs are unchanged and continue to work without hints.
> > For now, hints is always initialized to 0.  A subsequent patch will
> > set PGHINT_ZEROED when the page was pre-zeroed by the host.
> 
> Why do we need this feature?  Is there any performance impact?  If so,
> please provide some performance data.

It's in the cover letter:

Performance with THP enabled on a 2GB VM, 1 vCPU, allocating
256MB of anonymous pages:

  metric         baseline        optimized       delta
  task-clock     191 +- 31 ms    60 +- 35 ms     -68%
  cache-misses   1.10M +- 460K   269K +- 31K     -76%
  instructions   4.54M +- 275K   4.10M +- 130K   -10%

With hugetlb surplus pages:

  metric         baseline        optimized       delta
  task-clock     183 +- 24 ms    45 +- 23 ms     -76%
  cache-misses   1.27M +- 544K   270K +- 16K     -79%
  instructions   5.37M +- 254K   4.94M +- 155K   -8%

> [snip]
> ---
> Best Regards,
> Huang, Ying