From: Zenghui Yu <zenghui.yu@linux.dev>
To: linux-mm@kvack.org, linux-kselftest@vger.kernel.org,
linux-kernel@vger.kernel.org
Cc: akpm@linux-foundation.org, david@kernel.org, xu.xin16@zte.com.cn,
chengming.zhou@linux.dev, shr@devkernel.io, ljs@kernel.org,
vbabka@kernel.org, rppt@kernel.org, surenb@google.com,
mhocko@suse.com, shuah@kernel.org,
"Zenghui Yu (Huawei)" <zenghui.yu@linux.dev>
Subject: [PATCH] selftests/mm: disable smart scan for ksm_tests
Date: Mon, 24 Aug 2026 02:43:14 +0800 [thread overview]
Message-ID: <20260823184314.45044-1-zenghui.yu@linux.dev> (raw)
From: "Zenghui Yu (Huawei)" <zenghui.yu@linux.dev>
The "KSM NUMA merging" test allocates two identical pages on two NUMA nodes
and verifies KSM will merge these two pages after 2 scans (see
ksm_merge_pages()). But when smart scan is enabled, pages that have
previously not been de-duplicated may get skipped for some scans. Verifying
KSM behavior after only 2 scans may not be enough.
$ ./ksm_tests -N -d
TAP version 13
1..1
pages_shared : 0
pages_sharing : 0
max_page_sharing : 256
full_scans : 211
pages_unshared : 1
pages_volatile : 2
stable_node_chains: 0
stable_node_dups : 0
general_profit : -128
ksm_rmap_items 2
ksm_zero_pages 0
ksm_merging_pages 0
ksm_process_profit -128
ksm_merge_any: no
ksm_mergeable: yes
not ok 1 KSM NUMA merging
# Totals: pass:0 fail:1 xfail:0 xpass:0 skip:0 error:0
This specific test fails because KSM started scanning the second page
whilst the first page had already been scanned for 16 times
(ksm_rmap_item::age of page 0 is 16 greater than page 1). It's not
difficult to infer that should_skip_rmap_item() cannot be false at the same
time for these two pages - they cannot be merged even after 211 full scans.
Given the current implementation of smart scan, it may not be appropriate
to enable it for selftests. Let's disable it for now.
Signed-off-by: Zenghui Yu (Huawei) <zenghui.yu@linux.dev>
---
tools/testing/selftests/mm/ksm_tests.c | 4 ++++
1 file changed, 4 insertions(+)
diff --git a/tools/testing/selftests/mm/ksm_tests.c b/tools/testing/selftests/mm/ksm_tests.c
index 5fd7792a0d47..e72681090ff9 100644
--- a/tools/testing/selftests/mm/ksm_tests.c
+++ b/tools/testing/selftests/mm/ksm_tests.c
@@ -33,6 +33,7 @@ struct ksm_sysfs {
unsigned long pages_to_scan;
unsigned long run;
unsigned long sleep_millisecs;
+ unsigned long smart_scan;
unsigned long stable_node_chains_prune_millisecs;
unsigned long use_zero_pages;
};
@@ -293,6 +294,7 @@ static int ksm_save_def(struct ksm_sysfs *ksm_sysfs)
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) ||
+ ksm_read_sysfs(KSM_FP("smart_scan"), &ksm_sysfs->smart_scan) ||
ksm_read_sysfs(KSM_FP("stable_node_chains_prune_millisecs"),
&ksm_sysfs->stable_node_chains_prune_millisecs) ||
ksm_read_sysfs(KSM_FP("use_zero_pages"), &ksm_sysfs->use_zero_pages))
@@ -309,6 +311,7 @@ static int ksm_restore(struct ksm_sysfs *ksm_sysfs)
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) ||
+ ksm_write_sysfs(KSM_FP("smart_scan"), ksm_sysfs->smart_scan) ||
ksm_write_sysfs(KSM_FP("stable_node_chains_prune_millisecs"),
ksm_sysfs->stable_node_chains_prune_millisecs) ||
ksm_write_sysfs(KSM_FP("use_zero_pages"), ksm_sysfs->use_zero_pages))
@@ -846,6 +849,7 @@ 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("smart_scan"), 0) ||
(numa_available() ? 0 :
ksm_write_sysfs(KSM_FP("merge_across_nodes"), 1)) ||
ksm_write_sysfs(KSM_FP("pages_to_scan"), page_count))
--
2.53.0
next reply other threads:[~2026-08-23 18:43 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-08-23 18:43 Zenghui Yu [this message]
2026-08-24 10:33 ` [PATCH] selftests/mm: disable smart scan for ksm_tests David Hildenbrand (Arm)
2026-08-24 11:55 ` Zenghui Yu
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=20260823184314.45044-1-zenghui.yu@linux.dev \
--to=zenghui.yu@linux.dev \
--cc=akpm@linux-foundation.org \
--cc=chengming.zhou@linux.dev \
--cc=david@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-kselftest@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=ljs@kernel.org \
--cc=mhocko@suse.com \
--cc=rppt@kernel.org \
--cc=shr@devkernel.io \
--cc=shuah@kernel.org \
--cc=surenb@google.com \
--cc=vbabka@kernel.org \
--cc=xu.xin16@zte.com.cn \
/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