Commit c77c5cba authored by Yang Shi's avatar Yang Shi Committed by Linus Torvalds

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@gmail.comSigned-off-by: default avatarYang Shi <shy828301@gmail.com>
Cc: Matthew Wilcox <willy@infradead.org>
Cc: Jan Kara <jack@suse.cz>
Cc: Mel Gorman <mgorman@suse.de>
Cc: Michal Hocko <mhocko@suse.com>
Cc: Song Liu <songliubraving@fb.com>
Cc: Zi Yan <ziy@nvidia.com>
Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
parent dd4ae78a
...@@ -2071,6 +2071,17 @@ bool pmd_trans_migrating(pmd_t pmd) ...@@ -2071,6 +2071,17 @@ bool pmd_trans_migrating(pmd_t pmd)
return PageLocked(page); 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 * Attempt to migrate a misplaced page to the specified destination
* node. Caller is expected to have an elevated reference count on * node. Caller is expected to have an elevated reference count on
...@@ -2088,8 +2099,7 @@ int migrate_misplaced_page(struct page *page, struct vm_area_struct *vma, ...@@ -2088,8 +2099,7 @@ int migrate_misplaced_page(struct page *page, struct vm_area_struct *vma,
* Don't migrate file pages that are mapped in multiple processes * Don't migrate file pages that are mapped in multiple processes
* with execute permissions as they are probably shared libraries. * with execute permissions as they are probably shared libraries.
*/ */
if (page_mapcount(page) != 1 && page_is_file_lru(page) && if (is_shared_exec_page(vma, page))
(vma->vm_flags & VM_EXEC))
goto out; goto out;
/* /*
...@@ -2144,6 +2154,9 @@ int migrate_misplaced_transhuge_page(struct mm_struct *mm, ...@@ -2144,6 +2154,9 @@ int migrate_misplaced_transhuge_page(struct mm_struct *mm,
int page_lru = page_is_file_lru(page); int page_lru = page_is_file_lru(page);
unsigned long start = address & HPAGE_PMD_MASK; unsigned long start = address & HPAGE_PMD_MASK;
if (is_shared_exec_page(vma, page))
goto out;
new_page = alloc_pages_node(node, new_page = alloc_pages_node(node,
(GFP_TRANSHUGE_LIGHT | __GFP_THISNODE), (GFP_TRANSHUGE_LIGHT | __GFP_THISNODE),
HPAGE_PMD_ORDER); HPAGE_PMD_ORDER);
...@@ -2255,6 +2268,7 @@ int migrate_misplaced_transhuge_page(struct mm_struct *mm, ...@@ -2255,6 +2268,7 @@ int migrate_misplaced_transhuge_page(struct mm_struct *mm,
out_unlock: out_unlock:
unlock_page(page); unlock_page(page);
out:
put_page(page); put_page(page);
return 0; return 0;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment