[RFC PATCH 0/6] mm: thp: use generic THP migration for NUMA hinting fault

From: Yang Shi
Date: Mon Mar 29 2021 - 14:34:32 EST



When the THP NUMA fault support was added THP migration was not supported yet.
So the ad hoc THP migration was implemented in NUMA fault handling. Since v4.14
THP migration has been supported so it doesn't make too much sense to still keep
another THP migration implementation rather than using the generic migration
code. It is definitely a maintenance burden to keep two THP migration
implementation for different code paths and it is more error prone. Using the
generic THP migration implementation allows us remove the duplicate code and
some hacks needed by the old ad hoc implementation.

A quick grep shows x86_64, PowerPC (book3s), ARM64 ans S390 support both THP
and NUMA balancing. The most of them support THP migration except for S390.
Zi Yan tried to add THP migration support for S390 before but it was not
accepted due to the design of S390 PMD. For the discussion, please see:
https://lkml.org/lkml/2018/4/27/953.

I'm not expert on S390 so not sure if it is feasible to support THP migration
for S390 or not. If it is not feasible then the patchset may make THP NUMA
balancing not be functional on S390. Not sure if this is a show stopper although
the patchset does simplify the code a lot. Anyway it seems worth posting the
series to the mailing list to get some feedback.

Patch #1 ~ #3 are preparation and clean up patches.
Patch #4 is the real meat.
Patch #5 keep THP not split if migration is failed for NUMA hinting.
Patch #6 removes a hack about page refcount.

I saw there were some hacks about gup from git history, but I didn't figure out
if they have been removed or not since I just found FOLL_NUMA code in the current
gup implementation and they seems useful.


Yang Shi (6):
mm: memory: add orig_pmd to struct vm_fault
mm: memory: make numa_migrate_prep() non-static
mm: migrate: teach migrate_misplaced_page() about THP
mm: thp: refactor NUMA fault handling
mm: migrate: don't split THP for misplaced NUMA page
mm: migrate: remove redundant page count check for THP

include/linux/huge_mm.h | 9 ++---
include/linux/migrate.h | 29 ++-------------
include/linux/mm.h | 1 +
mm/huge_memory.c | 141 +++++++++++++++++++---------------------------------------------------
mm/internal.h | 3 ++
mm/memory.c | 33 ++++++++---------
mm/migrate.c | 190 ++++++++++++++---------------------------------------------------------------------------------
7 files changed, 94 insertions(+), 312 deletions(-)