On Mon, May 11, 2026 at 10:47:50AM -0400, Gregory Price wrote:
> On Mon, May 11, 2026 at 05:01:44AM -0400, Michael S. Tsirkin wrote:
> > +#ifdef CONFIG_NUMA
> > +/**
> > + * vma_alloc_folio - Allocate a folio for a VMA.
> > + * @gfp: GFP flags.
> > + * @order: Order of the folio.
> > + * @vma: Pointer to VMA.
> > + * @addr: Virtual address of the allocation. Must be inside @vma.
> > + *
> > + * Allocate a folio for a specific address in @vma, using the appropriate
> > + * NUMA policy. The caller must hold the mmap_lock of the mm_struct of the
> > + * VMA to prevent it from going away. Should be used for all allocations
> > + * for folios that will be mapped into user space, excepting hugetlbfs, and
> > + * excepting where direct use of folio_alloc_mpol() is more appropriate.
> > + *
> > + * Return: The folio on success or NULL if allocation fails.
> > + */
> > +struct folio *vma_alloc_folio_noprof(gfp_t gfp, int order,
> > + struct vm_area_struct *vma, unsigned long addr)
> > +{
> > + struct mempolicy *pol;
> > + pgoff_t ilx;
> > + struct folio *folio;
> > +
> > + if (vma->vm_flags & VM_DROPPABLE)
> > + gfp |= __GFP_NOWARN;
> > +
> > + pol = get_vma_policy(vma, addr, order, &ilx);
> > + folio = folio_alloc_mpol_noprof(gfp, order, pol, ilx, numa_node_id());
> > + mpol_cond_put(pol);
> > + return folio;
> > +}
> > +#else
> > +struct folio *vma_alloc_folio_noprof(gfp_t gfp, int order,
> > + struct vm_area_struct *vma, unsigned long addr)
> > +{
> > + if (vma->vm_flags & VM_DROPPABLE)
> > + gfp |= __GFP_NOWARN;
> > +
> > + return folio_alloc_noprof(gfp, order);
> > +}
> > +#endif
>
> Can this ifdef not reasonably be done in a header?
It can't :(
In patch 3 this will need to call __alloc_frozen_pages_noprof, and
that's in internal.h
> I know the old path relied on basically mempolicy.c being in/out of
> scope based on CONFIG_NUMA, but we should make an attempt at keeping
> page_alloc.c clean on this if possible.
>
> ~Gregory