add KSM selftests
Subsystems (2)
cover add KSM selftests
As a part of the Outreachy internship project, add unit tests for Kernel Samepage Merging. More tests to be added later; they would focus on unmerging, handling zero pages and pages in different NUMA nodes.
Zhansaya Bagdauletkyzy (1):
selftests: vm: add KSM tests
tools/testing/selftests/vm/.gitignore | 1 + tools/testing/selftests/vm/Makefile | 1 + tools/testing/selftests/vm/ksm_tests.c | 289 ++++++++++++++++++++++ tools/testing/selftests/vm/run_vmtests.sh | 16 ++ 4 files changed, 307 insertions(+) create mode 100644 tools/testing/selftests/vm/ksm_tests.c
Signature · 1 line
2.25.1
PATCH 1/1 selftests: vm: add KSM tests
Introduce selftests to validate the functionality of KSM. The function check_ksm_merge() tests the MADV_MERGEABLE advice of madvise syscall. The test is run on private anonymous pages that have read and write access. Since some KSM tunables are modified, their starting values are saved and restored after testing. At the start, run is set to 2 to ensure that only test pages will be merged (we assume that no applications make madvise syscalls in the background). If KSM config not enabled, then the test is skipped.
--- tools/testing/selftests/vm/.gitignore | 1 + tools/testing/selftests/vm/Makefile | 1 + tools/testing/selftests/vm/ksm_tests.c | 289 ++++++++++++++++++++++ tools/testing/selftests/vm/run_vmtests.sh | 16 ++ 4 files changed, 307 insertions(+) create mode 100644 tools/testing/selftests/vm/ksm_tests.c
tools/testing/selftests/vm/.gitignore +1 -0
@@ -23,3 +23,4 @@ write_to_hugetlbfs hmm-tests local_config.* split_huge_page_test +ksm_tests
tools/testing/selftests/vm/Makefile +1 -0
@@ -43,6 +43,7 @@ TEST_GEN_FILES += thuge-gen TEST_GEN_FILES += transhuge-stress TEST_GEN_FILES += userfaultfd TEST_GEN_FILES += split_huge_page_test +TEST_GEN_FILES += ksm_tests ifeq ($(MACHINE),x86_64) CAN_BUILD_I386 := $(shell ./../x86/check_cc.sh $(CC) ../x86/trivial_32bit_program.c -m32)
tools/testing/selftests/vm/ksm_tests.c new file +289 -0
289 lines not on this page · raw message
tools/testing/selftests/vm/run_vmtests.sh +16 -0
@@ -346,4 +346,20 @@ else exitcode=1 fi +echo "------------------------------------" +echo "running KSM tests" +echo "------------------------------------" +./ksm_tests +ret_val=$? + +if [ $ret_val -eq 0 ]; then + echo "[PASS]" +elif [ $ret_val -eq $ksft_skip ]; then + echo "[SKIP]" + exitcode=$ksft_skip +else + echo "[FAIL]" + exitcode=1 +fi + exit $exitcode
Signature · 1 line
2.25.1