<div dir="ltr"><div dir="ltr"><div class="gmail_default" style="font-size:small"><br></div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Mon, Mar 7, 2022 at 4:56 PM Cyril Hrubis <<a href="mailto:chrubis@suse.cz">chrubis@suse.cz</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">Hi!<br>
> > > But for the two knobs(run, sleep_millisecs) that should exist unless<br>
> > > the kernel disables KSM. So here we'd better start with prefix '!' and<br>
> > > add .needs_kconfg for ???CONFIG_KSM=y' check.<br>
> > > (This also fit for other ksm tests)<br>
> ><br>
> > I guess that if we put ! before the merge_across_nodes that would cause<br>
> > TBROK on systems without CONFIG_NUMA or kernels without that feature.<br>
> ><br>
> > So what about just removing the question marks there and adding<br>
> > .need_kconfigs for KSM and NUMA?<br>
> ><br>
> <br>
> Er, that's exactly what I meant in the last email, maybe you overlooked<br>
> the last sentence:).<br>
> <br>
> i.e.<br>
> <br>
> "<br>
> prefix ! for 'run' and 'sleep_milisecs'<br>
> no prefix for 'merge_across_nodes'<br>
> .need_kconfigs for KSM and NUMA<br>
> "<br>
<br>
Ah, right, sorry. What about this:<br>
<br>
diff --git a/testcases/kernel/mem/ksm/ksm06.c b/testcases/kernel/mem/ksm/ksm06.c<br>
index 61507b2aa..e734786c1 100644<br>
--- a/testcases/kernel/mem/ksm/ksm06.c<br>
+++ b/testcases/kernel/mem/ksm/ksm06.c<br>
@@ -39,9 +39,6 @@<br>
#ifdef HAVE_NUMA_V2<br>
#include <numaif.h><br>
<br>
-static int run = -1;<br>
-static int sleep_millisecs = -1;<br>
-static int merge_across_nodes = -1;<br>
static unsigned long nr_pages = 100;<br>
<br>
static char *n_opt;<br>
@@ -133,35 +130,11 @@ static void test_ksm(void)<br>
<br>
static void setup(void)<br>
{<br>
- if (access(PATH_KSM "merge_across_nodes", F_OK) == -1)<br>
- tst_brk(TCONF, "no merge_across_nodes sysfs knob");<br>
-<br>
if (!is_numa(NULL, NH_MEMS, 2))<br>
tst_brk(TCONF, "The case needs a NUMA system.");<br>
<br>
if (n_opt)<br>
nr_pages = SAFE_STRTOUL(n_opt, 0, ULONG_MAX);<br>
-<br>
- /* save the current value */<br>
- SAFE_FILE_SCANF(PATH_KSM "run", "%d", &run);<br>
- SAFE_FILE_SCANF(PATH_KSM "merge_across_nodes",<br>
- "%d", &merge_across_nodes);<br>
- SAFE_FILE_SCANF(PATH_KSM "sleep_millisecs",<br>
- "%d", &sleep_millisecs);<br>
-}<br>
-<br>
-static void cleanup(void)<br>
-{<br>
- if (merge_across_nodes != -1) {<br>
- FILE_PRINTF(PATH_KSM "merge_across_nodes",<br>
- "%d", merge_across_nodes);<br>
- }<br>
-<br>
- if (sleep_millisecs != -1)<br>
- FILE_PRINTF(PATH_KSM "sleep_millisecs", "%d", sleep_millisecs);<br>
-<br>
- if (run != -1)<br>
- FILE_PRINTF(PATH_KSM "run", "%d", run);<br>
}<br>
<br>
static struct tst_test test = {<br>
@@ -171,11 +144,18 @@ static struct tst_test test = {<br>
{}<br>
},<br>
.setup = setup,<br>
- .cleanup = cleanup,<br>
.save_restore = (const char * const[]) {<br>
"?/sys/kernel/mm/ksm/max_page_sharing",<br>
+ "!/sys/kernel/mm/ksm/run",<br>
+ "!/sys/kernel/mm/ksm/sleep_millisecs",<br>
+ "/sys/kernel/mm/ksm/merge_across_nodes",<br>
NULL,<br>
},<br>
+ .needs_kconfigs = (const char *const[]){<br>
+ "CONFIG_KSM=y",<br>
+ "CONFIG_NUMA=y",<br>
+ NULL<br>
+ },<br>
.test_all = test_ksm,<br>
};<br>
<br>
<br>
If we add merge_across_nodes without any prefix we can as well remove<br>
the check for the file existence in the test setup.<br></blockquote><div><br></div><div class="gmail_default" style="font-size:small">ACK.</div></div><div><br></div>-- <br><div dir="ltr" class="gmail_signature"><div dir="ltr"><div>Regards,<br></div><div>Li Wang<br></div></div></div></div>