The patch titled Subject: mm: migrate: skip shared exec THP for NUMA balancing has been added to the -mm tree. Its filename is mm-migrate-skip-shared-exec-thp-for-numa-balancing.patch This patch should soon appear at https://ozlabs.org/~akpm/mmots/broken-out/mm-migrate-skip-shared-exec-thp-for-numa-balancing.patch and later at https://ozlabs.org/~akpm/mmotm/broken-out/mm-migrate-skip-shared-exec-thp-for-numa-balancing.patch Before you just go and hit "reply", please: a) Consider who else should be cc'ed b) Prefer to cc a suitable mailing list as well c) Ideally: find the original patch on the mailing list and do a reply-to-all to that, adding suitable additional cc's *** Remember to use Documentation/process/submit-checklist.rst when testing your code *** The -mm tree is included into linux-next and is updated there every 3-4 working days ------------------------------------------------------ From: Yang Shi <shy828301@xxxxxxxxx> Subject: mm: migrate: skip shared exec THP for NUMA balancing The NUMA balancing skip shared exec base page. Since CONFIG_READ_ONLY_THP_FOR_FS was introduced, there are probably shared exec THP, so skip such THPs for NUMA balancing as well. And Willy's regular filesystem THP support patches could create shared exec THP wven without that config. In addition, the page_is_file_lru() is used to tell if the page is file cache or not, but it filters out shmem page. It sounds like a typical usecase by putting executables in shmem to achieve performance gain via using shmem-THP, so it sounds worth skipping migration for such case too. Link: https://lkml.kernel.org/r/20201113205359.556831-4-shy828301@xxxxxxxxx Signed-off-by: Yang Shi <shy828301@xxxxxxxxx> Cc: Matthew Wilcox <willy@xxxxxxxxxxxxx> Cc: Jan Kara <jack@xxxxxxx> Cc: Mel Gorman <mgorman@xxxxxxx> Cc: Michal Hocko <mhocko@xxxxxxxx> Cc: Song Liu <songliubraving@xxxxxx> Cc: Zi Yan <ziy@xxxxxxxxxx> Signed-off-by: Andrew Morton <akpm@xxxxxxxxxxxxxxxxxxxx> --- mm/migrate.c | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) --- a/mm/migrate.c~mm-migrate-skip-shared-exec-thp-for-numa-balancing +++ a/mm/migrate.c @@ -2071,6 +2071,17 @@ bool pmd_trans_migrating(pmd_t pmd) return PageLocked(page); } +static inline bool is_shared_exec_page(struct vm_area_struct *vma, + struct page *page) +{ + if (page_mapcount(page) != 1 && + (page_is_file_lru(page) || vma_is_shmem(vma)) && + (vma->vm_flags & VM_EXEC)) + return true; + + return false; +} + /* * Attempt to migrate a misplaced page to the specified destination * node. Caller is expected to have an elevated reference count on @@ -2088,8 +2099,7 @@ int migrate_misplaced_page(struct page * * Don't migrate file pages that are mapped in multiple processes * with execute permissions as they are probably shared libraries. */ - if (page_mapcount(page) != 1 && page_is_file_lru(page) && - (vma->vm_flags & VM_EXEC)) + if (is_shared_exec_page(vma, page)) goto out; /* @@ -2144,6 +2154,9 @@ int migrate_misplaced_transhuge_page(str int page_lru = page_is_file_lru(page); unsigned long start = address & HPAGE_PMD_MASK; + if (is_shared_exec_page(vma, page)) + goto out; + new_page = alloc_pages_node(node, (GFP_TRANSHUGE_LIGHT | __GFP_THISNODE), HPAGE_PMD_ORDER); @@ -2255,6 +2268,7 @@ out_fail: out_unlock: unlock_page(page); +out: put_page(page); return 0; } _ Patches currently in -mm which might be from shy828301@xxxxxxxxx are mm-truncate_complete_page-is-not-existed-anymore.patch mm-migrate-simplify-the-logic-for-handling-permanent-failure.patch mm-migrate-skip-shared-exec-thp-for-numa-balancing.patch mm-migrate-clean-up-migrate_prep_local.patch mm-migrate-return-enosys-if-thp-migration-is-unsupported.patch