]> 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>
Mon, 22 Aug 2022 22:58:03 +0000 (15:58 -0700)
commitfabcb89454a183a752b27ce791fc784ee319f15c
tree6567b391ed94d5664d5b518db9cddbe3e7b54e6e
parent5d81a215c6b4f4d45933b1a1ff4ff38786aaa0a5
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