| Seq | Timestamp | Type | Name | Duration |
|---|---|---|---|---|
| 0/0 | 2026/10/13 12:03 | flow | patch-triage |
0mArgs:null Results: {
"EnableConfigs": null,
"FocusSymbols": [],
"KMSANReasoning": "",
"NeedsKMSAN": false,
"Reasoning": "All modifications in this patch series are strictly confined to user-space self-tests in tools/testing/selftests/mm/. They do not affect the compiled kernel image (vmlinux) or any kernel modules, and are therefore not fuzzable.",
"WorthFuzzing": false
} |
| 1/1 | 2026/10/13 12:03 | action | read-patch-diff |
0mArgs:null Results: {
"PatchDiff": "commit 36c43ca3c7111646d3285f9d7b01922479e6e473\nAuthor: syz-cluster \u003ctriage@syzkaller.com\u003e\nDate: Tue Oct 13 12:03:54 2026 +0000\n\n syz-cluster: applied patch under review\n\ndiff --git a/tools/testing/selftests/mm/cow.c b/tools/testing/selftests/mm/cow.c\nindex 3264a828575bd..c8c26b26ff629 100644\n--- a/tools/testing/selftests/mm/cow.c\n+++ b/tools/testing/selftests/mm/cow.c\n@@ -1888,7 +1888,7 @@ int main(int argc, char **argv)\n \tthp_save_settings();\n \n \tpagesize = getpagesize();\n-\tpmdsize = read_pmd_pagesize();\n+\tpmdsize = pmd_psize();\n \tif (pmdsize) {\n \t\t/* Only if THP is supported. */\n \t\tthp_read_settings(\u0026default_settings);\ndiff --git a/tools/testing/selftests/mm/folio_split_race_test.c b/tools/testing/selftests/mm/folio_split_race_test.c\nindex 1a9840b73e618..4aa173bffa89a 100644\n--- a/tools/testing/selftests/mm/folio_split_race_test.c\n+++ b/tools/testing/selftests/mm/folio_split_race_test.c\n@@ -234,7 +234,7 @@ int main(void)\n \tksft_print_header();\n \n \tpage_size = getpagesize();\n-\tpmd_pagesize = read_pmd_pagesize();\n+\tpmd_pagesize = pmd_psize();\n \n \tif (!thp_available() || !pmd_pagesize)\n \t\tksft_exit_skip(\"Transparent Hugepages not available\\n\");\ndiff --git a/tools/testing/selftests/mm/guard-regions.c b/tools/testing/selftests/mm/guard-regions.c\nindex f7d53ea3c2527..02f69244f9a42 100644\n--- a/tools/testing/selftests/mm/guard-regions.c\n+++ b/tools/testing/selftests/mm/guard-regions.c\n@@ -2194,14 +2194,20 @@ TEST_F(guard_regions, pagemap_scan)\n TEST_F(guard_regions, collapse)\n {\n \tconst unsigned long page_size = self-\u003epage_size;\n-\tconst unsigned long size = 2 * HPAGE_SIZE;\n-\tconst unsigned long num_pages = size / page_size;\n+\tconst uint64_t hpage_size = pmd_psize();\n+\tunsigned long size, num_pages;\n \tchar *ptr;\n \tint i;\n \n \tif (!thp_available())\n \t\tSKIP(return, \"Transparent Hugepages not available\\n\");\n \n+\tif (!hpage_size)\n+\t\tksft_exit_fail_msg(\"reading hpage_size failed\\n\");\n+\n+\tsize = 2 * hpage_size;\n+\tnum_pages = size / page_size;\n+\n \t/* Need file to be correct size for tests for non-anon. */\n \tif (variant-\u003ebacking != ANON_BACKED)\n \t\tASSERT_EQ(ftruncate(self-\u003efd, size), 0);\ndiff --git a/tools/testing/selftests/mm/hmm-tests.c b/tools/testing/selftests/mm/hmm-tests.c\nindex e5f273ca84c10..02bec1ee54e14 100644\n--- a/tools/testing/selftests/mm/hmm-tests.c\n+++ b/tools/testing/selftests/mm/hmm-tests.c\n@@ -568,7 +568,7 @@ TEST_F(hmm, anon_write_child)\n \n \tfor (migrate = 0; migrate \u003c 2; ++migrate) {\n \t\tfor (use_thp = 0; use_thp \u003c 2; ++use_thp) {\n-\t\t\tnpages = ALIGN(use_thp ? read_pmd_pagesize() : HMM_BUFFER_SIZE,\n+\t\t\tnpages = ALIGN(use_thp ? pmd_psize() : HMM_BUFFER_SIZE,\n \t\t\t\t self-\u003epage_size) \u003e\u003e self-\u003epage_shift;\n \t\t\tASSERT_NE(npages, 0);\n \t\t\tsize = npages \u003c\u003c self-\u003epage_shift;\n@@ -729,7 +729,7 @@ TEST_F(hmm, anon_write_huge)\n \tint *ptr;\n \tint ret;\n \n-\tsize = 2 * read_pmd_pagesize();\n+\tsize = 2 * pmd_psize();\n \n \tbuffer = hmm_buffer_alloc(size, size,\n \t\t\t\t PROT_READ | PROT_WRITE,\n@@ -1940,7 +1940,7 @@ TEST_F(hmm, migrate_anon_huge_empty)\n \tint *ptr;\n \tint ret;\n \n-\tsize = read_pmd_pagesize();\n+\tsize = pmd_psize();\n \n \tbuffer = hmm_buffer_alloc(2 * size, size,\n \t\t\t\t PROT_READ,\n@@ -1983,7 +1983,7 @@ TEST_F(hmm, migrate_anon_huge_zero)\n \tint ret;\n \tint val;\n \n-\tsize = read_pmd_pagesize();\n+\tsize = pmd_psize();\n \n \tbuffer = hmm_buffer_alloc(2 * size, size,\n \t\t\t\t PROT_READ,\n@@ -2037,7 +2037,7 @@ TEST_F(hmm, migrate_anon_huge_free)\n \tint *ptr;\n \tint ret;\n \n-\tsize = read_pmd_pagesize();\n+\tsize = pmd_psize();\n \n \tbuffer = hmm_buffer_alloc(2 * size, size,\n \t\t\t\t PROT_READ | PROT_WRITE,\n@@ -2090,7 +2090,7 @@ TEST_F(hmm, migrate_anon_huge_fault)\n \tint *ptr;\n \tint ret;\n \n-\tsize = read_pmd_pagesize();\n+\tsize = pmd_psize();\n \n \tbuffer = hmm_buffer_alloc(2 * size, size,\n \t\t\t\t PROT_READ | PROT_WRITE,\n@@ -2160,7 +2160,7 @@ TEST_F(hmm, migrate_partial_unmap_fault)\n {\n \tstruct hmm_buffer *buffer;\n \tunsigned long npages;\n-\tunsigned long size = read_pmd_pagesize();\n+\tunsigned long size = pmd_psize();\n \tunsigned long unmap_size;\n \tunsigned long offsets[3];\n \tunsigned long i;\n@@ -2225,7 +2225,7 @@ TEST_F(hmm, migrate_remap_fault)\n {\n \tstruct hmm_buffer *buffer;\n \tunsigned long npages;\n-\tunsigned long size = read_pmd_pagesize();\n+\tunsigned long size = pmd_psize();\n \tunsigned long offsets[3];\n \tunsigned long i;\n \tvoid *old_ptr, *new_ptr = NULL;\n@@ -2322,7 +2322,7 @@ TEST_F(hmm, migrate_anon_huge_err)\n \tint *ptr;\n \tint ret;\n \n-\tsize = read_pmd_pagesize();\n+\tsize = pmd_psize();\n \n \tbuffer = hmm_buffer_alloc(2 * size, 2 * size,\n \t\t\t\t PROT_READ | PROT_WRITE,\n@@ -2412,7 +2412,7 @@ TEST_F(hmm, migrate_anon_huge_zero_err)\n \tint *ptr;\n \tint ret;\n \n-\tsize = read_pmd_pagesize();\n+\tsize = pmd_psize();\n \n \tbuffer = hmm_buffer_alloc(2 * size, 2 * size,\n \t\t\t\t PROT_READ,\n@@ -2608,7 +2608,7 @@ static inline int run_migration_benchmark(int fd, int use_thp, size_t buffer_siz\n TEST_F_TIMEOUT(hmm, benchmark_thp_migration, 120)\n {\n \tstruct benchmark_results thp_results, regular_results;\n-\tsize_t thp_size = read_pmd_pagesize();\n+\tsize_t thp_size = pmd_psize();\n \tint iterations = 5;\n \n \tif (!thp_size)\ndiff --git a/tools/testing/selftests/mm/khugepaged.c b/tools/testing/selftests/mm/khugepaged.c\nindex 1bc7acc66a469..195adb1875e5e 100644\n--- a/tools/testing/selftests/mm/khugepaged.c\n+++ b/tools/testing/selftests/mm/khugepaged.c\n@@ -1684,7 +1684,7 @@ int main(int argc, char **argv)\n \t\tksft_exit_skip(\"Transparent Hugepages not available\\n\");\n \n \tpage_size = getpagesize();\n-\thpage_pmd_size = read_pmd_pagesize();\n+\thpage_pmd_size = pmd_psize();\n \tif (!hpage_pmd_size)\n \t\tksft_exit_fail_msg(\"Reading PMD pagesize failed\\n\");\n \thpage_pmd_nr = hpage_pmd_size / page_size;\ndiff --git a/tools/testing/selftests/mm/khugepaged_race.c b/tools/testing/selftests/mm/khugepaged_race.c\nindex abb0678522cd9..6cd68cda07624 100644\n--- a/tools/testing/selftests/mm/khugepaged_race.c\n+++ b/tools/testing/selftests/mm/khugepaged_race.c\n@@ -371,7 +371,7 @@ int main(int argc, char **argv)\n \t\tksft_exit_skip(\"Transparent Hugepages not available\\n\");\n \n \tpage_size = getpagesize();\n-\thpage_pmd_size = read_pmd_pagesize();\n+\thpage_pmd_size = pmd_psize();\n \tif (!hpage_pmd_size)\n \t\tksft_exit_fail_msg(\"Reading PMD pagesize failed\\n\");\n \ndiff --git a/tools/testing/selftests/mm/khugepaged_sync_check.c b/tools/testing/selftests/mm/khugepaged_sync_check.c\nindex 28a9b1ff5d447..f31b0987d90c3 100644\n--- a/tools/testing/selftests/mm/khugepaged_sync_check.c\n+++ b/tools/testing/selftests/mm/khugepaged_sync_check.c\n@@ -140,7 +140,7 @@ int main(void)\n \t\tksft_exit_skip(\"Order %d is not a supported anon THP order\\n\",\n \t\t\t TARGET_ORDER);\n \n-\thpage_pmd_size = read_pmd_pagesize();\n+\thpage_pmd_size = pmd_psize();\n \tif (!hpage_pmd_size)\n \t\tksft_exit_fail_msg(\"Reading PMD pagesize failed\\n\");\n \tpagemap_fd = open(\"/proc/self/pagemap\", O_RDONLY);\ndiff --git a/tools/testing/selftests/mm/ksm_tests.c b/tools/testing/selftests/mm/ksm_tests.c\nindex 6711f4c613711..9e6e1633d0b53 100644\n--- a/tools/testing/selftests/mm/ksm_tests.c\n+++ b/tools/testing/selftests/mm/ksm_tests.c\n@@ -520,19 +520,23 @@ static int ksm_merge_hugepages_time(int merge_type, int mapping, int prot,\n \tstruct timespec start_time, end_time;\n \tunsigned long scan_time_ns;\n \tint pagemap_fd, n_normal_pages, n_huge_pages;\n+\tconst uint64_t hpage_size = pmd_psize();\n \n \tif (!thp_is_enabled()) {\n \t\tksft_print_msg(\"Transparent Hugepages not available\\n\");\n \t\treturn KSFT_SKIP;\n \t}\n \n+\tif (!hpage_size)\n+\t\tksft_exit_fail_msg(\"reading hpage_size failed\\n\");\n+\n \tmap_size *= MB;\n \tsize_t len = map_size;\n \n-\tlen -= len % HPAGE_SIZE;\n-\tmap_ptr_orig = mmap(NULL, len + HPAGE_SIZE, PROT_READ | PROT_WRITE,\n+\tlen -= len % hpage_size;\n+\tmap_ptr_orig = mmap(NULL, len + hpage_size, PROT_READ | PROT_WRITE,\n \t\t\tMAP_ANONYMOUS | MAP_NORESERVE | MAP_PRIVATE, -1, 0);\n-\tmap_ptr = map_ptr_orig + HPAGE_SIZE - (uintptr_t)map_ptr_orig % HPAGE_SIZE;\n+\tmap_ptr = map_ptr_orig + hpage_size - (uintptr_t)map_ptr_orig % hpage_size;\n \n \tif (map_ptr_orig == MAP_FAILED)\n \t\terr(2, \"initial mmap\");\n@@ -546,7 +550,7 @@ static int ksm_merge_hugepages_time(int merge_type, int mapping, int prot,\n \n \tn_normal_pages = 0;\n \tn_huge_pages = 0;\n-\tfor (void *p = map_ptr; p \u003c map_ptr + len; p += HPAGE_SIZE) {\n+\tfor (void *p = map_ptr; p \u003c map_ptr + len; p += hpage_size) {\n \t\tif (allocate_transhuge(p, pagemap_fd) \u003c 0)\n \t\t\tn_normal_pages++;\n \t\telse\n@@ -577,11 +581,11 @@ static int ksm_merge_hugepages_time(int merge_type, int mapping, int prot,\n \tksft_print_msg(\"Average speed: %.3f MiB/s\\n\", (map_size / MB) /\n \t\t\t\t\t ((double)scan_time_ns / NSEC_PER_SEC));\n \n-\tmunmap(map_ptr_orig, len + HPAGE_SIZE);\n+\tmunmap(map_ptr_orig, len + hpage_size);\n \treturn KSFT_PASS;\n \n err_out:\n-\tmunmap(map_ptr_orig, len + HPAGE_SIZE);\n+\tmunmap(map_ptr_orig, len + hpage_size);\n \treturn KSFT_FAIL;\n }\n \ndiff --git a/tools/testing/selftests/mm/migration.c b/tools/testing/selftests/mm/migration.c\nindex d1d0989ed2cad..f268751736740 100644\n--- a/tools/testing/selftests/mm/migration.c\n+++ b/tools/testing/selftests/mm/migration.c\n@@ -228,7 +228,7 @@ TEST_F_TIMEOUT(migration, private_anon_thp, 2*RUNTIME)\n \tif (!thp_is_enabled())\n \t\tSKIP(return, \"Transparent Hugepages not available\");\n \n-\tpmdsize = read_pmd_pagesize();\n+\tpmdsize = pmd_psize();\n \tif (!pmdsize)\n \t\tSKIP(return, \"Reading PMD pagesize failed\");\n \n@@ -262,7 +262,7 @@ TEST_F_TIMEOUT(migration, shared_anon_thp, 2*RUNTIME)\n \tif (!thp_is_enabled())\n \t\tSKIP(return, \"Transparent Hugepages not available\");\n \n-\tpmdsize = read_pmd_pagesize();\n+\tpmdsize = pmd_psize();\n \tif (!pmdsize)\n \t\tSKIP(return, \"Reading PMD pagesize failed\");\n \ndiff --git a/tools/testing/selftests/mm/mkdirty.c b/tools/testing/selftests/mm/mkdirty.c\nindex 68dd447a54542..49ef643a6e639 100644\n--- a/tools/testing/selftests/mm/mkdirty.c\n+++ b/tools/testing/selftests/mm/mkdirty.c\n@@ -330,7 +330,7 @@ int main(void)\n \tint err, tests = 2;\n \n \tpagesize = getpagesize();\n-\tthpsize = read_pmd_pagesize();\n+\tthpsize = pmd_psize();\n \tif (thpsize) {\n \t\tksft_print_msg(\"[INFO] detected THP size: %zu KiB\\n\",\n \t\t\t thpsize / 1024);\ndiff --git a/tools/testing/selftests/mm/pagemap_ioctl.c b/tools/testing/selftests/mm/pagemap_ioctl.c\nindex 03898b4f6cdab..e9718716feabc 100644\n--- a/tools/testing/selftests/mm/pagemap_ioctl.c\n+++ b/tools/testing/selftests/mm/pagemap_ioctl.c\n@@ -1653,7 +1653,7 @@ int main(int __attribute__((unused)) argc, char *argv[])\n \tksft_print_header();\n \n \tpage_size = getpagesize();\n-\thpage_size = read_pmd_pagesize();\n+\thpage_size = pmd_psize();\n \n \tif (init_uffd())\n \t\tksft_exit_skip(\"Failed to initialize userfaultfd\\n\");\ndiff --git a/tools/testing/selftests/mm/prctl_thp_disable.c b/tools/testing/selftests/mm/prctl_thp_disable.c\nindex f9ec1408a6e30..5b7fc68a4072c 100644\n--- a/tools/testing/selftests/mm/prctl_thp_disable.c\n+++ b/tools/testing/selftests/mm/prctl_thp_disable.c\n@@ -132,7 +132,7 @@ FIXTURE_SETUP(prctl_thp_disable_completely)\n \tif (!thp_available())\n \t\tSKIP(return, \"Transparent Hugepages not available\\n\");\n \n-\tself-\u003epmdsize = read_pmd_pagesize();\n+\tself-\u003epmdsize = pmd_psize();\n \tif (!self-\u003epmdsize)\n \t\tSKIP(return, \"Unable to read PMD size\\n\");\n \n@@ -240,7 +240,7 @@ FIXTURE_SETUP(prctl_thp_disable_except_madvise)\n \tif (!thp_available())\n \t\tSKIP(return, \"Transparent Hugepages not available\\n\");\n \n-\tself-\u003epmdsize = read_pmd_pagesize();\n+\tself-\u003epmdsize = pmd_psize();\n \tif (!self-\u003epmdsize)\n \t\tSKIP(return, \"Unable to read PMD size\\n\");\n \ndiff --git a/tools/testing/selftests/mm/process_madv.c b/tools/testing/selftests/mm/process_madv.c\nindex 3fffd5f7e6fb4..7e32bad8ab2a9 100644\n--- a/tools/testing/selftests/mm/process_madv.c\n+++ b/tools/testing/selftests/mm/process_madv.c\n@@ -141,7 +141,7 @@ TEST_F(process_madvise, remote_collapse)\n \t\tvoid *map_addr;\n \t} info;\n \n-\thuge_page_size = read_pmd_pagesize();\n+\thuge_page_size = pmd_psize();\n \tif (huge_page_size \u003c= 0)\n \t\tSKIP(return, \"Could not determine a valid huge page size.\\n\");\n \ndiff --git a/tools/testing/selftests/mm/run_vmtests.sh b/tools/testing/selftests/mm/run_vmtests.sh\nindex a1b45a3dedaee..f3ec767f562b8 100755\n--- a/tools/testing/selftests/mm/run_vmtests.sh\n+++ b/tools/testing/selftests/mm/run_vmtests.sh\n@@ -343,8 +343,8 @@ fi\n CATEGORY=\"memfd_secret\" run_test ./memfd_secret\n fi\n \n-# KSM KSM_MERGE_TIME_HUGE_PAGES test with size of 100\n-CATEGORY=\"ksm\" run_test ./ksm_tests -H -s 100\n+# KSM KSM_MERGE_TIME_HUGE_PAGES test with size of 512\n+CATEGORY=\"ksm\" run_test ./ksm_tests -H -s 512\n # KSM KSM_MERGE_TIME test with size of 100\n CATEGORY=\"ksm\" run_test ./ksm_tests -P -s 100\n # KSM MADV_MERGEABLE test with 10 identical pages\ndiff --git a/tools/testing/selftests/mm/soft-dirty.c b/tools/testing/selftests/mm/soft-dirty.c\nindex 7f649b6733553..e6fe4259b6f4d 100644\n--- a/tools/testing/selftests/mm/soft-dirty.c\n+++ b/tools/testing/selftests/mm/soft-dirty.c\n@@ -87,7 +87,7 @@ static void test_hugepage(int pagemap_fd, int pagesize)\n \t\treturn;\n \t}\n \n-\tsize_t hpage_len = read_pmd_pagesize();\n+\tsize_t hpage_len = pmd_psize();\n \tif (!hpage_len)\n \t\tksft_exit_fail_msg(\"Reading PMD pagesize failed\");\n \ndiff --git a/tools/testing/selftests/mm/split_huge_page_test.c b/tools/testing/selftests/mm/split_huge_page_test.c\nindex 36a6719ff09a8..33a2473327bb7 100644\n--- a/tools/testing/selftests/mm/split_huge_page_test.c\n+++ b/tools/testing/selftests/mm/split_huge_page_test.c\n@@ -615,7 +615,7 @@ int main(int argc, char **argv)\n \n \tpagesize = getpagesize();\n \tpageshift = ffs(pagesize) - 1;\n-\tpmd_pagesize = read_pmd_pagesize();\n+\tpmd_pagesize = pmd_psize();\n \tif (!pmd_pagesize)\n \t\tksft_exit_fail_msg(\"Reading PMD pagesize failed\\n\");\n \ndiff --git a/tools/testing/selftests/mm/transhuge-stress.c b/tools/testing/selftests/mm/transhuge-stress.c\nindex 96f72898ebe0a..ad2831c864dc3 100644\n--- a/tools/testing/selftests/mm/transhuge-stress.c\n+++ b/tools/testing/selftests/mm/transhuge-stress.c\n@@ -34,12 +34,17 @@ int main(int argc, char **argv)\n \tsize_t map_len;\n \tint pagemap_fd;\n \tint duration = 0;\n+\tconst uint64_t hpage_size = pmd_psize();\n+\tconst uint64_t hpage_shift = pmd_pshift();\n \n \tksft_print_header();\n \n \tif (!thp_is_enabled())\n \t\tksft_exit_skip(\"Transparent Hugepages not available\\n\");\n \n+\tif (!hpage_size || !hpage_shift)\n+\t\tksft_exit_fail_msg(\"reading hpage_size failed\\n\");\n+\n \tram = sysconf(_SC_PHYS_PAGES);\n \tif (ram \u003e SIZE_MAX / psize() / 4)\n \t\tram = SIZE_MAX / 4;\n@@ -69,23 +74,23 @@ int main(int argc, char **argv)\n \t}\n \n \twarnx(\"allocate %zd transhuge pages, using %zd MiB virtual memory\"\n-\t \" and %zd MiB of ram\", len \u003e\u003e HPAGE_SHIFT, len \u003e\u003e 20,\n-\t ram \u003e\u003e (20 + HPAGE_SHIFT - pshift() - 1));\n+\t \" and %zd MiB of ram\", len \u003e\u003e hpage_shift, len \u003e\u003e 20,\n+\t ram \u003e\u003e (20 + hpage_shift - pshift() - 1));\n \n \tpagemap_fd = open(\"/proc/self/pagemap\", O_RDONLY);\n \tif (pagemap_fd \u003c 0)\n \t\tksft_exit_fail_msg(\"open pagemap\\n\");\n \n-\tlen -= len % HPAGE_SIZE;\n-\tptr = mmap(NULL, len + HPAGE_SIZE, PROT_RW, mmap_flags, backing_fd, 0);\n+\tlen -= len % hpage_size;\n+\tptr = mmap(NULL, len + hpage_size, PROT_RW, mmap_flags, backing_fd, 0);\n \tif (ptr == MAP_FAILED)\n \t\tksft_exit_fail_msg(\"initial mmap\");\n-\tptr += HPAGE_SIZE - (uintptr_t)ptr % HPAGE_SIZE;\n+\tptr += hpage_size - (uintptr_t)ptr % hpage_size;\n \n \tif (madvise(ptr, len, MADV_HUGEPAGE))\n \t\tksft_exit_fail_msg(\"MADV_HUGEPAGE\");\n \n-\tmap_len = ram \u003e\u003e (HPAGE_SHIFT - 1);\n+\tmap_len = ram \u003e\u003e (hpage_shift - 1);\n \tmap = malloc(map_len);\n \tif (!map)\n \t\tksft_exit_fail_msg(\"map malloc\\n\");\n@@ -98,7 +103,7 @@ int main(int argc, char **argv)\n \t\tmemset(map, 0, map_len);\n \n \t\tclock_gettime(CLOCK_MONOTONIC, \u0026a);\n-\t\tfor (p = ptr; p \u003c ptr + len; p += HPAGE_SIZE) {\n+\t\tfor (p = ptr; p \u003c ptr + len; p += hpage_size) {\n \t\t\tint64_t pfn;\n \n \t\t\tpfn = allocate_transhuge(p, pagemap_fd);\n@@ -106,7 +111,7 @@ int main(int argc, char **argv)\n \t\t\tif (pfn \u003c 0) {\n \t\t\t\tnr_failed++;\n \t\t\t} else {\n-\t\t\t\tsize_t idx = pfn \u003e\u003e (HPAGE_SHIFT - pshift());\n+\t\t\t\tsize_t idx = pfn \u003e\u003e (hpage_shift - pshift());\n \n \t\t\t\tnr_succeed++;\n \t\t\t\tif (idx \u003e= map_len) {\n@@ -122,7 +127,7 @@ int main(int argc, char **argv)\n \t\t\t}\n \n \t\t\t/* split transhuge page, keep last page */\n-\t\t\tif (madvise(p, HPAGE_SIZE - psize(), MADV_DONTNEED))\n+\t\t\tif (madvise(p, hpage_size - psize(), MADV_DONTNEED))\n \t\t\t\tksft_exit_fail_msg(\"MADV_DONTNEED\");\n \t\t}\n \t\tclock_gettime(CLOCK_MONOTONIC, \u0026b);\n@@ -130,7 +135,7 @@ int main(int argc, char **argv)\n \n \t\tksft_print_msg(\"%.3f s/loop, %.3f ms/page, %10.3f MiB/s\\t\"\n \t\t\t \"%4d succeed, %4d failed, %4d different pages\\n\",\n-\t\t\t s, s * 1000 / (len \u003e\u003e HPAGE_SHIFT), len / s / (1 \u003c\u003c 20),\n+\t\t\t s, s * 1000 / (len \u003e\u003e hpage_shift), len / s / (1 \u003c\u003c 20),\n \t\t\t nr_succeed, nr_failed, nr_pages);\n \n \t\tif (duration \u003e 0 \u0026\u0026 b.tv_sec - start.tv_sec \u003e= duration) {\ndiff --git a/tools/testing/selftests/mm/uffd-common.c b/tools/testing/selftests/mm/uffd-common.c\nindex a76851aced4d0..d5882fc392f0b 100644\n--- a/tools/testing/selftests/mm/uffd-common.c\n+++ b/tools/testing/selftests/mm/uffd-common.c\n@@ -137,7 +137,7 @@ static void shmem_release_pages(uffd_global_test_opts_t *gopts, char *rel_area)\n static int shmem_allocate_area(uffd_global_test_opts_t *gopts, void **alloc_area, bool is_src)\n {\n \tvoid *area_alias = NULL;\n-\tsize_t bytes = gopts-\u003enr_pages * gopts-\u003epage_size, hpage_size = read_pmd_pagesize();\n+\tsize_t bytes = gopts-\u003enr_pages * gopts-\u003epage_size, hpage_size = pmd_psize();\n \tunsigned long offset = is_src ? 0 : bytes;\n \tchar *p = NULL, *p_alias = NULL;\n \tint mem_fd = uffd_mem_fd_create(bytes * 2, false);\n@@ -194,10 +194,10 @@ static void shmem_alias_mapping(uffd_global_test_opts_t *gopts, __u64 *start,\n \n static void shmem_check_pmd_mapping(uffd_global_test_opts_t *gopts, void *p, int expect_nr_hpages)\n {\n-\tsize_t len = expect_nr_hpages * read_pmd_pagesize();\n+\tsize_t len = expect_nr_hpages * pmd_psize();\n \n \tif (!check_huge_file(gopts-\u003earea_dst_alias, len, expect_nr_hpages,\n-\t\t\t read_pmd_pagesize()))\n+\t\t\t pmd_psize()))\n \t\terr(\"Did not find expected %d number of hugepages\",\n \t\t expect_nr_hpages);\n }\ndiff --git a/tools/testing/selftests/mm/uffd-unit-tests.c b/tools/testing/selftests/mm/uffd-unit-tests.c\nindex 2a97ba1d6feb1..298609544445e 100644\n--- a/tools/testing/selftests/mm/uffd-unit-tests.c\n+++ b/tools/testing/selftests/mm/uffd-unit-tests.c\n@@ -588,7 +588,7 @@ static void uffd_minor_test_common(uffd_global_test_opts_t *gopts, bool test_col\n \t\tuffd_test_ops-\u003echeck_pmd_mapping(gopts,\n \t\t\t\t\t\t gopts-\u003earea_dst,\n \t\t\t\t\t\t gopts-\u003enr_pages * gopts-\u003epage_size /\n-\t\t\t\t\t\t read_pmd_pagesize());\n+\t\t\t\t\t\t pmd_psize());\n \t\t/*\n \t\t * This won't cause uffd-fault - it purely just makes sure there\n \t\t * was no corruption.\n@@ -1914,7 +1914,7 @@ static void uffd_move_handle_fault(uffd_global_test_opts_t *gopts, struct uffd_m\n static void uffd_move_pmd_handle_fault(uffd_global_test_opts_t *gopts, struct uffd_msg *msg,\n \t\t\t\t struct uffd_args *args)\n {\n-\tuffd_move_handle_fault_common(gopts, msg, args, read_pmd_pagesize());\n+\tuffd_move_handle_fault_common(gopts, msg, args, pmd_psize());\n }\n \n static void\n@@ -2030,7 +2030,7 @@ static void uffd_move_pmd_test(uffd_global_test_opts_t *gopts, uffd_test_args_t\n {\n \tif (madvise(gopts-\u003earea_dst, gopts-\u003enr_pages * gopts-\u003epage_size, MADV_HUGEPAGE))\n \t\terr(\"madvise(MADV_HUGEPAGE) failure\");\n-\tuffd_move_test_common(gopts, targs, read_pmd_pagesize(),\n+\tuffd_move_test_common(gopts, targs, pmd_psize(),\n \t\t\t uffd_move_pmd_handle_fault);\n }\n \n@@ -2038,7 +2038,7 @@ static void uffd_move_pmd_split_test(uffd_global_test_opts_t *gopts, uffd_test_a\n {\n \tif (madvise(gopts-\u003earea_dst, gopts-\u003enr_pages * gopts-\u003epage_size, MADV_NOHUGEPAGE))\n \t\terr(\"madvise(MADV_NOHUGEPAGE) failure\");\n-\tuffd_move_test_common(gopts, targs, read_pmd_pagesize(),\n+\tuffd_move_test_common(gopts, targs, pmd_psize(),\n \t\t\t uffd_move_pmd_handle_fault);\n }\n \ndiff --git a/tools/testing/selftests/mm/uffd-wp-mremap.c b/tools/testing/selftests/mm/uffd-wp-mremap.c\nindex c48eaab8e75cf..15cff68c59a22 100644\n--- a/tools/testing/selftests/mm/uffd-wp-mremap.c\n+++ b/tools/testing/selftests/mm/uffd-wp-mremap.c\n@@ -38,7 +38,7 @@ static int detect_thp_sizes(size_t sizes[], int max)\n \tint i;\n \n \t/* thp not supported at all. */\n-\tif (!read_pmd_pagesize())\n+\tif (!pmd_psize())\n \t\treturn 0;\n \n \torders = thp_supported_orders();\ndiff --git a/tools/testing/selftests/mm/vm_util.c b/tools/testing/selftests/mm/vm_util.c\nindex 515031b8283da..8ef226107d788 100644\n--- a/tools/testing/selftests/mm/vm_util.c\n+++ b/tools/testing/selftests/mm/vm_util.c\n@@ -21,6 +21,8 @@\n \n unsigned int __page_size;\n unsigned int __page_shift;\n+uint64_t __pmd_psize = -1ull;\n+uint64_t __pmd_pshift = -1ull;\n \n uint64_t pagemap_get_entry(int fd, char *start)\n {\n@@ -155,25 +157,46 @@ bool check_for_pattern(FILE *fp, const char *pattern, char *buf, size_t len)\n \treturn false;\n }\n \n-uint64_t read_pmd_pagesize(void)\n+uint64_t pmd_psize(void)\n {\n \tint fd;\n \tchar buf[20];\n \tssize_t num_read;\n \n+\tif (__pmd_psize != -1ull)\n+\t\treturn __pmd_psize;\n+\n \tfd = open(PMD_SIZE_FILE_PATH, O_RDONLY);\n-\tif (fd == -1)\n+\tif (fd == -1) {\n+\t\t__pmd_psize = 0;\n \t\treturn 0;\n+\t}\n \n \tnum_read = read(fd, buf, 19);\n \tif (num_read \u003c 1) {\n+\t\t__pmd_psize = 0;\n \t\tclose(fd);\n \t\treturn 0;\n \t}\n \tbuf[num_read] = '\\0';\n \tclose(fd);\n \n-\treturn strtoul(buf, NULL, 10);\n+\t__pmd_psize = strtoul(buf, NULL, 10);\n+\n+\treturn __pmd_psize;\n+}\n+\n+uint64_t pmd_pshift(void)\n+{\n+\tif (__pmd_pshift != -1ull)\n+\t\treturn __pmd_pshift;\n+\n+\tif (__pmd_psize == -1ull)\n+\t\t__pmd_psize = pmd_psize();\n+\n+\t__pmd_pshift = size_to_shift(__pmd_psize);\n+\n+\treturn __pmd_pshift;\n }\n \n unsigned long rss_anon(void)\n@@ -437,7 +460,7 @@ static bool __check_huge(void *addr, size_t len, int nr_hpages,\n \tchar *start = addr;\n \tchar *end = start + len;\n \n-\tpmd_pagesize = read_pmd_pagesize();\n+\tpmd_pagesize = pmd_psize();\n \tif (!pmd_pagesize)\n \t\tksft_exit_fail_msg(\"reading PMD pagesize failed\\n\");\n \n@@ -489,14 +512,19 @@ bool check_huge_file(void *addr, size_t len, int nr_hpages, uint64_t hpage_size)\n int64_t allocate_transhuge(void *ptr, int pagemap_fd)\n {\n \tuint64_t ent[2];\n+\tconst uint64_t hpage_size = pmd_psize();\n+\tconst uint64_t hpage_shift = pmd_pshift();\n+\n+\tif (!hpage_size || !hpage_shift)\n+\t\treturn -1;\n \n \t/* drop pmd */\n-\tif (mmap(ptr, HPAGE_SIZE, PROT_READ | PROT_WRITE,\n+\tif (mmap(ptr, hpage_size, PROT_READ | PROT_WRITE,\n \t\t MAP_FIXED | MAP_ANONYMOUS |\n \t\t MAP_NORESERVE | MAP_PRIVATE, -1, 0) != ptr)\n \t\tksft_exit_fail_msg(\"mmap transhuge\\n\");\n \n-\tif (madvise(ptr, HPAGE_SIZE, MADV_HUGEPAGE))\n+\tif (madvise(ptr, hpage_size, MADV_HUGEPAGE))\n \t\tksft_exit_fail_msg(\"MADV_HUGEPAGE\\n\");\n \n \t/* allocate transparent huge page */\n@@ -508,7 +536,7 @@ int64_t allocate_transhuge(void *ptr, int pagemap_fd)\n \n \tif (PAGEMAP_PRESENT(ent[0]) \u0026\u0026 PAGEMAP_PRESENT(ent[1]) \u0026\u0026\n \t PAGEMAP_PFN(ent[0]) + 1 == PAGEMAP_PFN(ent[1]) \u0026\u0026\n-\t !(PAGEMAP_PFN(ent[0]) \u0026 ((1 \u003c\u003c (HPAGE_SHIFT - pshift())) - 1)))\n+\t !(PAGEMAP_PFN(ent[0]) \u0026 ((1 \u003c\u003c (hpage_shift - pshift())) - 1)))\n \t\treturn PAGEMAP_PFN(ent[0]);\n \n \treturn -1;\ndiff --git a/tools/testing/selftests/mm/vm_util.h b/tools/testing/selftests/mm/vm_util.h\nindex b5d59729d4327..67ff4bba5707a 100644\n--- a/tools/testing/selftests/mm/vm_util.h\n+++ b/tools/testing/selftests/mm/vm_util.h\n@@ -35,6 +35,8 @@\n \n extern unsigned int __page_size;\n extern unsigned int __page_shift;\n+extern uint64_t __pmd_psize;\n+extern uint64_t __pmd_pshift;\n \n /*\n * Represents an open fd and PROCMAP_QUERY state for binary (via ioctl)\n@@ -92,7 +94,8 @@ bool pagemap_is_populated(int fd, char *start);\n unsigned long pagemap_get_pfn(int fd, char *start);\n void clear_softdirty(void);\n bool check_for_pattern(FILE *fp, const char *pattern, char *buf, size_t len);\n-uint64_t read_pmd_pagesize(void);\n+uint64_t pmd_psize(void);\n+uint64_t pmd_pshift(void);\n unsigned long rss_anon(void);\n bool check_huge_anon(void *addr, size_t len, int nr_hpages, uint64_t hpage_size);\n bool check_huge_file(void *addr, size_t len, int nr_hpages, uint64_t hpage_size);\n@@ -156,6 +159,18 @@ static inline int sz2ord(size_t size, size_t pagesize)\n \treturn __builtin_ctzll(size / pagesize);\n }\n \n+static inline uint64_t size_to_shift(uint64_t size)\n+{\n+\t/*\n+\t * The function returns the corresponding shift only when the size\n+\t * is a power of two; otherwise, it returns 0.\n+\t */\n+\tif (!size || (size \u0026 (size - 1)))\n+\t\treturn 0;\n+\n+\treturn ffsl(size) - 1;\n+}\n+\n void *sys_mremap(void *old_address, unsigned long old_size,\n \t\t unsigned long new_size, int flags, void *new_address);\n \n@@ -168,12 +183,6 @@ int ksm_stop(void);\n int get_hardware_corrupted_size(unsigned long *val);\n int unpoison_memory(unsigned long pfn);\n \n-/*\n- * On ppc64 this will only work with radix 2M hugepage size\n- */\n-#define HPAGE_SHIFT 21\n-#define HPAGE_SIZE (1 \u003c\u003c HPAGE_SHIFT)\n-\n #define PAGEMAP_PRESENT(ent)\t(((ent) \u0026 (1ull \u003c\u003c 63)) != 0)\n #define PAGEMAP_PFN(ent)\t((ent) \u0026 ((1ull \u003c\u003c 55) - 1))\n \n"
} |
| 2/1 | 2026/10/13 12:03 | agent | patch-evaluator |
0mModel:core Args: null Results: {
"EnableConfigs": null,
"FocusSymbols": [],
"Reasoning": "All modifications in this patch series are strictly confined to user-space self-tests in tools/testing/selftests/mm/. They do not affect the compiled kernel image (vmlinux) or any kernel modules, and are therefore not fuzzable.",
"WorthFuzzing": false
}Instruction: You are an expert Linux kernel maintainer and security engineer.
Your job is to review a provided patch series and evaluate whether it warrants fuzzing with syzkaller.
IMPORTANT: The changes have ALREADY been applied and committed as the HEAD commit in
your workspace. Do NOT rely on internal assumptions. You must actively use your code access
tools to inspect the actual source code, callers, and surrounding context.
================================================================================
1. CORE TRIAGE PHILOSOPHY
================================================================================
The goal of patch fuzzing is to discover crashes, regressions, exposed latent bugs,
and newly triggered assertions introduced by the patch series.
- REACHABILITY IS THE PRIMARY GATE:
Fuzzing can only discover bugs in code that can actually execute in standard virtualized
environments (GCE or QEMU, utilizing software-emulated devices like USB gadgets, netdev, tun/tap).
If the modified code is structurally unreachable (see Section 2), it MUST NOT be fuzzed,
regardless of whether it adds assertions or complex logic.
- DO NOT BLINDLY TRUST "NO FUNCTIONAL CHANGE" (NFCI) OR "REFACTORING" CLAIMS:
Patch authors routinely label changes as "cleanups", "refactorings", or state
"No functional change intended". Do NOT take these claims at face value.
Code refactorings that rearrange logic, introduce helper functions, or alter state management
in core subsystems frequently introduce subtle semantic shifts or uncover latent kernel bugs.
If reachable executable code is modified or refactored, it MUST be fuzzed.
- NEW OR MODIFIED ASSERTIONS IN REACHABLE CODE MUST BE FUZZED:
When a patch introduces or modifies runtime checks or assertions (e.g., WARN_ON*, VM_WARN_ON*,
BUG_ON*, lockdep_assert*) in reachable code paths, it enforces new or stricter invariants.
Even if the author believes the invariant always holds, fuzzing is essential to verify whether
an unusual sequence of operations can violate it.
================================================================================
2. WHEN TO RETURN WorthFuzzing=false (NEGATIVE CRITERIA)
================================================================================
Return WorthFuzzing=false ONLY IF all modified code falls strictly into one or more of these categories:
- Non-kernel and non-executable changes:
* Modifications to Documentation/, comments, or spelling fixes.
* User-space directories, self-tests, samples, or scripts (e.g., tools/, samples/, scripts/, usr/)
that do not affect the compiled kernel image (vmlinux) or kernel modules.
* Purely decorative logging (e.g., message strings in pr_err, printk, dev_info) or tracepoints
that do not alter control flow or data structures.
* Build system or Kconfig changes that do not alter compiled C logic.
- Structurally unreachable hardware:
* Vendor-specific PCIe switches, SmartNICs, or GPU drivers (e.g., mlxsw, pds_core, qed,
ionic, amdgpu) requiring physical ASIC/PCIe cards not emulated in standard QEMU.
- Unreachable execution paths:
* Driver teardown callbacks (.remove, .shutdown, pci_unregister_driver) executed only during
physical PCI hot-unplug or manual sysfs driver unbinding.
* Code paths exclusive to architectures other than the target architecture.
================================================================================
3. WHEN TO RETURN WorthFuzzing=true (POSITIVE CRITERIA)
================================================================================
Return WorthFuzzing=true whenever the patch touches reachable executable code, including:
- Core Subsystems:
* Any logic modifications in memory management (mm/), synchronization/locking (kernel/locking/),
BPF, scheduler, core networking, VFS, or syscall handling.
- Refactorings and Code Cleanups:
* Any restructuring of reachable data structures, helper abstractions, or algorithm flows.
- Runtime Assertions and Defensive Checks:
* Any introduction or alteration of assertions (WARN_ON*, VM_WARN_ON*, BUG_ON*, etc.) in reachable paths.
- Reachable Drivers and Protocols:
* Drivers accessible via virtual buses (virtio, USB gadget, loopback, netlink, binder, sockets, etc.).
================================================================================
4. EXTRACTING FocusSymbols (PREVENTING DILUTION)
================================================================================
When WorthFuzzing=true, you must extract specific kernel functions into FocusSymbols to guide the fuzzer:
- AVOID UBIQUITOUS LIFECYCLE HOT-PATHS:
Do NOT list generic, ubiquitous functions called by almost every program in the corpus
(including, but not limited to: general memory allocators and deallocators, page fault
and trap handlers, or core synchronization primitives; this is not an exhaustive list).
Listing ubiquitous functions causes the fuzzer to classify thousands of unrelated tests as "focused",
which severely dilutes fuzzing effort away from the actual changes.
- TARGET SPECIFIC FEATURE LOGIC AND ENTRYPOINTS:
List functions that specifically implement the logic being added or altered, or direct API entrypoints
for the subsystem feature under review.
- HANDLING STATIC INLINE FUNCTIONS IN HEADERS (.h):
Compiler-inlined static functions (such as static inlines in mm/*.h or include/linux/*.h) lack
distinct symbol addresses in vmlinux and cannot be targeted directly by symbol coverage filters.
If the changes are primarily in static inline helpers, identify non-static, feature-specific caller
functions in .c files that exercise them (avoiding ubiquitous lifecycle wrappers).
================================================================================
5. IDENTIFYING EnableConfigs
================================================================================
Identify any specific CONFIG_ options required to properly compile and reach the modified code:
- Inspect Kconfig files and #ifdef guards; do not make assumptions.
- Check "depends on" lines in Kconfig to include any non-standard parent subsystem configs needed.
- Strip any 'CONFIG_' prefix (e.g., return "NET_IPV4" instead of "CONFIG_NET_IPV4").
Prefer calling several tools at the same time to save round-trips.
Use set-results tool to provide results of the analysis.
It must be called exactly once before the final reply.
Ignore results of this tool.
Prompt: Target architecture: amd64
For your convenience, here is the diff of the changes:
commit 36c43ca3c7111646d3285f9d7b01922479e6e473
Author: syz-cluster <triage@syzkaller.com>
Date: Tue Oct 13 12:03:54 2026 +0000
syz-cluster: applied patch under review
diff --git a/tools/testing/selftests/mm/cow.c b/tools/testing/selftests/mm/cow.c
index 3264a828575bd..c8c26b26ff629 100644
--- a/tools/testing/selftests/mm/cow.c
+++ b/tools/testing/selftests/mm/cow.c
@@ -1888,7 +1888,7 @@ int main(int argc, char **argv)
thp_save_settings();
pagesize = getpagesize();
- pmdsize = read_pmd_pagesize();
+ pmdsize = pmd_psize();
if (pmdsize) {
/* Only if THP is supported. */
thp_read_settings(&default_settings);
diff --git a/tools/testing/selftests/mm/folio_split_race_test.c b/tools/testing/selftests/mm/folio_split_race_test.c
index 1a9840b73e618..4aa173bffa89a 100644
--- a/tools/testing/selftests/mm/folio_split_race_test.c
+++ b/tools/testing/selftests/mm/folio_split_race_test.c
@@ -234,7 +234,7 @@ int main(void)
ksft_print_header();
page_size = getpagesize();
- pmd_pagesize = read_pmd_pagesize();
+ pmd_pagesize = pmd_psize();
if (!thp_available() || !pmd_pagesize)
ksft_exit_skip("Transparent Hugepages not available\n");
diff --git a/tools/testing/selftests/mm/guard-regions.c b/tools/testing/selftests/mm/guard-regions.c
index f7d53ea3c2527..02f69244f9a42 100644
--- a/tools/testing/selftests/mm/guard-regions.c
+++ b/tools/testing/selftests/mm/guard-regions.c
@@ -2194,14 +2194,20 @@ TEST_F(guard_regions, pagemap_scan)
TEST_F(guard_regions, collapse)
{
const unsigned long page_size = self->page_size;
- const unsigned long size = 2 * HPAGE_SIZE;
- const unsigned long num_pages = size / page_size;
+ const uint64_t hpage_size = pmd_psize();
+ unsigned long size, num_pages;
char *ptr;
int i;
if (!thp_available())
SKIP(return, "Transparent Hugepages not available\n");
+ if (!hpage_size)
+ ksft_exit_fail_msg("reading hpage_size failed\n");
+
+ size = 2 * hpage_size;
+ num_pages = size / page_size;
+
/* Need file to be correct size for tests for non-anon. */
if (variant->backing != ANON_BACKED)
ASSERT_EQ(ftruncate(self->fd, size), 0);
diff --git a/tools/testing/selftests/mm/hmm-tests.c b/tools/testing/selftests/mm/hmm-tests.c
index e5f273ca84c10..02bec1ee54e14 100644
--- a/tools/testing/selftests/mm/hmm-tests.c
+++ b/tools/testing/selftests/mm/hmm-tests.c
@@ -568,7 +568,7 @@ TEST_F(hmm, anon_write_child)
for (migrate = 0; migrate < 2; ++migrate) {
for (use_thp = 0; use_thp < 2; ++use_thp) {
- npages = ALIGN(use_thp ? read_pmd_pagesize() : HMM_BUFFER_SIZE,
+ npages = ALIGN(use_thp ? pmd_psize() : HMM_BUFFER_SIZE,
self->page_size) >> self->page_shift;
ASSERT_NE(npages, 0);
size = npages << self->page_shift;
@@ -729,7 +729,7 @@ TEST_F(hmm, anon_write_huge)
int *ptr;
int ret;
- size = 2 * read_pmd_pagesize();
+ size = 2 * pmd_psize();
buffer = hmm_buffer_alloc(size, size,
PROT_READ | PROT_WRITE,
@@ -1940,7 +1940,7 @@ TEST_F(hmm, migrate_anon_huge_empty)
int *ptr;
int ret;
- size = read_pmd_pagesize();
+ size = pmd_psize();
buffer = hmm_buffer_alloc(2 * size, size,
PROT_READ,
@@ -1983,7 +1983,7 @@ TEST_F(hmm, migrate_anon_huge_zero)
int ret;
int val;
- size = read_pmd_pagesize();
+ size = pmd_psize();
buffer = hmm_buffer_alloc(2 * size, size,
PROT_READ,
@@ -2037,7 +2037,7 @@ TEST_F(hmm, migrate_anon_huge_free)
int *ptr;
int ret;
- size = read_pmd_pagesize();
+ size = pmd_psize();
buffer = hmm_buffer_alloc(2 * size, size,
PROT_READ | PROT_WRITE,
@@ -2090,7 +2090,7 @@ TEST_F(hmm, migrate_anon_huge_fault)
int *ptr;
int ret;
- size = read_pmd_pagesize();
+ size = pmd_psize();
buffer = hmm_buffer_alloc(2 * size, size,
PROT_READ | PROT_WRITE,
@@ -2160,7 +2160,7 @@ TEST_F(hmm, migrate_partial_unmap_fault)
{
struct hmm_buffer *buffer;
unsigned long npages;
- unsigned long size = read_pmd_pagesize();
+ unsigned long size = pmd_psize();
unsigned long unmap_size;
unsigned long offsets[3];
unsigned long i;
@@ -2225,7 +2225,7 @@ TEST_F(hmm, migrate_remap_fault)
{
struct hmm_buffer *buffer;
unsigned long npages;
- unsigned long size = read_pmd_pagesize();
+ unsigned long size = pmd_psize();
unsigned long offsets[3];
unsigned long i;
void *old_ptr, *new_ptr = NULL;
@@ -2322,7 +2322,7 @@ TEST_F(hmm, migrate_anon_huge_err)
int *ptr;
int ret;
- size = read_pmd_pagesize();
+ size = pmd_psize();
buffer = hmm_buffer_alloc(2 * size, 2 * size,
PROT_READ | PROT_WRITE,
@@ -2412,7 +2412,7 @@ TEST_F(hmm, migrate_anon_huge_zero_err)
int *ptr;
int ret;
- size = read_pmd_pagesize();
+ size = pmd_psize();
buffer = hmm_buffer_alloc(2 * size, 2 * size,
PROT_READ,
@@ -2608,7 +2608,7 @@ static inline int run_migration_benchmark(int fd, int use_thp, size_t buffer_siz
TEST_F_TIMEOUT(hmm, benchmark_thp_migration, 120)
{
struct benchmark_results thp_results, regular_results;
- size_t thp_size = read_pmd_pagesize();
+ size_t thp_size = pmd_psize();
int iterations = 5;
if (!thp_size)
diff --git a/tools/testing/selftests/mm/khugepaged.c b/tools/testing/selftests/mm/khugepaged.c
index 1bc7acc66a469..195adb1875e5e 100644
--- a/tools/testing/selftests/mm/khugepaged.c
+++ b/tools/testing/selftests/mm/khugepaged.c
@@ -1684,7 +1684,7 @@ int main(int argc, char **argv)
ksft_exit_skip("Transparent Hugepages not available\n");
page_size = getpagesize();
- hpage_pmd_size = read_pmd_pagesize();
+ hpage_pmd_size = pmd_psize();
if (!hpage_pmd_size)
ksft_exit_fail_msg("Reading PMD pagesize failed\n");
hpage_pmd_nr = hpage_pmd_size / page_size;
diff --git a/tools/testing/selftests/mm/khugepaged_race.c b/tools/testing/selftests/mm/khugepaged_race.c
index abb0678522cd9..6cd68cda07624 100644
--- a/tools/testing/selftests/mm/khugepaged_race.c
+++ b/tools/testing/selftests/mm/khugepaged_race.c
@@ -371,7 +371,7 @@ int main(int argc, char **argv)
ksft_exit_skip("Transparent Hugepages not available\n");
page_size = getpagesize();
- hpage_pmd_size = read_pmd_pagesize();
+ hpage_pmd_size = pmd_psize();
if (!hpage_pmd_size)
ksft_exit_fail_msg("Reading PMD pagesize failed\n");
diff --git a/tools/testing/selftests/mm/khugepaged_sync_check.c b/tools/testing/selftests/mm/khugepaged_sync_check.c
index 28a9b1ff5d447..f31b0987d90c3 100644
--- a/tools/testing/selftests/mm/khugepaged_sync_check.c
+++ b/tools/testing/selftests/mm/khugepaged_sync_check.c
@@ -140,7 +140,7 @@ int main(void)
ksft_exit_skip("Order %d is not a supported anon THP order\n",
TARGET_ORDER);
- hpage_pmd_size = read_pmd_pagesize();
+ hpage_pmd_size = pmd_psize();
if (!hpage_pmd_size)
ksft_exit_fail_msg("Reading PMD pagesize failed\n");
pagemap_fd = open("/proc/self/pagemap", O_RDONLY);
diff --git a/tools/testing/selftests/mm/ksm_tests.c b/tools/testing/selftests/mm/ksm_tests.c
index 6711f4c613711..9e6e1633d0b53 100644
--- a/tools/testing/selftests/mm/ksm_tests.c
+++ b/tools/testing/selftests/mm/ksm_tests.c
@@ -520,19 +520,23 @@ static int ksm_merge_hugepages_time(int merge_type, int mapping, int prot,
struct timespec start_time, end_time;
unsigned long scan_time_ns;
int pagemap_fd, n_normal_pages, n_huge_pages;
+ const uint64_t hpage_size = pmd_psize();
if (!thp_is_enabled()) {
ksft_print_msg("Transparent Hugepages not available\n");
return KSFT_SKIP;
}
+ if (!hpage_size)
+ ksft_exit_fail_msg("reading hpage_size failed\n");
+
map_size *= MB;
size_t len = map_size;
- len -= len % HPAGE_SIZE;
- map_ptr_orig = mmap(NULL, len + HPAGE_SIZE, PROT_READ | PROT_WRITE,
+ len -= len % hpage_size;
+ map_ptr_orig = mmap(NULL, len + hpage_size, PROT_READ | PROT_WRITE,
MAP_ANONYMOUS | MAP_NORESERVE | MAP_PRIVATE, -1, 0);
- map_ptr = map_ptr_orig + HPAGE_SIZE - (uintptr_t)map_ptr_orig % HPAGE_SIZE;
+ map_ptr = map_ptr_orig + hpage_size - (uintptr_t)map_ptr_orig % hpage_size;
if (map_ptr_orig == MAP_FAILED)
err(2, "initial mmap");
@@ -546,7 +550,7 @@ static int ksm_merge_hugepages_time(int merge_type, int mapping, int prot,
n_normal_pages = 0;
n_huge_pages = 0;
- for (void *p = map_ptr; p < map_ptr + len; p += HPAGE_SIZE) {
+ for (void *p = map_ptr; p < map_ptr + len; p += hpage_size) {
if (allocate_transhuge(p, pagemap_fd) < 0)
n_normal_pages++;
else
@@ -577,11 +581,11 @@ static int ksm_merge_hugepages_time(int merge_type, int mapping, int prot,
ksft_print_msg("Average speed: %.3f MiB/s\n", (map_size / MB) /
((double)scan_time_ns / NSEC_PER_SEC));
- munmap(map_ptr_orig, len + HPAGE_SIZE);
+ munmap(map_ptr_orig, len + hpage_size);
return KSFT_PASS;
err_out:
- munmap(map_ptr_orig, len + HPAGE_SIZE);
+ munmap(map_ptr_orig, len + hpage_size);
return KSFT_FAIL;
}
diff --git a/tools/testing/selftests/mm/migration.c b/tools/testing/selftests/mm/migration.c
index d1d0989ed2cad..f268751736740 100644
--- a/tools/testing/selftests/mm/migration.c
+++ b/tools/testing/selftests/mm/migration.c
@@ -228,7 +228,7 @@ TEST_F_TIMEOUT(migration, private_anon_thp, 2*RUNTIME)
if (!thp_is_enabled())
SKIP(return, "Transparent Hugepages not available");
- pmdsize = read_pmd_pagesize();
+ pmdsize = pmd_psize();
if (!pmdsize)
SKIP(return, "Reading PMD pagesize failed");
@@ -262,7 +262,7 @@ TEST_F_TIMEOUT(migration, shared_anon_thp, 2*RUNTIME)
if (!thp_is_enabled())
SKIP(return, "Transparent Hugepages not available");
- pmdsize = read_pmd_pagesize();
+ pmdsize = pmd_psize();
if (!pmdsize)
SKIP(return, "Reading PMD pagesize failed");
diff --git a/tools/testing/selftests/mm/mkdirty.c b/tools/testing/selftests/mm/mkdirty.c
index 68dd447a54542..49ef643a6e639 100644
--- a/tools/testing/selftests/mm/mkdirty.c
+++ b/tools/testing/selftests/mm/mkdirty.c
@@ -330,7 +330,7 @@ int main(void)
int err, tests = 2;
pagesize = getpagesize();
- thpsize = read_pmd_pagesize();
+ thpsize = pmd_psize();
if (thpsize) {
ksft_print_msg("[INFO] detected THP size: %zu KiB\n",
thpsize / 1024);
diff --git a/tools/testing/selftests/mm/pagemap_ioctl.c b/tools/testing/selftests/mm/pagemap_ioctl.c
index 03898b4f6cdab..e9718716feabc 100644
--- a/tools/testing/selftests/mm/pagemap_ioctl.c
+++ b/tools/testing/selftests/mm/pagemap_ioctl.c
@@ -1653,7 +1653,7 @@ int main(int __attribute__((unused)) argc, char *argv[])
ksft_print_header();
page_size = getpagesize();
- hpage_size = read_pmd_pagesize();
+ hpage_size = pmd_psize();
if (init_uffd())
ksft_exit_skip("Failed to initialize userfaultfd\n");
diff --git a/tools/testing/selftests/mm/prctl_thp_disable.c b/tools/testing/selftests/mm/prctl_thp_disable.c
index f9ec1408a6e30..5b7fc68a4072c 100644
--- a/tools/testing/selftests/mm/prctl_thp_disable.c
+++ b/tools/testing/selftests/mm/prctl_thp_disable.c
@@ -132,7 +132,7 @@ FIXTURE_SETUP(prctl_thp_disable_completely)
if (!thp_available())
SKIP(return, "Transparent Hugepages not available\n");
- self->pmdsize = read_pmd_pagesize();
+ self->pmdsize = pmd_psize();
if (!self->pmdsize)
SKIP(return, "Unable to read PMD size\n");
@@ -240,7 +240,7 @@ FIXTURE_SETUP(prctl_thp_disable_except_madvise)
if (!thp_available())
SKIP(return, "Transparent Hugepages not available\n");
- self->pmdsize = read_pmd_pagesize();
+ self->pmdsize = pmd_psize();
if (!self->pmdsize)
SKIP(return, "Unable to read PMD size\n");
diff --git a/tools/testing/selftests/mm/process_madv.c b/tools/testing/selftests/mm/process_madv.c
index 3fffd5f7e6fb4..7e32bad8ab2a9 100644
--- a/tools/testing/selftests/mm/process_madv.c
+++ b/tools/testing/selftests/mm/process_madv.c
@@ -141,7 +141,7 @@ TEST_F(process_madvise, remote_collapse)
void *map_addr;
} info;
- huge_page_size = read_pmd_pagesize();
+ huge_page_size = pmd_psize();
if (huge_page_size <= 0)
SKIP(return, "Could not determine a valid huge page size.\n");
diff --git a/tools/testing/selftests/mm/run_vmtests.sh b/tools/testing/selftests/mm/run_vmtests.sh
index a1b45a3dedaee..f3ec767f562b8 100755
--- a/tools/testing/selftests/mm/run_vmtests.sh
+++ b/tools/testing/selftests/mm/run_vmtests.sh
@@ -343,8 +343,8 @@ fi
CATEGORY="memfd_secret" run_test ./memfd_secret
fi
-# KSM KSM_MERGE_TIME_HUGE_PAGES test with size of 100
-CATEGORY="ksm" run_test ./ksm_tests -H -s 100
+# KSM KSM_MERGE_TIME_HUGE_PAGES test with size of 512
+CATEGORY="ksm" run_test ./ksm_tests -H -s 512
# KSM KSM_MERGE_TIME test with size of 100
CATEGORY="ksm" run_test ./ksm_tests -P -s 100
# KSM MADV_MERGEABLE test with 10 identical pages
diff --git a/tools/testing/selftests/mm/soft-dirty.c b/tools/testing/selftests/mm/soft-dirty.c
index 7f649b6733553..e6fe4259b6f4d 100644
--- a/tools/testing/selftests/mm/soft-dirty.c
+++ b/tools/testing/selftests/mm/soft-dirty.c
@@ -87,7 +87,7 @@ static void test_hugepage(int pagemap_fd, int pagesize)
return;
}
- size_t hpage_len = read_pmd_pagesize();
+ size_t hpage_len = pmd_psize();
if (!hpage_len)
ksft_exit_fail_msg("Reading PMD pagesize failed");
diff --git a/tools/testing/selftests/mm/split_huge_page_test.c b/tools/testing/selftests/mm/split_huge_page_test.c
index 36a6719ff09a8..33a2473327bb7 100644
--- a/tools/testing/selftests/mm/split_huge_page_test.c
+++ b/tools/testing/selftests/mm/split_huge_page_test.c
@@ -615,7 +615,7 @@ int main(int argc, char **argv)
pagesize = getpagesize();
pageshift = ffs(pagesize) - 1;
- pmd_pagesize = read_pmd_pagesize();
+ pmd_pagesize = pmd_psize();
if (!pmd_pagesize)
ksft_exit_fail_msg("Reading PMD pagesize failed\n");
diff --git a/tools/testing/selftests/mm/transhuge-stress.c b/tools/testing/selftests/mm/transhuge-stress.c
index 96f72898ebe0a..ad2831c864dc3 100644
--- a/tools/testing/selftests/mm/transhuge-stress.c
+++ b/tools/testing/selftests/mm/transhuge-stress.c
@@ -34,12 +34,17 @@ int main(int argc, char **argv)
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;
@@ -69,23 +74,23 @@ int main(int argc, char **argv)
}
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));
+ " 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);
+ 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;
+ 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_len = ram >> (hpage_shift - 1);
map = malloc(map_len);
if (!map)
ksft_exit_fail_msg("map malloc\n");
@@ -98,7 +103,7 @@ int main(int argc, char **argv)
memset(map, 0, map_len);
clock_gettime(CLOCK_MONOTONIC, &a);
- for (p = ptr; p < ptr + len; p += HPAGE_SIZE) {
+ for (p = ptr; p < ptr + len; p += hpage_size) {
int64_t pfn;
pfn = allocate_transhuge(p, pagemap_fd);
@@ -106,7 +111,7 @@ int main(int argc, char **argv)
if (pfn < 0) {
nr_failed++;
} else {
- size_t idx = pfn >> (HPAGE_SHIFT - pshift());
+ size_t idx = pfn >> (hpage_shift - pshift());
nr_succeed++;
if (idx >= map_len) {
@@ -122,7 +127,7 @@ int main(int argc, char **argv)
}
/* split transhuge page, keep last page */
- if (madvise(p, HPAGE_SIZE - psize(), MADV_DONTNEED))
+ if (madvise(p, hpage_size - psize(), MADV_DONTNEED))
ksft_exit_fail_msg("MADV_DONTNEED");
}
clock_gettime(CLOCK_MONOTONIC, &b);
@@ -130,7 +135,7 @@ int main(int argc, char **argv)
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),
+ 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) {
diff --git a/tools/testing/selftests/mm/uffd-common.c b/tools/testing/selftests/mm/uffd-common.c
index a76851aced4d0..d5882fc392f0b 100644
--- a/tools/testing/selftests/mm/uffd-common.c
+++ b/tools/testing/selftests/mm/uffd-common.c
@@ -137,7 +137,7 @@ static void shmem_release_pages(uffd_global_test_opts_t *gopts, char *rel_area)
static int shmem_allocate_area(uffd_global_test_opts_t *gopts, void **alloc_area, bool is_src)
{
void *area_alias = NULL;
- size_t bytes = gopts->nr_pages * gopts->page_size, hpage_size = read_pmd_pagesize();
+ size_t bytes = gopts->nr_pages * gopts->page_size, hpage_size = pmd_psize();
unsigned long offset = is_src ? 0 : bytes;
char *p = NULL, *p_alias = NULL;
int mem_fd = uffd_mem_fd_create(bytes * 2, false);
@@ -194,10 +194,10 @@ static void shmem_alias_mapping(uffd_global_test_opts_t *gopts, __u64 *start,
static void shmem_check_pmd_mapping(uffd_global_test_opts_t *gopts, void *p, int expect_nr_hpages)
{
- size_t len = expect_nr_hpages * read_pmd_pagesize();
+ size_t len = expect_nr_hpages * pmd_psize();
if (!check_huge_file(gopts->area_dst_alias, len, expect_nr_hpages,
- read_pmd_pagesize()))
+ pmd_psize()))
err("Did not find expected %d number of hugepages",
expect_nr_hpages);
}
diff --git a/tools/testing/selftests/mm/uffd-unit-tests.c b/tools/testing/selftests/mm/uffd-unit-tests.c
index 2a97ba1d6feb1..298609544445e 100644
--- a/tools/testing/selftests/mm/uffd-unit-tests.c
+++ b/tools/testing/selftests/mm/uffd-unit-tests.c
@@ -588,7 +588,7 @@ static void uffd_minor_test_common(uffd_global_test_opts_t *gopts, bool test_col
uffd_test_ops->check_pmd_mapping(gopts,
gopts->area_dst,
gopts->nr_pages * gopts->page_size /
- read_pmd_pagesize());
+ pmd_psize());
/*
* This won't cause uffd-fault - it purely just makes sure there
* was no corruption.
@@ -1914,7 +1914,7 @@ static void uffd_move_handle_fault(uffd_global_test_opts_t *gopts, struct uffd_m
static void uffd_move_pmd_handle_fault(uffd_global_test_opts_t *gopts, struct uffd_msg *msg,
struct uffd_args *args)
{
- uffd_move_handle_fault_common(gopts, msg, args, read_pmd_pagesize());
+ uffd_move_handle_fault_common(gopts, msg, args, pmd_psize());
}
static void
@@ -2030,7 +2030,7 @@ static void uffd_move_pmd_test(uffd_global_test_opts_t *gopts, uffd_test_args_t
{
if (madvise(gopts->area_dst, gopts->nr_pages * gopts->page_size, MADV_HUGEPAGE))
err("madvise(MADV_HUGEPAGE) failure");
- uffd_move_test_common(gopts, targs, read_pmd_pagesize(),
+ uffd_move_test_common(gopts, targs, pmd_psize(),
uffd_move_pmd_handle_fault);
}
@@ -2038,7 +2038,7 @@ static void uffd_move_pmd_split_test(uffd_global_test_opts_t *gopts, uffd_test_a
{
if (madvise(gopts->area_dst, gopts->nr_pages * gopts->page_size, MADV_NOHUGEPAGE))
err("madvise(MADV_NOHUGEPAGE) failure");
- uffd_move_test_common(gopts, targs, read_pmd_pagesize(),
+ uffd_move_test_common(gopts, targs, pmd_psize(),
uffd_move_pmd_handle_fault);
}
diff --git a/tools/testing/selftests/mm/uffd-wp-mremap.c b/tools/testing/selftests/mm/uffd-wp-mremap.c
index c48eaab8e75cf..15cff68c59a22 100644
--- a/tools/testing/selftests/mm/uffd-wp-mremap.c
+++ b/tools/testing/selftests/mm/uffd-wp-mremap.c
@@ -38,7 +38,7 @@ static int detect_thp_sizes(size_t sizes[], int max)
int i;
/* thp not supported at all. */
- if (!read_pmd_pagesize())
+ if (!pmd_psize())
return 0;
orders = thp_supported_orders();
diff --git a/tools/testing/selftests/mm/vm_util.c b/tools/testing/selftests/mm/vm_util.c
index 515031b8283da..8ef226107d788 100644
--- a/tools/testing/selftests/mm/vm_util.c
+++ b/tools/testing/selftests/mm/vm_util.c
@@ -21,6 +21,8 @@
unsigned int __page_size;
unsigned int __page_shift;
+uint64_t __pmd_psize = -1ull;
+uint64_t __pmd_pshift = -1ull;
uint64_t pagemap_get_entry(int fd, char *start)
{
@@ -155,25 +157,46 @@ bool check_for_pattern(FILE *fp, const char *pattern, char *buf, size_t len)
return false;
}
-uint64_t read_pmd_pagesize(void)
+uint64_t pmd_psize(void)
{
int fd;
char buf[20];
ssize_t num_read;
+ if (__pmd_psize != -1ull)
+ return __pmd_psize;
+
fd = open(PMD_SIZE_FILE_PATH, O_RDONLY);
- if (fd == -1)
+ if (fd == -1) {
+ __pmd_psize = 0;
return 0;
+ }
num_read = read(fd, buf, 19);
if (num_read < 1) {
+ __pmd_psize = 0;
close(fd);
return 0;
}
buf[num_read] = '\0';
close(fd);
- return strtoul(buf, NULL, 10);
+ __pmd_psize = strtoul(buf, NULL, 10);
+
+ return __pmd_psize;
+}
+
+uint64_t pmd_pshift(void)
+{
+ if (__pmd_pshift != -1ull)
+ return __pmd_pshift;
+
+ if (__pmd_psize == -1ull)
+ __pmd_psize = pmd_psize();
+
+ __pmd_pshift = size_to_shift(__pmd_psize);
+
+ return __pmd_pshift;
}
unsigned long rss_anon(void)
@@ -437,7 +460,7 @@ static bool __check_huge(void *addr, size_t len, int nr_hpages,
char *start = addr;
char *end = start + len;
- pmd_pagesize = read_pmd_pagesize();
+ pmd_pagesize = pmd_psize();
if (!pmd_pagesize)
ksft_exit_fail_msg("reading PMD pagesize failed\n");
@@ -489,14 +512,19 @@ bool check_huge_file(void *addr, size_t len, int nr_hpages, uint64_t hpage_size)
int64_t allocate_transhuge(void *ptr, int pagemap_fd)
{
uint64_t ent[2];
+ const uint64_t hpage_size = pmd_psize();
+ const uint64_t hpage_shift = pmd_pshift();
+
+ if (!hpage_size || !hpage_shift)
+ return -1;
/* drop pmd */
- if (mmap(ptr, HPAGE_SIZE, PROT_READ | PROT_WRITE,
+ if (mmap(ptr, hpage_size, PROT_READ | PROT_WRITE,
MAP_FIXED | MAP_ANONYMOUS |
MAP_NORESERVE | MAP_PRIVATE, -1, 0) != ptr)
ksft_exit_fail_msg("mmap transhuge\n");
- if (madvise(ptr, HPAGE_SIZE, MADV_HUGEPAGE))
+ if (madvise(ptr, hpage_size, MADV_HUGEPAGE))
ksft_exit_fail_msg("MADV_HUGEPAGE\n");
/* allocate transparent huge page */
@@ -508,7 +536,7 @@ int64_t allocate_transhuge(void *ptr, int pagemap_fd)
if (PAGEMAP_PRESENT(ent[0]) && PAGEMAP_PRESENT(ent[1]) &&
PAGEMAP_PFN(ent[0]) + 1 == PAGEMAP_PFN(ent[1]) &&
- !(PAGEMAP_PFN(ent[0]) & ((1 << (HPAGE_SHIFT - pshift())) - 1)))
+ !(PAGEMAP_PFN(ent[0]) & ((1 << (hpage_shift - pshift())) - 1)))
return PAGEMAP_PFN(ent[0]);
return -1;
diff --git a/tools/testing/selftests/mm/vm_util.h b/tools/testing/selftests/mm/vm_util.h
index b5d59729d4327..67ff4bba5707a 100644
--- a/tools/testing/selftests/mm/vm_util.h
+++ b/tools/testing/selftests/mm/vm_util.h
@@ -35,6 +35,8 @@
extern unsigned int __page_size;
extern unsigned int __page_shift;
+extern uint64_t __pmd_psize;
+extern uint64_t __pmd_pshift;
/*
* Represents an open fd and PROCMAP_QUERY state for binary (via ioctl)
@@ -92,7 +94,8 @@ bool pagemap_is_populated(int fd, char *start);
unsigned long pagemap_get_pfn(int fd, char *start);
void clear_softdirty(void);
bool check_for_pattern(FILE *fp, const char *pattern, char *buf, size_t len);
-uint64_t read_pmd_pagesize(void);
+uint64_t pmd_psize(void);
+uint64_t pmd_pshift(void);
unsigned long rss_anon(void);
bool check_huge_anon(void *addr, size_t len, int nr_hpages, uint64_t hpage_size);
bool check_huge_file(void *addr, size_t len, int nr_hpages, uint64_t hpage_size);
@@ -156,6 +159,18 @@ static inline int sz2ord(size_t size, size_t pagesize)
return __builtin_ctzll(size / pagesize);
}
+static inline uint64_t size_to_shift(uint64_t size)
+{
+ /*
+ * The function returns the corresponding shift only when the size
+ * is a power of two; otherwise, it returns 0.
+ */
+ if (!size || (size & (size - 1)))
+ return 0;
+
+ return ffsl(size) - 1;
+}
+
void *sys_mremap(void *old_address, unsigned long old_size,
unsigned long new_size, int flags, void *new_address);
@@ -168,12 +183,6 @@ int ksm_stop(void);
int get_hardware_corrupted_size(unsigned long *val);
int unpoison_memory(unsigned long pfn);
-/*
- * On ppc64 this will only work with radix 2M hugepage size
- */
-#define HPAGE_SHIFT 21
-#define HPAGE_SIZE (1 << HPAGE_SHIFT)
-
#define PAGEMAP_PRESENT(ent) (((ent) & (1ull << 63)) != 0)
#define PAGEMAP_PFN(ent) ((ent) & ((1ull << 55) - 1))
|
| 3/2 | 2026/10/13 12:03 | llm | patch-evaluator |
0mModel:gemini-3.8-flash Args: null Results: null Tokens: input: 13900 output: 44 thoughts: 982 Thoughts: **Fuzzing Evaluation: A User-Space Selftest Patch** Okay, let's assess whether this patch series is worth fuzzing with syzkaller. The first step is to carefully examine the diff. It looks like the changes are confined to the `tools/testing/selftests/mm/` directory, which is immediately raising a flag. I recall the criteria for *not* fuzzing, and it hinges on the modifications being strictly within specific categories. My mind immediately recalls the rule: user-space directories, selftests, and scripts that *don't* impact the kernel image (vmlinux) or modules are out. Given that *every single* modified file falls under `tools/testing/selftests/mm/`, the initial impression is strong: this patch isn't suitable for fuzzing. These are, by definition, self-tests, which are user-space utilities. They aren't part of the kernel proper. Thus, based solely on the file paths, the 'WorthFuzzing' decision would be negative. Now, to be *absolutely* sure, I need to verify that no kernel files are touched. Although the prompt indicates that the changes have already been applied and committed as the HEAD commit, I need to make sure. I'm aware that it's important to cross-check. I could use git commands such as `git diff HEAD~1` or `git log`, but considering the prompt, I might have to use a tool to check. The prompt then makes a statement I will follow: "Do NOT rely on internal assumptions. You must actively use your code access tools to inspect the actual source code, callers, and surrounding context." As I have no assumption of whether git diff or git log are permitted, but I *must* access the source, I will rely on my `grepper` tool to search for things like `pmd_psize` in the `tools/testing/selftests/mm/vm_util.h` file, as I think it's likely to be in the code if it's there. I'll proceed with this check to gain certainty, but the initial evaluation strongly suggests that fuzzing isn't warranted in this case. |
| 4/2 | 2026/10/13 12:04 | tool | grepper |
0mArgs:{
"Expression": "uint64_t pmd_psize\\(void\\)",
"PathPrefixes": [
"tools/testing/selftests/mm/"
]
}Results: {
"Output": "tools/testing/selftests/mm/vm_util.c=151=bool check_for_pattern(FILE *fp, const char *pattern, char *buf, size_t len)\n--\ntools/testing/selftests/mm/vm_util.c-159-\ntools/testing/selftests/mm/vm_util.c:160:uint64_t pmd_psize(void)\ntools/testing/selftests/mm/vm_util.c-161-{\n--\ntools/testing/selftests/mm/vm_util.h=96=bool check_for_pattern(FILE *fp, const char *pattern, char *buf, size_t len);\ntools/testing/selftests/mm/vm_util.h:97:uint64_t pmd_psize(void);\ntools/testing/selftests/mm/vm_util.h-98-uint64_t pmd_pshift(void);\n"
} |
| 5/2 | 2026/10/13 12:04 | llm | patch-evaluator |
0mModel:gemini-3.8-flash Args: null Results: null Tokens: input: 15646 output: 33 thoughts: 60 Thoughts: Okay, let's see. My first thought is to quickly verify if anything *outside* the `tools/` directory has been touched. It's just good practice to double-check that the scope of the change aligns with what I expect. Then, from the commit diff provided in the prompt, it looks like the changes are isolated within `tools/testing/selftests/mm/`. To solidify this understanding, I should confirm that the variable `size_to_shift` that's mentioned is *only* appearing within the `mm/` directory, or potentially in `include/`, but nowhere else. This cross-check will give me confidence in the commit. |
| 6/2 | 2026/10/13 12:04 | tool | grepper |
0mError:no matches Args: {
"Expression": "size_to_shift",
"PathPrefixes": [
"mm/",
"include/"
]
}Results: {
"error": "no matches"
} |
| 7/2 | 2026/10/13 12:04 | llm | patch-evaluator |
0mModel:gemini-3.8-flash Args: null Results: null Tokens: input: 15896 output: 83 thoughts: 194 Thoughts: Okay, here's my assessment of this patch series, focusing on its fuzzing implications: **Fuzzing Applicability Assessment** Right, let me break this down. My primary concern here is determining if these changes are relevant to fuzzing efforts. The critical variable, `size_to_shift`, is *only* found in `tools/testing/selftests/mm/vm_util.h`. That's a strong indicator. Then, I see that every single file modified by this patch series resides within `tools/testing/selftests/mm/`. Excellent, that reinforces the initial observation. Now, I'm consulting section 2 of the guidelines. It clearly states that anything within "User-space directories, self-tests, samples, or scripts (e.g., tools/, samples/, scripts/, usr/) that do not affect the compiled kernel image (vmlinux) or kernel modules" should have `WorthFuzzing=false`. Given that these changes are strictly within the user-space MM selftests directory, and as the reasoning explains they are not touching any kernel executable code, I'm confident in setting `WorthFuzzing` to `false`. Consequently, this means I'll set: * `WorthFuzzing`: `false` * `FocusSymbols`: `[]` (an empty list, as expected) * `EnableConfigs`: `[]` (also empty). Essentially, these modifications are isolated to user-space memory management tests, which won't directly introduce kernel-level vulnerabilities that fuzzing would typically target. Okay, that's what I'll 'set-results' as. |
| 8/2 | 2026/10/13 12:04 | tool | set-results |
0mArgs:{
"EnableConfigs": [],
"FocusSymbols": [],
"Reasoning": "All modifications in this patch series are strictly confined to user-space self-tests in tools/testing/selftests/mm/. They do not affect the compiled kernel image (vmlinux) or any kernel modules, and are therefore not fuzzable.",
"WorthFuzzing": false
}Results: {
"EnableConfigs": null,
"FocusSymbols": [],
"Reasoning": "All modifications in this patch series are strictly confined to user-space self-tests in tools/testing/selftests/mm/. They do not affect the compiled kernel image (vmlinux) or any kernel modules, and are therefore not fuzzable.",
"WorthFuzzing": false
} |
| 9/1 | 2026/10/13 12:04 | action | If |
0mArgs:{
"WorthFuzzing": false
}Results: null |
| Total Calls | Total Tokens | Avg Tokens | Total Duration (Seconds) | Avg Duration (Seconds) |
|---|
| Total Calls | Total Duration (Seconds) | Avg Duration (Seconds) |
|---|