[PATCH v2 2/3] selftests/mm: fix false-positive KSM fork test by dropping init_global_file_handles()
From: Xu Xin (vivo)
Date: Fri Nov 20 2026 - 02:45:04 EST
In test_fork_ksm_merging_page_count(), the child process currently calls
init_global_file_handles() before reading ksm_get_self_merging_pages().
However, init_global_file_handles() calls ksm_stop(), which writes 2
(KSM_RUN_UNMERGE) to /sys/kernel/mm/ksm/run, unmerging all KSM pages
across the system and resetting the counters to 0. As a result, the test
always passes regardless of whether fork() properly resets the counter.
Remove the redundant init_global_file_handles().
Fixes: 08ff89b5659d ("selftests/mm: add fork inheritance test for ksm_merging_pages counter")
Cc: stable@xxxxxxxxxxxxxxx
Signed-off-by: Xu Xin (vivo) <xu.xin@xxxxxxxxx>
---
tools/testing/selftests/mm/ksm_functional_tests.c | 1 -
1 file changed, 1 deletion(-)
diff --git a/tools/testing/selftests/mm/ksm_functional_tests.c b/tools/testing/selftests/mm/ksm_functional_tests.c
index 135191f99962..c20982b0aff0 100644
--- a/tools/testing/selftests/mm/ksm_functional_tests.c
+++ b/tools/testing/selftests/mm/ksm_functional_tests.c
@@ -670,7 +670,6 @@ static void test_fork_ksm_merging_page_count(void)
child_pid = fork();
if (!child_pid) {
- init_global_file_handles();
exit(ksm_get_self_merging_pages());
} else if (child_pid < 0) {
ksft_test_result_fail("fork() failed\n");
--
2.34.1