Skip to content

Commit

Permalink
tunable: make use of save_restore
Browse files Browse the repository at this point in the history
SAFE_ACCESS requires the pathname is exist otherwise TBROK.
so let's use TST_SR_TBROK in save_restore.

Suggested-by: Petr Vorel <pvorel@suse.cz>
Signed-off-by: Li Wang <liwang@redhat.com>
Reviewed-by: Petr Vorel <pvorel@suse.cz>
  • Loading branch information
wangli5665 committed Jun 23, 2023
1 parent 8da6a94 commit 3f0b217
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 24 deletions.
18 changes: 1 addition & 17 deletions testcases/kernel/mem/tunable/max_map_count.c
Original file line number Diff line number Diff line change
Expand Up @@ -53,21 +53,6 @@
#define MAP_COUNT_DEFAULT 1024
#define MAX_MAP_COUNT 65536L

static long old_max_map_count = -1;

static void setup(void)
{
SAFE_ACCESS(PATH_SYSVM "max_map_count", F_OK);

old_max_map_count = get_sys_tune("max_map_count");
}

static void cleanup(void)
{
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.
*/
Expand Down Expand Up @@ -205,11 +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},
{}
},
};
8 changes: 1 addition & 7 deletions testcases/kernel/mem/tunable/min_free_kbytes.c
Original file line number Diff line number Diff line change
Expand Up @@ -218,21 +218,15 @@ static void setup(void)
default_tune = get_sys_tune("min_free_kbytes");
}

static void cleanup(void)
{
if (default_tune != -1)
set_sys_tune("min_free_kbytes", default_tune, 0);
}

static struct tst_test test = {
.needs_root = 1,
.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},
{}
},
};

0 comments on commit 3f0b217

Please sign in to comment.