Skip to contentSkip to conversation

KSM: support smart-scan feature

PATCH In review Stefan Roesch 2 participants 4 messages Dec 5, 2023 Memory management

lore
Share & tools
lore
#0 lore raw

v4 cover KSM: support smart-scan feature

This patch series makes two changes:
- Disable the smart-scan feature for ksm01 - ksm04
This is necessary to make sure that the volatile metrics have the expected counts.
- Add a new test for the smart-scan feature
The new test verifies that the smart-scan feature skips pages when it has been enabled for a VMA.

Versions:
- V4:
- no changes to first patch

- Changed header documentation
- Fixed includes
- Renamed create_memory() to verify_ksm(), orignal verify_ksm() has been removed
- Remove loop in verify_ksm
- Remove wait at the end
- Call madvise at the end of the function
- Remove needs_fork

- V3:
- Disable smart scan for ksm05 and ksm06
- add ksm07 to runtest/mm
- change documentation format in header of ksm07.c
- Move function create_memory_for_smartscan() to ksm07.c
- Rename create_memory_for_smartscan() to create_memory()

- V2:
- Disable smart_scan in the test setup structure
- Remove the changes in create_same_memory()
- Add the new testcase ksm07 for the smart scan test

*** BLURB HERE ***

Stefan Roesch (2):
mem: disable KSM smart scan for ksm tests
add ksm test for smart-scan feature

 runtest/mm                       |   1 +
 testcases/kernel/mem/.gitignore  |   1 +
 testcases/kernel/mem/ksm/ksm01.c |   2 +
 testcases/kernel/mem/ksm/ksm02.c |   2 +
 testcases/kernel/mem/ksm/ksm03.c |   2 +
 testcases/kernel/mem/ksm/ksm04.c |   2 +
 testcases/kernel/mem/ksm/ksm05.c |   2 +
 testcases/kernel/mem/ksm/ksm06.c |   2 +
 testcases/kernel/mem/ksm/ksm07.c | 113 +++++++++++++++++++++++++++++++
 9 files changed, 127 insertions(+)
 create mode 100644 testcases/kernel/mem/ksm/ksm07.c

base-commit: 8c89ef3d451087ed6e18750bd5eedd10e5ab3d2e

Signature · 1 line
2.39.3
#1 lore raw

PATCH v4 1/2 mem: disable KSM smart scan for ksm tests

This disables the "smart scan" KSM feature to make sure that the volatile count remains at 0.

---
 testcases/kernel/mem/ksm/ksm01.c | 2 ++
 testcases/kernel/mem/ksm/ksm02.c | 2 ++
 testcases/kernel/mem/ksm/ksm03.c | 2 ++
 testcases/kernel/mem/ksm/ksm04.c | 2 ++
 testcases/kernel/mem/ksm/ksm05.c | 2 ++
 testcases/kernel/mem/ksm/ksm06.c | 2 ++
 6 files changed, 12 insertions(+)
testcases/kernel/mem/ksm/ksm01.c +2 -0
index bcd095865..e2d3d9e00 100644
@@ -86,6 +86,8 @@ static struct tst_test test = {
 			TST_SR_SKIP_MISSING | TST_SR_TCONF_RO},
 		{"/sys/kernel/mm/ksm/merge_across_nodes", "1",
 			TST_SR_SKIP_MISSING | TST_SR_TCONF_RO},
