[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <20220803100514.1653440-1-xu.xin16@zte.con.cn>
Date: Wed, 3 Aug 2022 10:05:14 +0000
From: cgel.zte@...il.com
To: akpm@...ux-foundation.org
Cc: hughd@...gle.com, izik.eidus@...ellosystems.com,
willy@...radead.org, linux-kernel@...r.kernel.org,
linux-mm@...ck.org, xu xin <xu.xin16@....com.cn>,
CGEL <cgel.zte@...il.com>
Subject: [RFC PATCH 1/4] ksm: propose a auto-run mode of ksm
From: xu xin <xu.xin16@....com.cn>
Add a new running state auto-mode to ksm. This is to pave the way
for subsequent real optimization features.
Use it by: echo 8 > /sys/kernel/mm/ksm/run
Signed-off-by: xu xin <xu.xin16@....com.cn>
Signed-off-by: CGEL <cgel.zte@...il.com>
---
mm/ksm.c | 9 ++++++---
1 file changed, 6 insertions(+), 3 deletions(-)
diff --git a/mm/ksm.c b/mm/ksm.c
index 2f315c69fa2c..c80d908221a4 100644
--- a/mm/ksm.c
+++ b/mm/ksm.c
@@ -290,6 +290,7 @@ static int ksm_nr_node_ids = 1;
#define KSM_RUN_MERGE 1
#define KSM_RUN_UNMERGE 2
#define KSM_RUN_OFFLINE 4
+#define KSM_RUN_AUTO 8
static unsigned long ksm_run = KSM_RUN_STOP;
static void wait_while_offlining(void);
@@ -2416,7 +2417,9 @@ static void ksm_do_scan(unsigned int scan_npages)
static int ksmd_should_run(void)
{
- return (ksm_run & KSM_RUN_MERGE) && !list_empty(&ksm_mm_head.mm_list);
+ if (!list_empty(&ksm_mm_head.mm_list))
+ return ksm_run & KSM_RUN_AUTO || ksm_run & KSM_RUN_MERGE;
+ return 0;
}
static int ksm_scan_thread(void *nothing)
@@ -2916,7 +2919,7 @@ static ssize_t run_store(struct kobject *kobj, struct kobj_attribute *attr,
err = kstrtouint(buf, 10, &flags);
if (err)
return -EINVAL;
- if (flags > KSM_RUN_UNMERGE)
+ if (flags > KSM_RUN_UNMERGE && flags != KSM_RUN_AUTO)
return -EINVAL;
/*
@@ -2942,7 +2945,7 @@ static ssize_t run_store(struct kobject *kobj, struct kobj_attribute *attr,
}
mutex_unlock(&ksm_thread_mutex);
- if (flags & KSM_RUN_MERGE)
+ if (flags & KSM_RUN_MERGE || flags & KSM_RUN_AUTO)
wake_up_interruptible(&ksm_thread_wait);
return count;
--
2.25.1
Powered by blists - more mailing lists