aboutsummaryrefslogtreecommitdiff
path: root/testcases/kernel/mem/tunable
diff options
context:
space:
mode:
Diffstat (limited to 'testcases/kernel/mem/tunable')
-rw-r--r--testcases/kernel/mem/tunable/max_map_count.c27
-rw-r--r--testcases/kernel/mem/tunable/min_free_kbytes.c16
-rw-r--r--testcases/kernel/mem/tunable/overcommit_memory.c20
3 files changed, 15 insertions, 48 deletions
diff --git a/testcases/kernel/mem/tunable/max_map_count.c b/testcases/kernel/mem/tunable/max_map_count.c
index caf8972e0..f33095473 100644
--- a/testcases/kernel/mem/tunable/max_map_count.c
+++ b/testcases/kernel/mem/tunable/max_map_count.c
@@ -53,26 +53,6 @@
#define MAP_COUNT_DEFAULT 1024
#define MAX_MAP_COUNT 65536L
-static long old_max_map_count = -1;
-static long old_overcommit = -1;
-
-static void setup(void)
-{
- SAFE_ACCESS(PATH_SYSVM "max_map_count", F_OK);
-
- old_max_map_count = get_sys_tune("max_map_count");
- old_overcommit = get_sys_tune("overcommit_memory");
- set_sys_tune("overcommit_memory", 0, 1);
-}
-
-static void cleanup(void)
-{
- if (old_overcommit != -1)
- set_sys_tune("overcommit_memory", old_overcommit, 0);
- if (old_max_map_count != -1)
- set_sys_tune("max_map_count", old_max_map_count, 0);
-}
-
/* This is a filter to exclude map entries which aren't accounted
* for in the vm_area_struct's map_count.
*/
@@ -210,7 +190,10 @@ static void max_map_count_test(void)
static struct tst_test test = {
.needs_root = 1,
.forks_child = 1,
- .setup = setup,
- .cleanup = cleanup,
.test_all = max_map_count_test,
+ .save_restore = (const struct tst_path_val[]) {
+ {"/proc/sys/vm/overcommit_memory", "0", TST_SR_TBROK},
+ {"/proc/sys/vm/max_map_count", NULL, TST_SR_TBROK},
+ {}
+ },
};
diff --git a/testcases/kernel/mem/tunable/min_free_kbytes.c b/testcases/kernel/mem/tunable/min_free_kbytes.c
index eab6c8b2e..19da409e8 100644
--- a/testcases/kernel/mem/tunable/min_free_kbytes.c
+++ b/testcases/kernel/mem/tunable/min_free_kbytes.c
@@ -41,7 +41,6 @@
volatile int end;
static long default_tune = -1;
-static long orig_overcommit = -1;
static unsigned long total_mem;
static void test_tune(unsigned long overcommit_policy);
@@ -217,15 +216,6 @@ static void setup(void)
total_mem = SAFE_READ_MEMINFO("MemTotal:") + SAFE_READ_MEMINFO("SwapTotal:");
default_tune = get_sys_tune("min_free_kbytes");
- orig_overcommit = get_sys_tune("overcommit_memory");
-}
-
-static void cleanup(void)
-{
- if (default_tune != -1)
- set_sys_tune("min_free_kbytes", default_tune, 0);
- if (orig_overcommit != -1)
- set_sys_tune("overcommit_memory", orig_overcommit, 0);
}
static struct tst_test test = {
@@ -233,6 +223,10 @@ static struct tst_test test = {
.forks_child = 1,
.max_runtime = TST_UNLIMITED_RUNTIME,
.setup = setup,
- .cleanup = cleanup,
.test_all = min_free_kbytes_test,
+ .save_restore = (const struct tst_path_val[]) {
+ {"/proc/sys/vm/overcommit_memory", NULL, TST_SR_TBROK},
+ {"/proc/sys/vm/min_free_kbytes", NULL, TST_SR_TBROK},
+ {}
+ },
};
diff --git a/testcases/kernel/mem/tunable/overcommit_memory.c b/testcases/kernel/mem/tunable/overcommit_memory.c
index 7fe8fe14c..ffb7a6d9d 100644
--- a/testcases/kernel/mem/tunable/overcommit_memory.c
+++ b/testcases/kernel/mem/tunable/overcommit_memory.c
@@ -70,7 +70,6 @@
#define EXPECT_FAIL 1
static char *R_opt;
-static long old_overcommit_memory = -1;
static long old_overcommit_ratio = -1;
static long overcommit_ratio;
static long sum_total;
@@ -90,16 +89,11 @@ static void setup(void)
long mem_total, swap_total;
struct rlimit lim;
- if (access(PATH_SYSVM "overcommit_memory", F_OK) == -1 ||
- access(PATH_SYSVM "overcommit_ratio", F_OK) == -1)
- tst_brk(TCONF, "system doesn't support overcommit_memory");
-
if (R_opt)
overcommit_ratio = SAFE_STRTOL(R_opt, 0, LONG_MAX);
else
overcommit_ratio = DEFAULT_OVER_RATIO;
- old_overcommit_memory = get_sys_tune("overcommit_memory");
old_overcommit_ratio = get_sys_tune("overcommit_ratio");
mem_total = SAFE_READ_MEMINFO("MemTotal:");
@@ -128,14 +122,6 @@ static void setup(void)
tst_res(TINFO, "TotalBatchSize is %ld kB", total_batch_size);
}
-static void cleanup(void)
-{
- if (old_overcommit_memory != -1)
- set_sys_tune("overcommit_memory", old_overcommit_memory, 0);
- if (old_overcommit_ratio != -1)
- set_sys_tune("overcommit_ratio", old_overcommit_ratio, 0);
-}
-
static void overcommit_memory_test(void)
{
@@ -269,6 +255,10 @@ static struct tst_test test = {
{}
},
.setup = setup,
- .cleanup = cleanup,
.test_all = overcommit_memory_test,
+ .save_restore = (const struct tst_path_val[]) {
+ {"/proc/sys/vm/overcommit_memory", NULL, TST_SR_TBROK},
+ {"/proc/sys/vm/overcommit_ratio", NULL, TST_SR_TBROK},
+ {}
+ },
};