diff mbox series

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

Message ID 20220228094659.21959-3-chrubis@suse.cz
State Accepted
Headers show
Series ksm06 fixes | expand

Commit Message

Cyril Hrubis Feb. 28, 2022, 9:46 a.m. UTC
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(+)

Comments

Petr Vorel Feb. 28, 2022, 1:16 p.m. UTC | #1
Hi Cyril,

Reviewed-by: Petr Vorel <pvorel@suse.cz>
Good catch!

> 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");
I'd consider using TWARN.

Kind regards,
Petr
Li Wang March 1, 2022, 3:18 a.m. UTC | #2
This patchset looks pretty good if go with Petr's suggestions.

Reviewed-by: Li Wang <liwang@redhat.com>
Cyril Hrubis March 1, 2022, 8:09 a.m. UTC | #3
Hi!
Fixed the typo and changed the TINFO to TWARN and pushed.

Thanks for the review.
diff mbox series

Patch

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");