<div dir="ltr">Hi Cyril,<br><div class="gmail_extra"><br><div class="gmail_quote">On Tue, Mar 22, 2016 at 9:14 PM, Cyril Hrubis <span dir="ltr"><<a href="mailto:chrubis@suse.cz" target="_blank">chrubis@suse.cz</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><span class="">> diff --git a/testcases/kernel/mem/include/mem.h b/testcases/kernel/mem/include/mem.h<br>
> index 43988fe..fbb11b2 100644<br>
> --- a/testcases/kernel/mem/include/mem.h<br>
> +++ b/testcases/kernel/mem/include/mem.h<br>
> @@ -43,6 +43,7 @@ void testoom(int mempolicy, int lite, int retcode, int allow_sigkill);<br>
> /* KSM */<br>
><br>
> #define PATH_KSM "/sys/kernel/mm/ksm/"<br>
> +int max_page_sharing;<br>
<br>
</span>This variable is not used in the library. It does not make sense to<br>
declare it in the header file.<br></blockquote><div><br>no, it has been used in mem.c file.<br><br>see here:<br>------------<br>diff --git a/testcases/kernel/mem/lib/<div id=":1f8" class="">mem.c b/testcases/kernel/mem/lib/mem.c<br>
index 7b5bb35..d37d6a4 100644<br>
--- a/testcases/kernel/mem/lib/mem.c<br>
+++ b/testcases/kernel/mem/lib/mem.c<br>
@@ -502,9 +502,12 @@ void create_same_memory(int size, int num, int unit)<br>
stop_ksm_children(child, num);<br>
<br>
tst_resm(TINFO, "KSM merging...");<br>
+ if (access(PATH_KSM "max_page_sharing", F_OK) == 0)<br>
+ SAFE_FILE_PRINTF(cleanup, PATH_KSM "max_page_sharing",<br>
+ "%ld", size * pages * num);<br>
SAFE_FILE_PRINTF(cleanup, PATH_KSM "run", "1");<br>
SAFE_FILE_PRINTF(cleanup, PATH_KSM "pages_to_scan", "%ld",<br>
- size * pages *num);<br>
+ size * pages * num);<br>
SAFE_FILE_PRINTF(cleanup, PATH_KSM "sleep_millisecs", "0");<br>
<br>
resume_ksm_children(child, num);<br>
@@ -595,6 +598,9 @@ void test_ksm_merge_across_nodes(unsigned long nr_pages)<br>
SAFE_FILE_PRINTF(cleanup, PATH_KSM "sleep_millisecs", "0");<br>
SAFE_FILE_PRINTF(cleanup, PATH_KSM "pages_to_scan", "%ld",<br>
nr_pages * num_nodes);<br>
+ if (access(PATH_KSM "max_page_sharing", F_OK) == 0)<br>
+ SAFE_FILE_PRINTF(cleanup, PATH_KSM "max_page_sharing",<br>
+ "%ld", nr_pages * num_nodes);<br><br></div><br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
<span class=""><br>
> void test_ksm_merge_across_nodes(unsigned long nr_pages);<br>
><br>
> diff --git a/testcases/kernel/mem/ksm/ksm01.c b/testcases/kernel/mem/ksm/ksm01.c<br>
> index b62df06..a352abd 100644<br>
> --- a/testcases/kernel/mem/ksm/ksm01.c<br>
> +++ b/testcases/kernel/mem/ksm/ksm01.c<br>
> @@ -105,6 +105,9 @@ void setup(void)<br>
> tst_brkm(TCONF, NULL, "2.6.32 or greater kernel required");<br>
> if (access(PATH_KSM, F_OK) == -1)<br>
> tst_brkm(TCONF, NULL, "KSM configuration is not enabled");<br>
> + if (access(PATH_KSM "max_page_sharing", F_OK) == 0)<br>
> + SAFE_FILE_SCANF(NULL, PATH_KSM "max_page_sharing",<br>
> + "%d", &max_page_sharing);<br>
><br>
> /*<br>
> * kernel commit 90bd6fd introduced a new KSM sysfs knob<br>
> @@ -128,4 +131,8 @@ void cleanup(void)<br>
> if (access(PATH_KSM "merge_across_nodes", F_OK) == 0)<br>
> FILE_PRINTF(PATH_KSM "merge_across_nodes",<br>
> "%d", merge_across_nodes);<br>
> +<br>
> + if (access(PATH_KSM "max_page_sharing", F_OK) == 0)<br>
> + FILE_PRINTF(PATH_KSM "max_page_sharing",<br>
> + "%d", max_page_sharing);<br>
> }<br>
<br>
</span>You are saving and restoring the file in each test. Why can't you just<br>
add two functions to save and restore it the library instead and call<br>
them from test setup and cleanup?<br></blockquote><div><br>ok, that's a better way.<br> </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
<br>
It's also quite confusing that the test saves and restores a value while<br>
it's not modifying it at all. It will be less confusing if it's all done<br>
in the library.<br>
<span class=""><font color="#888888"><br>
--<br>
Cyril Hrubis<br>
<a href="mailto:chrubis@suse.cz">chrubis@suse.cz</a><br>
</font></span></blockquote></div><br><br clear="all"><br>-- <br><div class="gmail_signature"><div dir="ltr"><div><div dir="ltr"><div><div dir="ltr"><div>Regards,<br></div>Li Wang<br></div><div>Email: <a href="mailto:liwang@redhat.com" target="_blank">liwang@redhat.com</a><br></div></div></div></div></div></div>
</div></div>