From: Martin Doucha <mdoucha@suse.cz>
To: ltp@lists.linux.it
Subject: [LTP] [PATCH] Unshare KSM pages before setting max_page_sharing
Date: Thu, 28 Nov 2019 17:31:47 +0100 [thread overview]
Message-ID: <20191128163147.4377-1-mdoucha@suse.cz> (raw)
Setting max_page_sharing is possible only when there are no KSM shared pages
in the system. Otherwise writing to max_page_sharing SysFS file will fail
with EBUSY.
Signed-off-by: Martin Doucha <mdoucha@suse.cz>
---
testcases/kernel/mem/lib/mem.c | 17 ++++++++++-------
1 file changed, 10 insertions(+), 7 deletions(-)
diff --git a/testcases/kernel/mem/lib/mem.c b/testcases/kernel/mem/lib/mem.c
index a0c1b9b00..456259792 100644
--- a/testcases/kernel/mem/lib/mem.c
+++ b/testcases/kernel/mem/lib/mem.c
@@ -482,8 +482,11 @@ void create_same_memory(int size, int num, int unit)
stop_ksm_children(child, num);
tst_res(TINFO, "KSM merging...");
- if (access(PATH_KSM "max_page_sharing", F_OK) == 0)
+ if (access(PATH_KSM "max_page_sharing", F_OK) == 0) {
+ SAFE_FILE_PRINTF(PATH_KSM "run", "2");
SAFE_FILE_PRINTF(PATH_KSM "max_page_sharing", "%ld", size * pages * num);
+ }
+
SAFE_FILE_PRINTF(PATH_KSM "run", "1");
SAFE_FILE_PRINTF(PATH_KSM "pages_to_scan", "%ld", size * pages * num);
SAFE_FILE_PRINTF(PATH_KSM "sleep_millisecs", "0");
@@ -571,16 +574,16 @@ void test_ksm_merge_across_nodes(unsigned long nr_pages)
SAFE_FILE_PRINTF(PATH_KSM "sleep_millisecs", "0");
SAFE_FILE_PRINTF(PATH_KSM "pages_to_scan", "%ld",
nr_pages * num_nodes);
- if (access(PATH_KSM "max_page_sharing", F_OK) == 0)
- SAFE_FILE_PRINTF(PATH_KSM "max_page_sharing",
- "%ld", nr_pages * num_nodes);
/*
- * merge_across_nodes setting can be changed only when there
- * are no ksm shared pages in system, so set run 2 to unmerge
- * pages first, then to 1 after changing merge_across_nodes,
+ * merge_across_nodes and max_page_sharing setting can be changed
+ * only when there are no ksm shared pages in system, so set run 2
+ * to unmerge pages first, then to 1 after changing merge_across_nodes,
* to remerge according to the new setting.
*/
SAFE_FILE_PRINTF(PATH_KSM "run", "2");
+ if (access(PATH_KSM "max_page_sharing", F_OK) == 0)
+ SAFE_FILE_PRINTF(PATH_KSM "max_page_sharing",
+ "%ld", nr_pages * num_nodes);
tst_res(TINFO, "Start to test KSM with merge_across_nodes=1");
SAFE_FILE_PRINTF(PATH_KSM "merge_across_nodes", "1");
SAFE_FILE_PRINTF(PATH_KSM "run", "1");
--
2.24.0
next reply other threads:[~2019-11-28 16:31 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-11-28 16:31 Martin Doucha [this message]
2019-11-29 6:49 ` [LTP] [PATCH] Unshare KSM pages before setting max_page_sharing Li Wang
2019-12-02 3:29 ` Petr Vorel
2019-12-02 3:57 ` Li Wang
2019-12-04 9:07 ` Martin Doucha
2019-12-04 10:46 ` Petr Vorel
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=20191128163147.4377-1-mdoucha@suse.cz \
--to=mdoucha@suse.cz \
--cc=ltp@lists.linux.it \
/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