Re: [PATCH v3 10/12] mempolicy: alloc_pages_mpol() for NUMA policy without vma

From: Hugh Dickins
Date: Mon Oct 23 2023 - 17:10:59 EST


On Mon, 23 Oct 2023, Zi Yan wrote:
> On 19 Oct 2023, at 16:39, Hugh Dickins wrote:
> > @@ -1170,6 +1170,15 @@ static struct folio *new_folio(struct folio *src, unsigned long start)
> > break;
> > }
> >
> > + /*
> > + * __get_vma_policy() now expects a genuine non-NULL vma. Return NULL
> > + * when the page can no longer be located in a vma: that is not ideal
> > + * (migrate_pages() will give up early, presuming ENOMEM), but good
> > + * enough to avoid a crash by syzkaller or concurrent holepunch.
> > + */
> > + if (!vma)
> > + return NULL;
> > +
>
> How often would this happen? I just want to point out that ENOMEM can cause
> src THPs or large folios to be split by migrate_pages().

The only case I know of it happening was when a file was mapped, then that
file truncated (cutting out the source page) before migrate_pages(&pagelist)
reached it - rather a syzbotty thing to do, not of great reallife concern.

I won't assert that's the only way: I've a ghost of a memory of another way,
that I can't quite resurface, from a long-ago version of queue_pages_range().

But in the end just didn't care enough about it, because this is really just
to save a bisection point from crashing - the possibility goes away in the
11/12 commit which follows this one, which takes VMA out of it altogether.

Hugh