The Linux Kernel Mailing List
 help / color / mirror / Atom feed
From: "David Hildenbrand (Arm)" <david@kernel.org>
To: Zenghui Yu <zenghui.yu@linux.dev>,
	linux-mm@kvack.org, linux-kselftest@vger.kernel.org,
	linux-kernel@vger.kernel.org
Cc: akpm@linux-foundation.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
Subject: Re: [PATCH] selftests/mm: disable smart scan for ksm_tests
Date: Mon, 24 Aug 2026 12:33:09 +0200	[thread overview]
Message-ID: <24cdec9c-28b5-4e44-bb05-fef27ef09846@kernel.org> (raw)
In-Reply-To: <20260823184314.45044-1-zenghui.yu@linux.dev>

On 8/23/26 20:43, Zenghui Yu wrote:
> 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

How did you reproduce this? Is this an actual test result?


~/linux/tools/testing/selftests/mm$ cat /sys/kernel/mm/ksm/smart_scan
1
~/linux/tools/testing/selftests/mm$ sudo ./ksm_tests -N -d
TAP version 13
1..1
pages_shared      : 1
pages_sharing     : 1
max_page_sharing  : 256
full_scans        : 1283
pages_unshared    : 0
pages_volatile    : 0
stable_node_chains: 0
stable_node_dups  : 0
general_profit    : 3968
ksm_rmap_items 2
ksm_zero_pages 0
ksm_merging_pages 2
ksm_process_profit 8064
ksm_merge_any: no
ksm_mergeable: yes
ok 1 KSM NUMA merging
# Totals: pass:1 fail:0 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

How is that supposed to happen? The sequence we have is:

numa1_map_ptr = numa_alloc_onnode(page_size, first_node);
numa2_map_ptr = numa_alloc_onnode(page_size, second_node);
...
memset(numa1_map_ptr, '*', page_size);
memset(numa2_map_ptr, '*', page_size);
...
if (ksm_merge_pages(merge_type, numa1_map_ptr, page_size, start_time, timeout) ...

KSM smart scan operates on rmap entries. rmap entries are per MM.

-- 
Cheers,

David

  reply	other threads:[~2026-08-24 10:33 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-08-23 18:43 [PATCH] selftests/mm: disable smart scan for ksm_tests Zenghui Yu
2026-08-24 10:33 ` David Hildenbrand (Arm) [this message]
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=24cdec9c-28b5-4e44-bb05-fef27ef09846@kernel.org \
    --to=david@kernel.org \
    --cc=akpm@linux-foundation.org \
    --cc=chengming.zhou@linux.dev \
    --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 \
    --cc=zenghui.yu@linux.dev \
    /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