]> 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>
Wed, 17 Aug 2022 20:58:35 +0000 (13:58 -0700)
commit61c63c2076d940c00e0b2716e872ceeeeb9105d3
treec71ca29bd41d91fc8175d25c498f1751aa72e457
parente0fe2ca7ac59b6ac052766f17784411490436cbe
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