From: "David Hildenbrand (Arm)" <david@kernel.org>
To: Qiliang Yuan <odys.yuan@gmail.com>,
Andrew Morton <akpm@linux-foundation.org>,
Lorenzo Stoakes <ljs@kernel.org>,
"Liam R. Howlett" <liam@infradead.org>,
Vlastimil Babka <vbabka@kernel.org>,
Mike Rapoport <rppt@kernel.org>,
Suren Baghdasaryan <surenb@google.com>,
Michal Hocko <mhocko@suse.com>, Shuah Khan <shuah@kernel.org>,
Usama Arif <usamaarif642@gmail.com>, Yu Zhao <yuzhao@google.com>,
Xu Xin <xu.xin@linux.dev>,
Chengming Zhou <chengming.zhou@linux.dev>,
Nico Pache <npache@redhat.com>
Cc: linux-mm@kvack.org, linux-kselftest@vger.kernel.org,
linux-kernel@vger.kernel.org
Subject: Re: [PATCH] selftests/mm: keep ksm_tests on small pages
Date: Mon, 19 Oct 2026 15:37:52 +0200 [thread overview]
Message-ID: <4a6ddf56-af89-482a-b173-18e181bfc3ae@kernel.org> (raw)
In-Reply-To: <20261018-bug-selftests-mm-ksm-tests-nohugepage-v1-1-55ed54bdad35@gmail.com>
On 10/18/26 06:53, Qiliang Yuan wrote:
> ksm_tests fills regions with identical data and checks KSM's counters
> after merging them. allocate_memory() maps these regions without any
> THP hint.
>
> With mTHP enabled the regions can be backed by large folios, which KSM
> splits before merging. Splitting an anonymous folio maps its
> zero-filled pages to the shared zeropage, so with use_zero_pages=0
> those pages never become KSM pages and "KSM zero page merging" fails
> its count. "ksm_tests -Z -p 10 -z 0", 20 runs:
>
> THP setup before after
> default 0/20 0/20
> every mTHP size "always" 20/20 0/20
>
> Map the regions with MADV_NOHUGEPAGE, as ksm_functional_tests does.
> ksm_merge_hugepages_time() maps its own THP-backed region and is not
> affected.
That's actually something Nico intends to fix:
https://lore.kernel.org/all/20260609114619.144416-1-npache@redhat.com/
>
> Fixes: b1f202060afe ("mm: remap unused subpages to shared zeropage when splitting isolated thp")
> Signed-off-by: Qiliang Yuan <odys.yuan@gmail.com>
> ---
> tools/testing/selftests/mm/ksm_tests.c | 10 ++++++++++
> 1 file changed, 10 insertions(+)
>
> diff --git a/tools/testing/selftests/mm/ksm_tests.c b/tools/testing/selftests/mm/ksm_tests.c
> index 5fd7792a0d479..140ea833353b6 100644
> --- a/tools/testing/selftests/mm/ksm_tests.c
> +++ b/tools/testing/selftests/mm/ksm_tests.c
> @@ -178,6 +178,16 @@ static void *allocate_memory(void *ptr, int prot, int mapping, char data, size_
> ksft_perror("mmap");
> return NULL;
> }
> + /*
> + * Splitting a large folio before merging maps its zero-filled pages
> + * to the shared zeropage, so keep the pages small. Ignore EINVAL on
> + * kernels without THP.
> + */
> + if (madvise(map_ptr, map_size, MADV_NOHUGEPAGE) && errno != EINVAL) {
> + ksft_perror("madvise");
> + munmap(map_ptr, map_size);
> + return NULL;
> + }
> memset(map_ptr, data, map_size);
> if (mprotect(map_ptr, map_size, prot)) {
> ksft_perror("mprotect");
>
> ---
> base-commit: 90201351a862182bdabfc1ad1c97b1e1b6ed5931
> change-id: 20261016-bug-selftests-mm-ksm-tests-nohugepage-1414868db0ef
>
> Best regards,
--
Cheers,
David
next prev parent reply other threads:[~2026-10-19 13:37 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-10-18 4:53 Qiliang Yuan
2026-10-19 6:25 ` Sarthak Sharma
2026-10-19 13:37 ` David Hildenbrand (Arm) [this message]
2026-10-19 14:24 ` Nico Pache
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=4a6ddf56-af89-482a-b173-18e181bfc3ae@kernel.org \
--to=david@kernel.org \
--cc=akpm@linux-foundation.org \
--cc=chengming.zhou@linux.dev \
--cc=liam@infradead.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=npache@redhat.com \
--cc=odys.yuan@gmail.com \
--cc=rppt@kernel.org \
--cc=shuah@kernel.org \
--cc=surenb@google.com \
--cc=usamaarif642@gmail.com \
--cc=vbabka@kernel.org \
--cc=xu.xin@linux.dev \
--cc=yuzhao@google.com \
/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
all inboxes | Powered by JetHome®