[LTP] [PATCH] mem/lib: Keep KSM off when child_alloc() allocate memory in single thread

Li Wang liwang@redhat.com
Tue Jun 21 05:39:52 CEST 2016


We occasionally catch errors like:
oom03       0  TINFO  :  start OOM testing for KSM pages.
oom03       0  TINFO  :  expected victim is 3490.
oom03       6  TFAIL  :  mem.c:163: victim unexpectedly ended with retcode: 0, expected: 12
oom03       0  TINFO  :  set overcommit_memory to 0

It cames from the caller testoom(0, 1, ENOMEM, 1). The issue was occurred
because child_alloc() go into single(lite == 1) thread mode but successfully
finish the memory allocation and return 0. A probably reason is that KSM
scan merged same pages and disturbed the OOM test in cgroup.

In this patch, keep KSM scan off to prevent OOM test in cgroup distrubing.

Signed-off-by: Li Wang <liwang@redhat.com>
---
 testcases/kernel/mem/lib/mem.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/testcases/kernel/mem/lib/mem.c b/testcases/kernel/mem/lib/mem.c
index 3d853a3..b43b7f8 100644
--- a/testcases/kernel/mem/lib/mem.c
+++ b/testcases/kernel/mem/lib/mem.c
@@ -230,7 +230,9 @@ void testoom(int mempolicy, int lite, int retcode, int allow_sigkill)
 	} else {
 		tst_resm(TINFO, "start OOM testing for KSM pages.");
 		SAFE_FILE_SCANF(cleanup, PATH_KSM "run", "%d", &ksm_run_orig);
-		SAFE_FILE_PRINTF(cleanup, PATH_KSM "run", "1");
+		/* Let KSM off if lite == 1, since limit_in_bytes may vary from
+		 * run to run, which isn't reliable for oom03 cgroup test.*/
+		if (!lite) SAFE_FILE_PRINTF(cleanup, PATH_KSM "run", "1");
 		oom(KSM, lite, retcode, allow_sigkill);
 		SAFE_FILE_PRINTF(cleanup,PATH_KSM "run", "%d", ksm_run_orig);
 	}
-- 
1.8.3.1



More information about the ltp mailing list