From: Baolin Wang <baolin.wang@linux.alibaba.com>
To: akpm@linux-foundation.org, hughd@google.com, david@kernel.org
Cc: ziy@nvidia.com, liam@infradead.org, nico.pache@linux.dev,
ryan.roberts@arm.com, dev.jain@arm.com, baohua@kernel.org,
lance.yang@linux.dev, usama.arif@linux.dev, kas@kernel.org,
ljs@kernel.org, baolin.wang@linux.alibaba.com,
linux-mm@kvack.org, linux-kernel@vger.kernel.org
Subject: [PATCH 12/12] selftests: mm: add shmem mTHP collapse test cases
Date: Fri, 18 Sep 2026 11:58:43 +0800 [thread overview]
Message-ID: <5f0b54de46dfe0dabaeb78e8a68bbe828ffce9ca.1789701677.git.baolin.wang@linux.alibaba.com> (raw)
In-Reply-To: <cover.1789701677.git.baolin.wang@linux.alibaba.com>
Add shmem mTHP collapse test cases for 'collapse_full', and 'collapse_single_mthp'
for shmem. All khugepaged test cases passed.
Signed-off-by: Baolin Wang <baolin.wang@linux.alibaba.com>
---
tools/testing/selftests/mm/khugepaged.c | 7 +++++--
tools/testing/selftests/mm/run_vmtests.sh | 2 ++
2 files changed, 7 insertions(+), 2 deletions(-)
diff --git a/tools/testing/selftests/mm/khugepaged.c b/tools/testing/selftests/mm/khugepaged.c
index f82673f5f6b4..a205b7afbc85 100644
--- a/tools/testing/selftests/mm/khugepaged.c
+++ b/tools/testing/selftests/mm/khugepaged.c
@@ -627,6 +627,9 @@ static void mthp_khugepaged_collapse(const char *msg, char *p, int nr_hpages,
if (ops == &__anon_ops) {
settings.thp_enabled = THP_NEVER;
settings.hugepages[collapse_order].enabled = THP_MADVISE;
+ } else if (ops == &__shmem_ops) {
+ settings.shmem_enabled = SHMEM_NEVER;
+ settings.shmem_hugepages[collapse_order].enabled = SHMEM_ADVISE;
}
thp_push_settings(&settings);
@@ -1260,8 +1263,6 @@ static void parse_test_type(int argc, char **argv)
usage();
} else if (!strcmp(buf, "shmem")) {
shmem_ops = &__shmem_ops;
- if (mthp_khugepaged_context)
- usage();
} else {
usage();
}
@@ -1358,6 +1359,7 @@ int main(int argc, char **argv)
TEST(collapse_full, khugepaged_context, read_write_file_write_ops);
TEST(collapse_full, khugepaged_context, shmem_ops);
TEST(collapse_full, mthp_khugepaged_context, anon_ops);
+ TEST(collapse_full, mthp_khugepaged_context, shmem_ops);
TEST(collapse_full, madvise_context, anon_ops);
TEST(collapse_full, madvise_context, read_only_file_ops);
TEST(collapse_full, madvise_context, read_write_file_read_ops);
@@ -1369,6 +1371,7 @@ int main(int argc, char **argv)
TEST(collapse_empty, madvise_context, anon_ops);
TEST(collapse_single_mthp, mthp_khugepaged_context, anon_ops);
+ TEST(collapse_single_mthp, mthp_khugepaged_context, shmem_ops);
TEST(collapse_single_pte_entry, khugepaged_context, anon_ops);
TEST(collapse_single_pte_entry, khugepaged_context, read_only_file_ops);
diff --git a/tools/testing/selftests/mm/run_vmtests.sh b/tools/testing/selftests/mm/run_vmtests.sh
index 19755fb4edb9..e1e404a612cc 100755
--- a/tools/testing/selftests/mm/run_vmtests.sh
+++ b/tools/testing/selftests/mm/run_vmtests.sh
@@ -427,6 +427,8 @@ CATEGORY="thp" run_test ./khugepaged -s 4 all:shmem
CATEGORY="thp" run_test ./khugepaged -c 4 mthp_khugepaged:anon
+CATEGORY="thp" run_test ./khugepaged -c 4 mthp_khugepaged:shmem
+
# Try to create XFS if not provided
if [ -z "${SPLIT_HUGE_PAGE_TEST_XFS_PATH}" ]; then
if test_selected "thp"; then
--
2.47.3
prev parent reply other threads:[~2026-09-18 3:59 UTC|newest]
Thread overview: 17+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-09-18 3:58 [PATCH 00/12] add shmem mTHP collapse support Baolin Wang
2026-09-18 3:58 ` [PATCH 01/12] mm: khugepaged: remove outdated comments and check for shmem Baolin Wang
2026-09-18 5:31 ` Barry Song
2026-09-18 3:58 ` [PATCH 02/12] mm: khugepaged: drop the hugepage_madvise() Baolin Wang
2026-09-18 5:33 ` Barry Song
2026-09-18 3:58 ` [PATCH 03/12] mm: shmem: don't expose 'deny' and 'force' via the kernel command line Baolin Wang
2026-09-18 5:45 ` Barry Song
2026-09-18 8:31 ` Baolin Wang
2026-09-18 3:58 ` [PATCH 04/12] mm: khugepaged: move cc->scan_file and cc->scan_pgoff assignment into collapse_scan_file() Baolin Wang
2026-09-18 3:58 ` [PATCH 05/12] mm: khugepaged: add max_ptes_none check in collapse_file() Baolin Wang
2026-09-18 3:58 ` [PATCH 06/12] mm: khugepaged: generalize collapse_file() for shmem mTHP support Baolin Wang
2026-09-18 3:58 ` [PATCH 07/12] mm: khugepaged: add an order check for PMD-sized THP statistics Baolin Wang
2026-09-18 3:58 ` [PATCH 08/12] mm: khugepaged: add a helper to get the minimal collapse order Baolin Wang
2026-09-18 3:58 ` [PATCH 09/12] mm: khugepaged: add shmem mTHP collapse support Baolin Wang
2026-09-18 3:58 ` [PATCH 10/12] mm: shmem: run khugepaged for all shmem mTHP orders Baolin Wang
2026-09-18 3:58 ` [PATCH 11/12] mm: khugepaged: allow khugepaged to check all shmem mTHP-sized orders Baolin Wang
2026-09-18 3:58 ` Baolin Wang [this message]
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=5f0b54de46dfe0dabaeb78e8a68bbe828ffce9ca.1789701677.git.baolin.wang@linux.alibaba.com \
--to=baolin.wang@linux.alibaba.com \
--cc=akpm@linux-foundation.org \
--cc=baohua@kernel.org \
--cc=david@kernel.org \
--cc=dev.jain@arm.com \
--cc=hughd@google.com \
--cc=kas@kernel.org \
--cc=lance.yang@linux.dev \
--cc=liam@infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=ljs@kernel.org \
--cc=nico.pache@linux.dev \
--cc=ryan.roberts@arm.com \
--cc=usama.arif@linux.dev \
--cc=ziy@nvidia.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®