Skip to contentSkip to conversation

selftests: vm: a few fixup patches

PATCH Applied Patrick Wang 1 participant 4 messages May 21, 2022

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

cover selftests: vm: a few fixup patches

This series contains three fixup patches for vm selftests. They are independent. Please see the patches.

Patrick Wang (3):
selftests: vm: check numa_available() before operating
"merge_across_nodes" in ksm_tests
selftests: vm: add "test_hmm.sh" to TEST_FILES
selftests: vm: add the "settings" file with timeout variable

 tools/testing/selftests/vm/Makefile    | 1 +
 tools/testing/selftests/vm/ksm_tests.c | 9 ++++++---
 tools/testing/selftests/vm/settings    | 1 +
 3 files changed, 8 insertions(+), 3 deletions(-)
 create mode 100644 tools/testing/selftests/vm/settings
Signature · 1 line
2.25.1
#1 lore raw

PATCH 1/3 selftests: vm: check numa_available() before operating "merge_across_nodes" in ksm_tests

Currently, ksm_tests operates "merge_across_nodes" with NUMA either enabled or disabled. In a system with NUMA disabled, these operations will fail and output a misleading report given "merge_across_nodes" does not exist in sysfs:

----------------------------
running ./ksm_tests -M -p 10
----------------------------
f /sys/kernel/mm/ksm/merge_across_nodes
fopen: No such file or directory
Cannot save default tunables
[FAIL]
----------------------

So check numa_available() before those operations to skip them if NUMA is disabled.

---
 tools/testing/selftests/vm/ksm_tests.c | 9 ++++++---
 1 file changed, 6 insertions(+), 3 deletions(-)
tools/testing/selftests/vm/ksm_tests.c +6 -3
index fd85f15869d1..2fcf24312da8 100644
@@ -221,7 +221,8 @@ static bool assert_ksm_pages_count(long dupl_page_count)
 static int ksm_save_def(struct ksm_sysfs *ksm_sysfs)
 {
 	if (ksm_read_sysfs(KSM_FP("max_page_sharing"), &ksm_sysfs->max_page_sharing) ||
-	    ksm_read_sysfs(KSM_FP("merge_across_nodes"), &ksm_sysfs->merge_across_nodes) ||
+	    numa_available() ? 0 :
+		ksm_read_sysfs(KSM_FP("merge_across_nodes"), &ksm_sysfs->merge_across_nodes) ||
 	    ksm_read_sysfs(KSM_FP("sleep_millisecs"), &ksm_sysfs->sleep_millisecs) ||
 	    ksm_read_sysfs(KSM_FP("pages_to_scan"), &ksm_sysfs->pages_to_scan) ||
 	    ksm_read_sysfs(KSM_FP("run"), &ksm_sysfs->run) ||
@@ -236,7 +237,8 @@ static int ksm_save_def(struct ksm_sysfs *ksm_sysfs)
 static int ksm_restore(struct ksm_sysfs *ksm_sysfs)
 {
 	if (ksm_write_sysfs(KSM_FP("max_page_sharing"), ksm_sysfs->max_page_sharing) ||
-	    ksm_write_sysfs(KSM_FP("merge_across_nodes"), ksm_sysfs->merge_across_nodes) ||
+	    numa_available() ? 0 :
+		ksm_write_sysfs(KSM_FP("merge_across_nodes"), ksm_sysfs->merge_across_nodes) ||
 	    ksm_write_sysfs(KSM_FP("pages_to_scan"), ksm_sysfs->pages_to_scan) ||
 	    ksm_write_sysfs(KSM_FP("run"), ksm_sysfs->run) ||
 	    ksm_write_sysfs(KSM_FP("sleep_millisecs"), ksm_sysfs->sleep_millisecs) ||
@@ -720,7 +722,8 @@ int main(int argc, char *argv[])
 
 	if (ksm_write_sysfs(KSM_FP("run"), 2) ||
 	    ksm_write_sysfs(KSM_FP("sleep_millisecs"), 0) ||
-	    ksm_write_sysfs(KSM_FP("merge_across_nodes"), 1) ||
+	    numa_available() ? 0 :
+		ksm_write_sysfs(KSM_FP("merge_across_nodes"), 1) ||
 	    ksm_write_sysfs(KSM_FP("pages_to_scan"), page_count))
 		return KSFT_FAIL;
 
Signature · 1 line
2.25.1
#2 lore raw

PATCH 2/3 selftests: vm: add "test_hmm.sh" to TEST_FILES

In reply to Patrick Wang

The "test_hmm.sh" file used by run_vmtests.sh dose not be installed into INSTALL_PATH. Thus run_vmtests.sh can not call it in INSTALL_PATH:

---------------------------
running ./test_hmm.sh smoke
---------------------------
./run_vmtests.sh: line 74: ./test_hmm.sh: No such file or directory [FAIL]
-----------------------

Add "test_hmm.sh" to TEST_FILES so that it will be installed.

---
 tools/testing/selftests/vm/Makefile | 1 +
 1 file changed, 1 insertion(+)
tools/testing/selftests/vm/Makefile +1 -0
index 12897927311e..44f25acfbeca 100644
@@ -92,6 +92,7 @@ endif
 TEST_PROGS := run_vmtests.sh
 
 TEST_FILES := test_vmalloc.sh
+TEST_FILES += test_hmm.sh
 
 KSFT_KHDR_INSTALL := 1
 include ../lib.mk
Signature · 1 line
2.25.1
#3 lore raw

PATCH 3/3 selftests: vm: add the "settings" file with timeout variable

In reply to Patrick Wang

The default "timeout" for one kselftest is 45 seconds, while some cases in run_vmtests.sh require more time. This will cause testing timeout like:

not ok 4 selftests: vm: run_vmtests.sh # TIMEOUT 45 seconds

Therefore, add the "settings" file with timeout variable so users can set the "timeout" value.

---
 tools/testing/selftests/vm/settings | 1 +
 1 file changed, 1 insertion(+)
 create mode 100644 tools/testing/selftests/vm/settings
tools/testing/selftests/vm/settings new file +1 -0
new file mode 100644
index 000000000000..9abfc60e9e6f
@@ -0,0 +1 @@
+timeout=45
Signature · 1 line
2.25.1