From: Sarthak Sharma <sarthak.sharma@arm.com>
To: Andrew Morton <akpm@linux-foundation.org>,
David Hildenbrand <david@kernel.org>
Cc: 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>,
Zi Yan <ziy@nvidia.com>,
Baolin Wang <baolin.wang@linux.alibaba.com>,
Nico Pache <nico.pache@linux.dev>,
Ryan Roberts <ryan.roberts@arm.com>, Dev Jain <dev.jain@arm.com>,
Anshuman Khandual <anshuman.khandual@arm.com>,
Barry Song <baohua@kernel.org>, Lance Yang <lance.yang@linux.dev>,
Usama Arif <usama.arif@linux.dev>,
Kiryl Shutsemau <kas@kernel.org>,
linux-mm@kvack.org, linux-kselftest@vger.kernel.org,
linux-kernel@vger.kernel.org,
Sarthak Sharma <sarthak.sharma@arm.com>
Subject: [PATCH 1/4] selftests/mm: remove transhuge-stress
Date: Thu, 12 Nov 2026 14:32:47 +0530 [thread overview]
Message-ID: <20261112090250.334344-2-sarthak.sharma@arm.com> (raw)
In-Reply-To: <20261112090250.334344-1-sarthak.sharma@arm.com>
transhuge-stress currently behaves like a stressor which takes arguments
like duration and size. By default, it tries to allocate and split a
THP at every hugepage sized offset in a range equal to RAM. It counts
successful and failed allocations and prints them. The test passes if
the specified duration has elapsed and fails only if a setup or system
call fails.
This is not how a selftest is supposed to behave. Remove
transhuge-stress from selftests/mm and remove its references from
Makefile, run_vmtests.sh and MAINTAINERS. A subsequent patch adds a
selftest for THP compaction.
Suggested-by: David Hildenbrand (Arm) <david@kernel.org>
Signed-off-by: Sarthak Sharma <sarthak.sharma@arm.com>
---
MAINTAINERS | 1 -
tools/testing/selftests/mm/Makefile | 1 -
tools/testing/selftests/mm/run_vmtests.sh | 2 -
tools/testing/selftests/mm/transhuge-stress.c | 146 ------------------
4 files changed, 150 deletions(-)
delete mode 100644 tools/testing/selftests/mm/transhuge-stress.c
diff --git a/MAINTAINERS b/MAINTAINERS
index ce05a3253baa..4d74ad879ecf 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -17946,7 +17946,6 @@ F: mm/mm_slot.h
F: tools/mm/thpmaps
F: tools/testing/selftests/mm/khugepaged.c
F: tools/testing/selftests/mm/split_huge_page_test.c
-F: tools/testing/selftests/mm/transhuge-stress.c
MEMORY MANAGEMENT - USERFAULTFD
M: Andrew Morton <akpm@linux-foundation.org>
diff --git a/tools/testing/selftests/mm/Makefile b/tools/testing/selftests/mm/Makefile
index 675ec57d47de..06d3d0350a9a 100644
--- a/tools/testing/selftests/mm/Makefile
+++ b/tools/testing/selftests/mm/Makefile
@@ -90,7 +90,6 @@ TEST_GEN_FILES += pfnmap
TEST_GEN_FILES += process_madv
TEST_GEN_FILES += prctl_thp_disable
TEST_GEN_FILES += thuge-gen
-TEST_GEN_FILES += transhuge-stress
TEST_GEN_FILES += uffd-stress
TEST_GEN_FILES += uffd-unit-tests
TEST_GEN_FILES += uffd-wp-mremap
diff --git a/tools/testing/selftests/mm/run_vmtests.sh b/tools/testing/selftests/mm/run_vmtests.sh
index 973cb715b326..cb5c7cccb585 100755
--- a/tools/testing/selftests/mm/run_vmtests.sh
+++ b/tools/testing/selftests/mm/run_vmtests.sh
@@ -448,8 +448,6 @@ if [ -n "${MOUNTED_XFS}" ]; then
rm -f ${XFS_IMG}
fi
-CATEGORY="thp" run_test ./transhuge-stress -d 20
-
CATEGORY="thp" run_test ./folio_split_race_test
CATEGORY="migration" run_test ./migration
diff --git a/tools/testing/selftests/mm/transhuge-stress.c b/tools/testing/selftests/mm/transhuge-stress.c
deleted file mode 100644
index ad2831c864dc..000000000000
--- a/tools/testing/selftests/mm/transhuge-stress.c
+++ /dev/null
@@ -1,146 +0,0 @@
-/*
- * Stress test for transparent huge pages, memory compaction and migration.
- *
- * Authors: Konstantin Khlebnikov <koct9i@gmail.com>
- *
- * This is free and unencumbered software released into the public domain.
- */
-
-#include <stdlib.h>
-#include <stdio.h>
-#include <stdint.h>
-#include <err.h>
-#include <time.h>
-#include <unistd.h>
-#include <fcntl.h>
-#include <string.h>
-#include <sys/mman.h>
-#include "vm_util.h"
-#include "kselftest.h"
-
-int backing_fd = -1;
-int mmap_flags = MAP_ANONYMOUS | MAP_NORESERVE | MAP_PRIVATE;
-#define PROT_RW (PROT_READ | PROT_WRITE)
-
-int main(int argc, char **argv)
-{
- size_t ram, len;
- void *ptr, *p;
- struct timespec start, a, b;
- int i = 0;
- char *name = NULL;
- double s;
- uint8_t *map;
- size_t map_len;
- int pagemap_fd;
- int duration = 0;
- const uint64_t hpage_size = pmd_psize();
- const uint64_t hpage_shift = pmd_pshift();
-
- ksft_print_header();
-
- if (!thp_is_enabled())
- ksft_exit_skip("Transparent Hugepages not available\n");
-
- if (!hpage_size || !hpage_shift)
- ksft_exit_fail_msg("reading hpage_size failed\n");
-
- ram = sysconf(_SC_PHYS_PAGES);
- if (ram > SIZE_MAX / psize() / 4)
- ram = SIZE_MAX / 4;
- else
- ram *= psize();
- len = ram;
-
- while (++i < argc) {
- if (!strcmp(argv[i], "-h"))
- ksft_exit_fail_msg("usage: %s [-f <filename>] [-d <duration>] [size in MiB]\n",
- argv[0]);
- else if (!strcmp(argv[i], "-f"))
- name = argv[++i];
- else if (!strcmp(argv[i], "-d"))
- duration = atoi(argv[++i]);
- else
- len = atoll(argv[i]) << 20;
- }
-
- ksft_set_plan(1);
-
- if (name) {
- backing_fd = open(name, O_RDWR);
- if (backing_fd == -1)
- ksft_exit_fail_msg("open %s\n", name);
- mmap_flags = MAP_SHARED;
- }
-
- warnx("allocate %zd transhuge pages, using %zd MiB virtual memory"
- " and %zd MiB of ram", len >> hpage_shift, len >> 20,
- ram >> (20 + hpage_shift - pshift() - 1));
-
- pagemap_fd = open("/proc/self/pagemap", O_RDONLY);
- if (pagemap_fd < 0)
- ksft_exit_fail_msg("open pagemap\n");
-
- len -= len % hpage_size;
- ptr = mmap(NULL, len + hpage_size, PROT_RW, mmap_flags, backing_fd, 0);
- if (ptr == MAP_FAILED)
- ksft_exit_fail_msg("initial mmap");
- ptr += hpage_size - (uintptr_t)ptr % hpage_size;
-
- if (madvise(ptr, len, MADV_HUGEPAGE))
- ksft_exit_fail_msg("MADV_HUGEPAGE");
-
- map_len = ram >> (hpage_shift - 1);
- map = malloc(map_len);
- if (!map)
- ksft_exit_fail_msg("map malloc\n");
-
- clock_gettime(CLOCK_MONOTONIC, &start);
-
- while (1) {
- int nr_succeed = 0, nr_failed = 0, nr_pages = 0;
-
- memset(map, 0, map_len);
-
- clock_gettime(CLOCK_MONOTONIC, &a);
- for (p = ptr; p < ptr + len; p += hpage_size) {
- int64_t pfn;
-
- pfn = allocate_transhuge(p, pagemap_fd);
-
- if (pfn < 0) {
- nr_failed++;
- } else {
- size_t idx = pfn >> (hpage_shift - pshift());
-
- nr_succeed++;
- if (idx >= map_len) {
- map = realloc(map, idx + 1);
- if (!map)
- ksft_exit_fail_msg("map realloc\n");
- memset(map + map_len, 0, idx + 1 - map_len);
- map_len = idx + 1;
- }
- if (!map[idx])
- nr_pages++;
- map[idx] = 1;
- }
-
- /* split transhuge page, keep last page */
- if (madvise(p, hpage_size - psize(), MADV_DONTNEED))
- ksft_exit_fail_msg("MADV_DONTNEED");
- }
- clock_gettime(CLOCK_MONOTONIC, &b);
- s = b.tv_sec - a.tv_sec + (b.tv_nsec - a.tv_nsec) / 1000000000.;
-
- ksft_print_msg("%.3f s/loop, %.3f ms/page, %10.3f MiB/s\t"
- "%4d succeed, %4d failed, %4d different pages\n",
- s, s * 1000 / (len >> hpage_shift), len / s / (1 << 20),
- nr_succeed, nr_failed, nr_pages);
-
- if (duration > 0 && b.tv_sec - start.tv_sec >= duration) {
- ksft_test_result_pass("Completed\n");
- ksft_finished();
- }
- }
-}
--
2.53.0
next prev parent reply other threads:[~2026-11-12 9:03 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-12 9:02 [PATCH 0/4] selftests/mm: replace transhuge-stress with a THP compaction selftest Sarthak Sharma
2026-11-12 9:02 ` Sarthak Sharma [this message]
2026-11-12 9:02 ` [PATCH 2/4] selftests/mm: detect masked PFNs in allocate_transhuge() Sarthak Sharma
2026-11-12 9:02 ` [PATCH 3/4] selftests/mm: factor out THP split helpers Sarthak Sharma
2026-11-12 9:02 ` [PATCH 4/4] selftests/mm: add a THP compaction selftest Sarthak Sharma
2026-11-14 12:43 ` [PATCH 0/4] selftests/mm: replace transhuge-stress with " Dev Jain
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=20261112090250.334344-2-sarthak.sharma@arm.com \
--to=sarthak.sharma@arm.com \
--cc=akpm@linux-foundation.org \
--cc=anshuman.khandual@arm.com \
--cc=baohua@kernel.org \
--cc=baolin.wang@linux.alibaba.com \
--cc=david@kernel.org \
--cc=dev.jain@arm.com \
--cc=kas@kernel.org \
--cc=lance.yang@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=nico.pache@linux.dev \
--cc=rppt@kernel.org \
--cc=ryan.roberts@arm.com \
--cc=shuah@kernel.org \
--cc=surenb@google.com \
--cc=usama.arif@linux.dev \
--cc=vbabka@kernel.org \
--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®