Skip to contentSkip to conversation

ksm06 fixes

PATCH In review Cyril Hrubis 3 participants 9 messages Feb 28, 2022 – Mar 1, 2022

lore
Share & tools
lore
#0 lore raw

cover ksm06 fixes

Two minor fixes for the ksm06 test.

Also it looks like the test_ksm_merge_across_nodes() is only called from the ksm06 test so it does not make that much sense for the code to be in the mem.c library. I guess that we should move it to the test source so that it's not hidden in the library as well.

Cyril Hrubis (2):
ksm06: Free memory at the end of the test
ksm06: lock memory about to be merged

 testcases/kernel/mem/lib/mem.c | 8 ++++++++
 1 file changed, 8 insertions(+)
Signature · 5 lines
2.34.1


-- 
Mailing list info: https://lists.linux.it/listinfo/ltp
#1 lore raw

PATCH 1/2 ksm06: Free memory at the end of the test

Fixes the kms06 run with -i 2.

---
 testcases/kernel/mem/lib/mem.c | 5 +++++
 1 file changed, 5 insertions(+)
testcases/kernel/mem/lib/mem.c +5 -0
index 99d5f7f53..39e3f1791 100644
@@ -594,6 +594,11 @@ void test_ksm_merge_across_nodes(unsigned long nr_pages)
 		    0, 0, 0, nr_pages * num_nodes);
 
 	SAFE_FILE_PRINTF(PATH_KSM "run", "2");
+
+	for (i = 0; i < num_nodes; i++)
+		SAFE_MUNMAP(memory[i], length);
+
+	free(memory);
 }
 
 /* THP */
Signature · 5 lines
2.34.1


-- 
Mailing list info: https://lists.linux.it/listinfo/ltp
Reviewed-by on v1 1/2
#2 lore raw

Re: [LTP] [PATCH 1/2] ksm06: Free memory at the end of the test

Hi Cyril,

obviously correct.

Quoted 1 line

Fixes the kms06 run with -i 2.

typo: s/kms06/ksm06/g

Kind regards,
Petr

Signature · 1 line
Mailing list info: https://lists.linux.it/listinfo/ltp
#3 lore raw

PATCH 2/2 ksm06: lock memory about to be merged

In reply to Cyril Hrubis

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.

---
 testcases/kernel/mem/lib/mem.c | 3 +++
 1 file changed, 3 insertions(+)
testcases/kernel/mem/lib/mem.c +3 -0
index 39e3f1791..f1756b34a 100644
@@ -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");
Signature · 5 lines
2.34.1


-- 
Mailing list info: https://lists.linux.it/listinfo/ltp
Reviewed-by on v1 2/2
#4 lore raw

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

Hi Cyril,

Good catch!

Quoted 10 lines
---
 testcases/kernel/mem/lib/mem.c | 3 +++
 1 file changed, 3 insertions(+)
testcases/kernel/mem/lib/mem.c +0 -0
index 39e3f1791..f1756b34a 100644

testcases/kernel/mem/lib/mem.c void test_ksm_merge_across_nodes(unsigned long nr_pages) · line 570

Quoted 6 lines
testcases/kernel/mem/lib/mem.c +3 -0
@@ -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

Signature · 1 line
Mailing list info: https://lists.linux.it/listinfo/ltp
Reviewed-by on v1 2/2
#5 lore raw

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

In reply to Cyril Hrubis

This patchset looks pretty good if go with Petr's suggestions.

Signature · 2 lines
Regards,
Li Wang
Signature · 2 lines
-- 
Mailing list info: https://lists.linux.it/listinfo/ltp
#6 lore raw

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

Hi!
Fixed the typo and changed the TINFO to TWARN and pushed.

Thanks for the review.

Signature · 5 lines
Cyril Hrubis
[email protected]

-- 
Mailing list info: https://lists.linux.it/listinfo/ltp
#7 lore raw
In reply to Cyril Hrubis

Cyril Hrubis <[email protected]> wrote:

Two minor fixes for the ksm06 test.

Quoted 6 lines

Also it looks like the test_ksm_merge_across_nodes() is only called from the ksm06 test so it does not make that much sense for the code to be in the mem.c library. I guess that we should move it to the test source so that it's not hidden in the library as well.

Absolutely yes, that will make mem library a bit shorten to read, we can do that in a separate patch.
(sorry for overlooking this patch cover letter)

Signature · 2 lines
Regards,
Li Wang
Signature · 2 lines
-- 
Mailing list info: https://lists.linux.it/listinfo/ltp
#8 lore raw

Hi!

Quoted 3 lines

Absolutely yes, that will make mem library a bit shorten to read, we can do that in a separate patch.
(sorry for overlooking this patch cover letter)

I will send another cleanup patchset later on, I wanted the test fixed ASAP which is why I limited the first patchset strictly to obvious fixes.

Signature · 5 lines
Cyril Hrubis
[email protected]

-- 
Mailing list info: https://lists.linux.it/listinfo/ltp