[PATCH 6/6] sysctl: Add global tunable mt_page_copy

From: Anshuman Khandual
Date: Fri Feb 17 2017 - 06:27:17 EST


From: Zi Yan <ziy@xxxxxxxxxx>

A new global sysctl tunable 'mt_page_copy' is added which will override
syscall specific requests and enable multi threaded page copy during
all migrations on the system. This tunable is disabled by default.

Signed-off-by: Zi Yan <zi.yan@xxxxxxxxxxxxxx>
Signed-off-by: Anshuman Khandual <khandual@xxxxxxxxxxxxxxxxxx>
---
kernel/sysctl.c | 10 ++++++++++
mm/migrate.c | 14 ++++++++++++++
2 files changed, 24 insertions(+)

diff --git a/kernel/sysctl.c b/kernel/sysctl.c
index 1aea594..e5f7ca9 100644
--- a/kernel/sysctl.c
+++ b/kernel/sysctl.c
@@ -98,6 +98,7 @@
#if defined(CONFIG_SYSCTL)

/* External variables not in a header file. */
+extern int mt_page_copy;
extern int suid_dumpable;
#ifdef CONFIG_COREDUMP
extern int core_uses_pid;
@@ -1346,6 +1347,15 @@ static struct ctl_table vm_table[] = {
.proc_handler = &hugetlb_mempolicy_sysctl_handler,
},
#endif
+ {
+ .procname = "mt_page_copy",
+ .data = &mt_page_copy,
+ .maxlen = sizeof(mt_page_copy),
+ .mode = 0644,
+ .proc_handler = proc_dointvec,
+ .extra1 = &zero,
+ .extra2 = &one,
+ },
{
.procname = "hugetlb_shm_group",
.data = &sysctl_hugetlb_shm_group,
diff --git a/mm/migrate.c b/mm/migrate.c
index 660c4b2..75b6d7a 100644
--- a/mm/migrate.c
+++ b/mm/migrate.c
@@ -48,6 +48,8 @@

#include "internal.h"

+int mt_page_copy;
+
/*
* migrate_prep() needs to be called before we start compiling a list of pages
* to be migrated using isolate_lru_page(). If scheduling work on other CPUs is
@@ -611,6 +613,9 @@ static void copy_huge_page(struct page *dst, struct page *src,
nr_pages = hpage_nr_pages(src);
}

+ if (mt_page_copy)
+ mode |= MIGRATE_MT;
+
if (mode & MIGRATE_MT)
rc = copy_pages_mthread(dst, src, nr_pages);

@@ -629,6 +634,9 @@ void migrate_page_copy(struct page *newpage, struct page *page,
{
int cpupid;

+ if (mt_page_copy)
+ mode |= MIGRATE_MT;
+
if (PageHuge(page) || PageTransHuge(page)) {
copy_huge_page(newpage, page, mode);
} else {
@@ -695,6 +703,12 @@ void migrate_page_copy(struct page *newpage, struct page *page,
}
EXPORT_SYMBOL(migrate_page_copy);

+static int __init mt_page_copy_init(void)
+{
+ mt_page_copy = 0;
+ return 0;
+}
+subsys_initcall(mt_page_copy_init);
/************************************************************
* Migration functions
***********************************************************/
--
2.9.3