path: root/mm/internal.h
diff options
authorYang Shi <>2021-06-30 18:51:42 -0700
committerLinus Torvalds <>2021-06-30 20:47:30 -0700
commitc5b5a3dd2c1fa61049b7789ce596faff4d659a61 (patch)
treeef18a9e9627b1233365a960716b4730993cdeefa /mm/internal.h
parentf4c0d8367ea492cdfc7f6d14763c02f472731592 (diff)
mm: thp: refactor NUMA fault handling
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. This patch reworks the NUMA fault handling to use generic migration implementation to migrate misplaced page. There is no functional change. After the refactor the flow of NUMA fault handling looks just like its PTE counterpart: Acquire ptl Prepare for migration (elevate page refcount) Release ptl Isolate page from lru and elevate page refcount Migrate the misplaced THP If migration fails just restore the old normal PMD. In the old code anon_vma lock was needed to serialize THP migration against THP split, but since then the THP code has been reworked a lot, it seems anon_vma lock is not required anymore to avoid the race. The page refcount elevation when holding ptl should prevent from THP split. Use migrate_misplaced_page() for both base page and THP NUMA hinting fault and remove all the dead and duplicate code. [ fix a double unlock bug] Link: Link: Signed-off-by: Yang Shi <> Signed-off-by: Dan Carpenter <> Acked-by: Mel Gorman <> Cc: Christian Borntraeger <> Cc: Gerald Schaefer <> Cc: Heiko Carstens <> Cc: Huang Ying <> Cc: Hugh Dickins <> Cc: Kirill A. Shutemov <> Cc: Michal Hocko <> Cc: Vasily Gorbik <> Cc: Zi Yan <> Signed-off-by: Andrew Morton <> Signed-off-by: Linus Torvalds <>
Diffstat (limited to 'mm/internal.h')
1 files changed, 0 insertions, 18 deletions
diff --git a/mm/internal.h b/mm/internal.h
index a4942f9867a3..d565eb94d6ec 100644
--- a/mm/internal.h
+++ b/mm/internal.h
@@ -369,23 +369,6 @@ extern unsigned int munlock_vma_page(struct page *page);
extern void clear_page_mlock(struct page *page);
- * mlock_migrate_page - called only from migrate_misplaced_transhuge_page()
- * (because that does not go through the full procedure of migration ptes):
- * to migrate the Mlocked page flag; update statistics.
- */
-static inline void mlock_migrate_page(struct page *newpage, struct page *page)
- if (TestClearPageMlocked(page)) {
- int nr_pages = thp_nr_pages(page);
- /* Holding pmd lock, no change in irq context: __mod is safe */
- __mod_zone_page_state(page_zone(page), NR_MLOCK, -nr_pages);
- SetPageMlocked(newpage);
- __mod_zone_page_state(page_zone(newpage), NR_MLOCK, nr_pages);
- }
extern pmd_t maybe_pmd_mkwrite(pmd_t pmd, struct vm_area_struct *vma);
@@ -461,7 +444,6 @@ static inline struct file *maybe_unlock_mmap_for_io(struct vm_fault *vmf,
#else /* !CONFIG_MMU */
static inline void clear_page_mlock(struct page *page) { }
static inline void mlock_vma_page(struct page *page) { }
-static inline void mlock_migrate_page(struct page *new, struct page *old) { }
static inline void vunmap_range_noflush(unsigned long start, unsigned long end)