[LTP] [PATCH 2/2] ksm06: lock memory about to be merged

Cyril Hrubis chrubis@suse.cz
Mon Feb 28 10:46:59 CET 2022


We have observed sporadic failures of the test in OpenQA in the case
that the memory allocated by the test is large enough (ksm06_2 runs the
test with -n 8000 which on ppc64le with 64k page size amounts to 1GB in
allocated buffers in total) and in the case of bacground load being run
while the test is executed (LTP compilation with suitable -j make
parameter suffices to trigger the conditions).

The culprit is that some of the pages may end up being swapped before
they happen to be merged due to a memory pressure caused by the
background load.

After this patch applied the test seems to be passing regardless the
background load.

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

diff --git a/testcases/kernel/mem/lib/mem.c b/testcases/kernel/mem/lib/mem.c
index 39e3f1791..f1756b34a 100644
--- a/testcases/kernel/mem/lib/mem.c
+++ b/testcases/kernel/mem/lib/mem.c
@@ -565,6 +565,9 @@ void test_ksm_merge_across_nodes(unsigned long nr_pages)
 #endif
 
 		memset(memory[i], 10, length);
+
+		if (mlock(memory[i], length))
+			tst_res(TINFO | TERRNO, "mlock() failed");
 	}
 
 	SAFE_FILE_PRINTF(PATH_KSM "sleep_millisecs", "0");
-- 
2.34.1



More information about the ltp mailing list