Re: [PATCH 07/13] mm/migrate_device: look up fault folio after a split

From: Gregory Price (Meta)

Date: Thu Nov 12 2026 - 13:09:20 EST


On 2026-11-11 18:13 +0000, Lorenzo Stoakes (ARM) wrote:
> From: Josef Bacik <josef@xxxxxxxxxxxxxx>
>
> migrate_vma_collect_pmd() looks up the folio of migrate->fault_page once,
> when it is entered, at which point the folio is locked.
>
> The fault folio is assumed not to change after this, however if
> migrate_vma_split_folio() splits a PTE-mapped large folio which contains
> the fault page, the fault page ends up in a different folio.
>
> Resolve the issue by looking up fault_folio again after each restart of the
> walk.
>
> Fixes: 022a12deda53 ("mm/migrate_device: handle partially mapped folios during collection")
> Cc: <stable@xxxxxxxxxxxxxxx>
> Signed-off-by: Josef Bacik <josef@xxxxxxxxxxxxxx>
> [ ljs: pared down commit message ]
> Signed-off-by: Lorenzo Stoakes (ARM) <ljs@xxxxxxxxxx>

Was able to reproduce this, and i think this also reveals (and fixes)
another bug in Nouveau (memory leak). I think the Nouveau driver still
needs a patch, but this otherwise looks correct.

Tested-by: Gregory Price (Meta) <gourry@xxxxxxxxxx>

--
~Gregory