+		{"/sys/kernel/mm/ksm/smart_scan", "0",
+			TST_SR_SKIP_MISSING | TST_SR_TBROK_RO},
 		{}
 	},
 	.needs_kconfigs = (const char *const[]){
testcases/kernel/mem/ksm/ksm02.c +2 -0
index bce639dce..3707de95d 100644
@@ -107,6 +107,8 @@ static struct tst_test test = {
 			TST_SR_SKIP_MISSING | TST_SR_TCONF_RO},
 		{"/sys/kernel/mm/ksm/merge_across_nodes", "1",
 			TST_SR_SKIP_MISSING | TST_SR_TCONF_RO},
+		{"/sys/kernel/mm/ksm/smart_scan", "0",
+			TST_SR_SKIP_MISSING | TST_SR_TBROK_RO},
 		{}
 	},
 	.needs_kconfigs = (const char *const[]){
testcases/kernel/mem/ksm/ksm03.c +2 -0
index 4a733269f..cff74700d 100644
@@ -89,6 +89,8 @@ static struct tst_test test = {
 			TST_SR_SKIP_MISSING | TST_SR_TCONF_RO},
 		{"/sys/kernel/mm/ksm/merge_across_nodes", "1",
 			TST_SR_SKIP_MISSING | TST_SR_TCONF_RO},
+		{"/sys/kernel/mm/ksm/smart_scan", "0",
+			TST_SR_SKIP_MISSING | TST_SR_TBROK_RO},
 		{}
 	},
 	.needs_kconfigs = (const char *const[]){
testcases/kernel/mem/ksm/ksm04.c +2 -0
index 4f1f2f721..9935e32d7 100644
@@ -109,6 +109,8 @@ static struct tst_test test = {
 			TST_SR_SKIP_MISSING | TST_SR_TCONF_RO},
 		{"/sys/kernel/mm/ksm/merge_across_nodes", "1",
 			TST_SR_SKIP_MISSING | TST_SR_TCONF_RO},
+		{"/sys/kernel/mm/ksm/smart_scan", "0",
+			TST_SR_SKIP_MISSING | TST_SR_TBROK_RO},
 		{}
 	},
 	.needs_kconfigs = (const char *const[]){
testcases/kernel/mem/ksm/ksm05.c +2 -0
index 1f58c8325..61e740843 100644
@@ -89,6 +89,8 @@ static struct tst_test test = {
 	.test_all = test_ksm,
 	.save_restore = (const struct tst_path_val[]) {
 		{"/sys/kernel/mm/ksm/run", "1", TST_SR_TBROK},
+		{"/sys/kernel/mm/ksm/smart_scan", "0",
+			TST_SR_SKIP_MISSING | TST_SR_TBROK_RO},
 		{}
 	},
 	.needs_kconfigs = (const char *const[]){
testcases/kernel/mem/ksm/ksm06.c +2 -0
index 0b159e5c7..80fdf1e47 100644
@@ -142,6 +142,8 @@ static struct tst_test test = {
 		{"/sys/kernel/mm/ksm/run", NULL, TST_SR_TBROK},
 		{"/sys/kernel/mm/ksm/sleep_millisecs", NULL, TST_SR_TBROK},
 		{"/sys/kernel/mm/ksm/merge_across_nodes", NULL, TST_SR_TCONF},
+		{"/sys/kernel/mm/ksm/smart_scan", "0",
+			TST_SR_SKIP_MISSING | TST_SR_TBROK_RO},
 		{}
 	},
 	.needs_kconfigs = (const char *const[]){
Signature · 1 line
2.39.3
#2 lore raw

PATCH v4 2/2 add ksm test for smart-scan feature

In reply to Stefan Roesch

This adds a new ksm (kernel samepage merging) test to evaluate the new smart scan feature. It allocates a page and fills it with 'a' characters. It captures the pages_skipped counter, waits for a few iterations and captures the pages_skipped counter again. The expectation is that over 50% of the page scans are skipped (There is only one page that has KSM enabled and it gets scanned during each iteration and it cannot be de-duplicated).

---
 runtest/mm                       |   1 +
 testcases/kernel/mem/.gitignore  |   1 +
 testcases/kernel/mem/ksm/ksm07.c | 113 +++++++++++++++++++++++++++++++
 3 files changed, 115 insertions(+)
 create mode 100644 testcases/kernel/mem/ksm/ksm07.c
runtest/mm +1 -0
index f288fed36..d859b331c 100644
@@ -70,6 +70,7 @@ ksm05 ksm05 -I 10
 ksm06 ksm06
 ksm06_1 ksm06 -n 10
 ksm06_2 ksm06 -n 8000
+ksm07 ksm07
 
 cpuset01 cpuset01
 
testcases/kernel/mem/.gitignore +1 -0
index 7258489ed..c96fe8bfc 100644
@@ -53,6 +53,7 @@
 /ksm/ksm04
 /ksm/ksm05
 /ksm/ksm06
+/ksm/ksm07
 /mem/mem02
 /mmapstress/mmap-corruption01
 /mmapstress/mmapstress01
testcases/kernel/mem/ksm/ksm07.c new file +113 -0

113 lines not on this page · raw message

Signature · 1 line
2.39.3
#3 lore raw

Re: [PATCH v4 2/2] add ksm test for smart-scan feature

Hi Stefan,

Quoted 7 lines

This adds a new ksm (kernel samepage merging) test to evaluate the new smart scan feature. It allocates a page and fills it with 'a' characters. It captures the pages_skipped counter, waits for a few iterations and captures the pages_skipped counter again. The expectation is that over 50% of the page scans are skipped (There is only one page that has KSM enabled and it gets scanned during each iteration and it cannot be de-duplicated).

Thanks a lot, merged. We really appreciate when kernel developers writing new tests.

(The previous patch was merged already as v3).

Kind regards,
Petr