From: "Xu Xin (vivo)" <xu.xin@linux.dev>
To: xu.xin@linux.dev
Cc: akpm@linux-foundation.org, chengming.zhou@linux.dev,
david@kernel.org, donettom@linux.ibm.com,
linux-kernel@vger.kernel.org, linux-mm@kvack.org,
stable@vger.kernel.org
Subject: [PATCH v2 2/3] selftests/mm: fix false-positive KSM fork test by dropping init_global_file_handles()
Date: Fri, 20 Nov 2026 15:44:45 +0800 [thread overview]
Message-ID: <20261120074445.41446-1-xu.xin@linux.dev> (raw)
In-Reply-To: <20261120074230.40269-1-xu.xin@linux.dev>
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@vger.kernel.org
Signed-off-by: Xu Xin (vivo) <xu.xin@linux.dev>
---
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
next prev parent reply other threads:[~2026-11-20 7:44 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-20 7:42 [PATCH v2 0/3] mm/ksm: fix ksm_zero_pages accounting on fork Xu Xin (vivo)
2026-11-20 7:43 ` [PATCH v2 1/3] mm/ksm: do not inherit ksm_zero_pages counter or PTE markers " Xu Xin (vivo)
2026-11-20 7:44 ` Xu Xin (vivo) [this message]
2026-11-20 7:44 ` [PATCH v2 3/3] selftests/mm: verify ksm_zero_pages is not inherited " Xu Xin (vivo)
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20261120074445.41446-1-xu.xin@linux.dev \
--to=xu.xin@linux.dev \
--cc=akpm@linux-foundation.org \
--cc=chengming.zhou@linux.dev \
--cc=david@kernel.org \
--cc=donettom@linux.ibm.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=stable@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox