From: Yang Shi <shy828301@gmail.com>
To: mhocko@suse.com, ziy@nvidia.com, songliubraving@fb.com,
mgorman@suse.de, jack@suse.cz, akpm@linux-foundation.org
Cc: shy828301@gmail.com, linux-mm@kvack.org, linux-kernel@vger.kernel.org
Subject: [PATCH 3/5] mm: migrate: skip shared exec THP for NUMA balancing
Date: Tue, 3 Nov 2020 05:03:32 -0800 [thread overview]
Message-ID: <20201103130334.13468-4-shy828301@gmail.com> (raw)
In-Reply-To: <20201103130334.13468-1-shy828301@gmail.com>
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(-)
diff --git a/mm/migrate.c b/mm/migrate.c
index c33c92495ead..9a32bb128f31 100644
--- a/mm/migrate.c
+++ b/mm/migrate.c
@@ -2061,6 +2061,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
@@ -2078,8 +2088,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;
/*
@@ -2134,6 +2143,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);
@@ -2245,6 +2258,7 @@ int migrate_misplaced_transhuge_page(struct mm_struct *mm,
out_unlock:
unlock_page(page);
+out:
put_page(page);
return 0;
}
--
2.26.2
next prev parent reply other threads:[~2020-11-05 20:53 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-11-03 13:03 [PATCH 0/5] mm: misc migrate cleanup and improvement Yang Shi
2020-11-03 13:03 ` [PATCH 1/5] mm: truncate_complete_page is not existed anymore Yang Shi
2020-11-06 9:16 ` Jan Kara
2020-11-03 13:03 ` [PATCH 2/5] mm: migrate: simplify the logic for handling permanent failure Yang Shi
2020-11-06 20:03 ` Zi Yan
2020-11-06 21:34 ` Yang Shi
2020-11-03 13:03 ` Yang Shi [this message]
2020-11-03 13:03 ` [PATCH 4/5] mm: migrate: clean up migrate_prep{_local} Yang Shi
2020-11-06 20:05 ` Zi Yan
2020-11-03 13:03 ` [PATCH 5/5] mm: migrate: return -ENOSYS if THP migration is unsupported Yang Shi
2020-11-06 20:17 ` Zi Yan
2020-11-06 21:53 ` Yang Shi
2020-11-06 22:02 ` Yang Shi
2020-11-06 23:15 ` Yang Shi
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20201103130334.13468-4-shy828301@gmail.com \
--to=shy828301@gmail.com \
--cc=akpm@linux-foundation.org \
--cc=jack@suse.cz \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=mgorman@suse.de \
--cc=mhocko@suse.com \
--cc=songliubraving@fb.com \
--cc=ziy@nvidia.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox