From: cgel.zte@gmail.com
To: akpm@linux-foundation.org, willy@infradead.org
Cc: hughd@google.com, izik.eidus@ravellosystems.com,
linux-kernel@vger.kernel.org, linux-mm@kvack.org,
xu.xin16@zte.com.cn, CGEL <cgel.zte@gmail.com>
Subject: [PATCH v2 1/5] ksm: add a auto-run mode of ksm
Date: Fri, 12 Aug 2022 10:11:52 +0000 [thread overview]
Message-ID: <20220812101152.41479-1-xu.xin16@zte.com.cn> (raw)
In-Reply-To: <20220812101102.41422-1-xu.xin16@zte.com.cn>
From: xu xin <xu.xin16@zte.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@zte.com.cn>
Signed-off-by: CGEL <cgel.zte@gmail.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
next prev parent reply other threads:[~2022-08-12 10:12 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-08-12 10:11 [PATCH v2 0/5] propose auto-run mode of ksm and its tests cgel.zte
2022-08-12 10:11 ` cgel.zte [this message]
2022-08-12 10:12 ` [PATCH v2 2/5] ksm: implement scan-enhanced algorithm cgel.zte
2022-08-12 10:12 ` [PATCH v2 3/5] ksm: let ksmd auto-work with memory threshold cgel.zte
2022-08-12 10:12 ` [PATCH v2 4/5] ksm: show ksmd status for auto mode cgel.zte
2022-08-12 10:12 ` [PATCH v2 5/5] ksm: add tests of ksm " cgel.zte
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=20220812101152.41479-1-xu.xin16@zte.com.cn \
--to=cgel.zte@gmail.com \
--cc=akpm@linux-foundation.org \
--cc=hughd@google.com \
--cc=izik.eidus@ravellosystems.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=willy@infradead.org \
--cc=xu.xin16@zte.com.cn \
/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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.