Re: [PATCH] mm/gup.c: Simplify and fix check_and_migrate_movable_pages() return codes

Jason Gunthorpe
2022-08-02T12:21:13Z

On Mon, Aug 01, 2022 at 12:18:53PM +1000, Alistair Popple wrote:

> > AFAICT there is no reason to 'continue' in most of these paths since
> > we intend to return to userspace with an error anyhow? Why try to
> > isolate more pages?
>
> The main reason would be if callers want to retry the operation. AFAIK
> isolate_folio_lru() can have transient failures, so if callers want to
> retry it makes sense to isolate and migrate as many pages as possible
> rather than one page at a time as subsequent retries may find different
> pages that can't be isolated.

Except we don't try to do the migrate, we just isolate and then
unisolate and return failure.

> Actually I should have called this out more clearly - the previous
> behaviour on isolation failure was to retry indefinitely which is what
> lead to looping in the kernel. This patch turns isolation failure into
> an error and doesn't retry. I wonder though if we need to maintain a
> retry count similar to what migrate_pages() does if there are unexpected
> page refs?

This makes more sense, exporting this mess to the caller and hoping
they retry (they won't) doesn't make sense..

Jason