[LTP] [PATCH 5/7] mem/ksm06: Move ksm restoration into the tst_test struct

Cyril Hrubis chrubis@suse.cz
Thu Mar 3 15:50:30 CET 2022


Signed-off-by: Cyril Hrubis <chrubis@suse.cz>
---
 testcases/kernel/mem/ksm/ksm06.c | 28 +++-------------------------
 1 file changed, 3 insertions(+), 25 deletions(-)

diff --git a/testcases/kernel/mem/ksm/ksm06.c b/testcases/kernel/mem/ksm/ksm06.c
index 61507b2aa..f5f7319d7 100644
--- a/testcases/kernel/mem/ksm/ksm06.c
+++ b/testcases/kernel/mem/ksm/ksm06.c
@@ -39,9 +39,6 @@
 #ifdef HAVE_NUMA_V2
 #include <numaif.h>
 
-static int run = -1;
-static int sleep_millisecs = -1;
-static int merge_across_nodes = -1;
 static unsigned long nr_pages = 100;
 
 static char *n_opt;
@@ -141,27 +138,6 @@ static void setup(void)
 
 	if (n_opt)
 		nr_pages = SAFE_STRTOUL(n_opt, 0, ULONG_MAX);
-
-	/* save the current value */
-	SAFE_FILE_SCANF(PATH_KSM "run", "%d", &run);
-	SAFE_FILE_SCANF(PATH_KSM "merge_across_nodes",
-			"%d", &merge_across_nodes);
-	SAFE_FILE_SCANF(PATH_KSM "sleep_millisecs",
-			"%d", &sleep_millisecs);
-}
-
-static void cleanup(void)
-{
-	if (merge_across_nodes != -1) {
-		FILE_PRINTF(PATH_KSM "merge_across_nodes",
-			    "%d", merge_across_nodes);
-	}
-
-	if (sleep_millisecs != -1)
-		FILE_PRINTF(PATH_KSM "sleep_millisecs", "%d", sleep_millisecs);
-
-	if (run != -1)
-		FILE_PRINTF(PATH_KSM "run", "%d", run);
 }
 
 static struct tst_test test = {
@@ -171,9 +147,11 @@ static struct tst_test test = {
 		{}
 	},
 	.setup = setup,
-	.cleanup = cleanup,
 	.save_restore = (const char * const[]) {
 		"?/sys/kernel/mm/ksm/max_page_sharing",
+		"?/sys/kernel/mm/ksm/run",
+		"?/sys/kernel/mm/ksm/merge_across_nodes",
+		"?/sys/kernel/mm/ksm/sleep_millisecs",
 		NULL,
 	},
 	.test_all = test_ksm,
-- 
2.34.1



More information about the ltp mailing list