Skip to content

Commit

Permalink
ksm05: Fix cleanup on mising KSM run sys file
Browse files Browse the repository at this point in the history
If /sys/kernel/mm/ksm/run is not present the cleanup will stil try to
restore it's value and the test will fail with a warning:

tst_test.c:980: INFO: Timeout per run is 0h 15m 00s
ksm05.c:98: CONF: KSM configuration is not enabled
safe_file_ops.c:238: WARN: Failed to open FILE '/sys/kernel/mm/ksm/run' at ksm05.c:110

This patch changes the test to attempt to restore the value only if we
were able to read it first.

Signed-off-by: Cyril Hrubis <chrubis@suse.cz>
Reported-by: Naresh Kamboju <naresh.kamboju@linaro.org>
  • Loading branch information
metan-ucw committed Jun 4, 2018
1 parent 298a984 commit ffc8005
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions testcases/kernel/mem/ksm/ksm05.c
Expand Up @@ -52,7 +52,7 @@

#ifdef HAVE_MADV_MERGEABLE

static int ksm_run_orig;
static int ksm_run_orig = -1;
static void sighandler(int sig);

static void test_ksm(void)
Expand Down Expand Up @@ -107,7 +107,8 @@ static void setup(void)
static void cleanup(void)
{
/* restore /sys/kernel/mm/ksm/run value */
FILE_PRINTF(PATH_KSM "run", "%d", ksm_run_orig);
if (ksm_run_orig > 0)
FILE_PRINTF(PATH_KSM "run", "%d", ksm_run_orig);
}

static struct tst_test test = {
Expand Down

0 comments on commit ffc8005

Please sign in to comment.