Message ID | 20201110181250.264394-4-shy828301@gmail.com (mailing list archive) |
---|---|
State | New, archived |
Headers | show |
Series | mm: misc migrate cleanup and improvement | expand |
On Tue, Nov 10, 2020 at 10:12:48AM -0800, Yang Shi wrote: > @@ -2142,6 +2151,10 @@ int migrate_misplaced_transhuge_page(struct mm_struct *mm, > int page_lru = page_is_file_lru(page); > unsigned long start = address & HPAGE_PMD_MASK; > > + if (IS_ENABLED(CONFIG_READ_ONLY_THP_FOR_FS) && > + is_shared_exec_page(vma, page)) > + goto out; Why include the IS_ENABLED() check? Once the ~50 patches I have pending go in, shared executable THPs can exist without this option. And can't we have executables on tmpfs today without this option too?
On Tue, Nov 10, 2020 at 10:16 AM Matthew Wilcox <willy@infradead.org> wrote: > > On Tue, Nov 10, 2020 at 10:12:48AM -0800, Yang Shi wrote: > > @@ -2142,6 +2151,10 @@ int migrate_misplaced_transhuge_page(struct mm_struct *mm, > > int page_lru = page_is_file_lru(page); > > unsigned long start = address & HPAGE_PMD_MASK; > > > > + if (IS_ENABLED(CONFIG_READ_ONLY_THP_FOR_FS) && > > + is_shared_exec_page(vma, page)) > > + goto out; > > Why include the IS_ENABLED() check? Once the ~50 patches I have pending > go in, shared executable THPs can exist without this option. And can't > we have executables on tmpfs today without this option too? Aha, yes, thanks for reminding. I had the patches baked in my tree before your patches were posted. We could have executables on tmpfs w/o that config. Will remove it. Thanks.
diff --git a/mm/migrate.c b/mm/migrate.c index d7167f7107bd..1b103e801fe4 100644 --- a/mm/migrate.c +++ b/mm/migrate.c @@ -2069,6 +2069,16 @@ 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->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 @@ -2086,8 +2096,7 @@ int migrate_misplaced_page(struct page *page, struct vm_area_struct *vma, * 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; /* @@ -2142,6 +2151,10 @@ int migrate_misplaced_transhuge_page(struct mm_struct *mm, int page_lru = page_is_file_lru(page); unsigned long start = address & HPAGE_PMD_MASK; + if (IS_ENABLED(CONFIG_READ_ONLY_THP_FOR_FS) && + is_shared_exec_page(vma, page)) + goto out; + new_page = alloc_pages_node(node, (GFP_TRANSHUGE_LIGHT | __GFP_THISNODE), HPAGE_PMD_ORDER); @@ -2253,6 +2266,7 @@ int migrate_misplaced_transhuge_page(struct mm_struct *mm, out_unlock: unlock_page(page); +out: put_page(page); return 0; }
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. Signed-off-by: Yang Shi <shy828301@gmail.com> --- mm/migrate.c | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-)