]> www.infradead.org Git - users/jedix/linux-maple.git/commit
mm/gup.c: simplify and fix check_and_migrate_movable_pages() return codes
authorAlistair Popple <apopple@nvidia.com>
Fri, 29 Jul 2022 02:46:45 +0000 (12:46 +1000)
committerAndrew Morton <akpm@linux-foundation.org>
Fri, 26 Aug 2022 05:02:53 +0000 (22:02 -0700)
commitbc2def8d3ccad28640e432a85ca67f3cb44a5ad5
treeddca8a4b8203af43109ee61a911657264d7121cb
parent1e495c0a06283e53fd1eb70433112aa426c36622
mm/gup.c: simplify and fix check_and_migrate_movable_pages() return codes

When pinning pages with FOLL_LONGTERM check_and_migrate_movable_pages() is
called to migrate pages out of zones which should not contain any longterm
pinned pages.

When migration succeeds all pages will have been unpinned so pinning needs
to be retried.  This is indicated by returning zero.  When all pages are
in the correct zone the number of pinned pages is returned.

However migration can also fail, in which case pages are unpinned and
-ENOMEM is returned.  However if the failure was due to not being unable
to isolate a page zero is returned.  This leads to indefinite looping in
__gup_longterm_locked().

Fix this by simplifying the return codes such that zero indicates all
pages were successfully pinned in the correct zone while errors indicate
either pages were migrated and pinning should be retried or that migration
has failed and therefore the pinning operation should fail.

Link: https://lkml.kernel.org/r/20220729024645.764366-1-apopple@nvidia.com
Signed-off-by: Alistair Popple <apopple@nvidia.com>
Cc: David Hildenbrand <david@redhat.com>
Cc: Jason Gunthorpe <jgg@nvidia.com>
Cc: Alistair Popple <apopple@nvidia.com>
Cc: John Hubbard <jhubbard@nvidia.com>
Cc: Minchan Kim <minchan@kernel.org>
Cc: Pasha Tatashin <pasha.tatashin@soleen.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
mm/gup.c