[PATCH 0/6] prohibit pinning pages in ZONE_MOVABLE

From: Pavel Tatashin
Date: Wed Dec 02 2020 - 00:24:16 EST


When page is pinned it cannot be moved and its physical address stays
the same until pages is unpinned.

This is useful functionality to allows userland to implementation DMA
access. For example, it is used by vfio in vfio_pin_pages().

However, this functionality breaks memory hotplug/hotremove assumptions
that pages in ZONE_MOVABLE can always be migrated.

This patch series fixes this issue by forcing new allocations during
page pinning to omit ZONE_MOVABLE, and also to migrate any existing
pages from ZONE_MOVABLE during pinning.

It uses the same scheme logic that is currently used by CMA, and extends
the functionality for all allocations.

For more information read the discussion [1] about this problem.

[1] https://lore.kernel.org/lkml/CA+CK2bBffHBxjmb9jmSKacm0fJMinyt3Nhk8Nx6iudcQSj80_w@xxxxxxxxxxxxxx/

Pavel Tatashin (6):
mm/gup: perform check_dax_vmas only when FS_DAX is enabled
mm/gup: don't pin migrated cma pages in movable zone
mm/gup: make __gup_longterm_locked common
mm cma: rename PF_MEMALLOC_NOCMA to PF_MEMALLOC_NOMOVABLE
mm: honor PF_MEMALLOC_NOMOVABLE for all allocations
mm/gup: migrate pinned pages out of movable zone

include/linux/migrate.h | 1 +
include/linux/sched.h | 2 +-
include/linux/sched/mm.h | 21 +++------
include/trace/events/migrate.h | 3 +-
mm/gup.c | 82 +++++++++++++---------------------
mm/hugetlb.c | 4 +-
mm/page_alloc.c | 26 ++++++-----
7 files changed, 58 insertions(+), 81 deletions(-)

--
2.25.1