From: Lorenzo Stoakes <lorenzo.stoakes@oracle.com>
To: Andrew Morton <akpm@linux-foundation.org>
Cc: Vlastimil Babka <vbabka@suse.cz>, Jann Horn <jannh@google.com>,
"Liam R . Howlett" <Liam.Howlett@oracle.com>,
Suren Baghdasaryan <surenb@google.com>,
Matthew Wilcox <willy@infradead.org>,
David Hildenbrand <david@redhat.com>,
Pedro Falcato <pfalcato@suse.de>, Rik van Riel <riel@surriel.com>,
Harry Yoo <harry.yoo@oracle.com>, Zi Yan <ziy@nvidia.com>,
Baolin Wang <baolin.wang@linux.alibaba.com>,
Nico Pache <npache@redhat.com>,
Ryan Roberts <ryan.roberts@arm.com>, Dev Jain <dev.jain@arm.com>,
Jakub Matena <matenajakub@gmail.com>,
Wei Yang <richard.weiyang@gmail.com>,
Barry Song <baohua@kernel.org>,
linux-mm@kvack.org, linux-kernel@vger.kernel.org
Subject: [PATCH 08/11] tools/testing/selftests: expand mremap() tests for MREMAP_RELOCATE_ANON
Date: Mon, 9 Jun 2025 14:26:42 +0100 [thread overview]
Message-ID: <25ed4f20f8874db9a496539aa9793013d22de06d.1749473726.git.lorenzo.stoakes@oracle.com> (raw)
In-Reply-To: <cover.1749473726.git.lorenzo.stoakes@oracle.com>
Adjust every relevant test (that is, one that moves memory) to also perform
the same test using MREMAP_MUST_RELOCATE_ANON to assert that it is behaving
as expected.
In order to avoid glibc not being up-to-date, also move to using the
mremap() system call direct, and import the linux/mman.h header, which will
use the tool linux header wrappers, to get the latest mremap defines.
Also take careful precaution in the instance where we might unexpectedly
fail the 'mremap move within range' test due to large folios mapped outside
of the range we are relocating.
In these instances, if we test with MREMAP_MUST_RELOCATE_ANON, we ensure
the folios in question are not huge. If testing with MREMAP_RELOCATE_ANON
we do not - this asserts that this correctly falls back to non-relocate
anon behaviour.
In cases where MREMAP_MUST_RELOCATE_ANON is used, we attempt to immediately
trigger reclaim to also assert that the rmap state is uncorrupted.
Signed-off-by: Lorenzo Stoakes <lorenzo.stoakes@oracle.com>
---
tools/testing/selftests/mm/mremap_test.c | 262 +++++++++++++++--------
1 file changed, 168 insertions(+), 94 deletions(-)
diff --git a/tools/testing/selftests/mm/mremap_test.c b/tools/testing/selftests/mm/mremap_test.c
index bb84476a177f..5d6ff0d1da7d 100644
--- a/tools/testing/selftests/mm/mremap_test.c
+++ b/tools/testing/selftests/mm/mremap_test.c
@@ -8,11 +8,13 @@
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
+#include <linux/mman.h>
#include <sys/mman.h>
#include <time.h>
#include <stdbool.h>
#include "../kselftest.h"
+#include "vm_util.h"
#define EXPECT_SUCCESS 0
#define EXPECT_FAILURE 1
@@ -34,6 +36,7 @@ struct config {
unsigned long long dest_alignment;
unsigned long long region_size;
int overlapping;
+ bool use_relocate_anon;
unsigned int dest_preamble_size;
};
@@ -60,7 +63,8 @@ enum {
#define PTE page_size
#define MAKE_TEST(source_align, destination_align, size, \
- overlaps, should_fail, test_name) \
+ overlaps, use_relocate_anon, should_fail, \
+ test_name) \
(struct test){ \
.name = test_name, \
.config = { \
@@ -68,6 +72,7 @@ enum {
.dest_alignment = destination_align, \
.region_size = size, \
.overlapping = overlaps, \
+ .use_relocate_anon = use_relocate_anon, \
}, \
.expect_failure = should_fail \
}
@@ -184,6 +189,12 @@ static void *get_source_mapping(struct config c)
unsigned long long addr = 0ULL;
void *src_addr = NULL;
unsigned long long mmap_min_addr;
+ int mmap_flags = MAP_FIXED_NOREPLACE | MAP_ANONYMOUS;
+
+ if (c.use_relocate_anon)
+ mmap_flags |= MAP_PRIVATE;
+ else
+ mmap_flags |= MAP_SHARED;
mmap_min_addr = get_mmap_min_addr();
/*
@@ -198,8 +209,7 @@ static void *get_source_mapping(struct config c)
goto retry;
src_addr = mmap((void *) addr, c.region_size, PROT_READ | PROT_WRITE,
- MAP_FIXED_NOREPLACE | MAP_ANONYMOUS | MAP_SHARED,
- -1, 0);
+ mmap_flags, -1, 0);
if (src_addr == MAP_FAILED) {
if (errno == EPERM || errno == EEXIST)
goto retry;
@@ -251,7 +261,7 @@ static void mremap_expand_merge(FILE *maps_fp, unsigned long page_size)
}
munmap(start + page_size, page_size);
- remap = mremap(start, page_size, 2 * page_size, 0);
+ remap = sys_mremap(start, page_size, 2 * page_size, 0, 0);
if (remap == MAP_FAILED) {
ksft_print_msg("mremap failed: %s\n", strerror(errno));
munmap(start, page_size);
@@ -292,7 +302,8 @@ static void mremap_expand_merge_offset(FILE *maps_fp, unsigned long page_size)
/* Unmap final page to ensure we have space to expand. */
munmap(start + 2 * page_size, page_size);
- remap = mremap(start + page_size, page_size, 2 * page_size, 0);
+
+ remap = sys_mremap(start + page_size, page_size, 2 * page_size, 0, 0);
if (remap == MAP_FAILED) {
ksft_print_msg("mremap failed: %s\n", strerror(errno));
munmap(start, 2 * page_size);
@@ -324,20 +335,35 @@ static void mremap_expand_merge_offset(FILE *maps_fp, unsigned long page_size)
*
* |DDDDddddSSSSssss|
*/
-static void mremap_move_within_range(unsigned int pattern_seed, char *rand_addr)
+static void mremap_move_within_range(unsigned int pattern_seed, char *rand_addr,
+ char *test_suffix, int extra_flags)
{
char *test_name = "mremap mremap move within range";
void *src, *dest;
unsigned int i, success = 1;
-
size_t size = SIZE_MB(20);
void *ptr = mmap(NULL, size, PROT_READ | PROT_WRITE,
MAP_PRIVATE | MAP_ANONYMOUS, -1, 0);
+ int mremap_flags = MREMAP_MAYMOVE | MREMAP_FIXED;
+
if (ptr == MAP_FAILED) {
perror("mmap");
success = 0;
goto out;
}
+
+ /*
+ * If THP is enabled, we may end up spanning a range which has large
+ * folios not enclosed within the mapping, which will disallow the
+ * relocate.
+ *
+ * In this case, disallow huge pages in the range.
+ */
+ if (extra_flags & MREMAP_MUST_RELOCATE_ANON)
+ madvise(ptr, size, MADV_NOHUGEPAGE);
+
+ mremap_flags |= extra_flags;
+
memset(ptr, 0, size);
src = ptr + SIZE_MB(6);
@@ -348,8 +374,8 @@ static void mremap_move_within_range(unsigned int pattern_seed, char *rand_addr)
dest = src - SIZE_MB(2);
- void *new_ptr = mremap(src + SIZE_MB(1), SIZE_MB(1), SIZE_MB(1),
- MREMAP_MAYMOVE | MREMAP_FIXED, dest + SIZE_MB(1));
+ void *new_ptr = sys_mremap(src + SIZE_MB(1), SIZE_MB(1), SIZE_MB(1),
+ mremap_flags, dest + SIZE_MB(1));
if (new_ptr == MAP_FAILED) {
perror("mremap");
success = 0;
@@ -375,9 +401,9 @@ static void mremap_move_within_range(unsigned int pattern_seed, char *rand_addr)
perror("munmap");
if (success)
- ksft_test_result_pass("%s\n", test_name);
+ ksft_test_result_pass("%s%s\n", test_name, test_suffix);
else
- ksft_test_result_fail("%s\n", test_name);
+ ksft_test_result_fail("%s%s\n", test_name, test_suffix);
}
/* Returns the time taken for the remap on success else returns -1. */
@@ -390,6 +416,10 @@ static long long remap_region(struct config c, unsigned int threshold_mb,
long long start_ns, end_ns, align_mask, ret, offset;
unsigned long long threshold;
unsigned long num_chunks;
+ int mremap_flags = MREMAP_MAYMOVE | MREMAP_FIXED;
+
+ if (c.use_relocate_anon)
+ mremap_flags |= MREMAP_MUST_RELOCATE_ANON;
if (threshold_mb == VALIDATION_NO_THRESHOLD)
threshold = c.region_size;
@@ -431,10 +461,15 @@ static long long remap_region(struct config c, unsigned int threshold_mb,
}
if (c.dest_preamble_size) {
+ int mmap_flags = MAP_FIXED_NOREPLACE | MAP_ANONYMOUS;
+
+ if (c.use_relocate_anon)
+ mmap_flags |= MAP_PRIVATE;
+ else
+ mmap_flags |= MAP_SHARED;
+
dest_preamble_addr = mmap((void *) addr - c.dest_preamble_size, c.dest_preamble_size,
- PROT_READ | PROT_WRITE,
- MAP_FIXED_NOREPLACE | MAP_ANONYMOUS | MAP_SHARED,
- -1, 0);
+ PROT_READ | PROT_WRITE, mmap_flags, -1, 0);
if (dest_preamble_addr == MAP_FAILED) {
ksft_print_msg("Failed to map dest preamble region: %s\n",
strerror(errno));
@@ -447,8 +482,8 @@ static long long remap_region(struct config c, unsigned int threshold_mb,
}
clock_gettime(CLOCK_MONOTONIC, &t_start);
- dest_addr = mremap(src_addr, c.region_size, c.region_size,
- MREMAP_MAYMOVE|MREMAP_FIXED, (char *) addr);
+ dest_addr = sys_mremap(src_addr, c.region_size, c.region_size,
+ mremap_flags, (char *) addr);
clock_gettime(CLOCK_MONOTONIC, &t_end);
if (dest_addr == MAP_FAILED) {
@@ -549,6 +584,10 @@ static long long remap_region(struct config c, unsigned int threshold_mb,
* subsequent tests. So we clean up mappings after each test.
*/
clean_up_dest:
+ /* Trigger reclaim to assert that adjusted rmap state is valid. */
+ if (c.use_relocate_anon)
+ madvise(dest_addr, c.region_size, MADV_PAGEOUT);
+
munmap(dest_addr, c.region_size);
clean_up_dest_preamble:
if (c.dest_preamble_size && dest_preamble_addr)
@@ -565,16 +604,19 @@ static long long remap_region(struct config c, unsigned int threshold_mb,
* down address landed on a mapping that maybe does not exist.
*/
static void mremap_move_1mb_from_start(unsigned int pattern_seed,
- char *rand_addr)
+ char *rand_addr, char *test_suffix,
+ int extra_flags)
{
char *test_name = "mremap move 1mb from start at 1MB+256KB aligned src";
void *src = NULL, *dest = NULL;
unsigned int i, success = 1;
-
+ int mremap_flags = MREMAP_MAYMOVE | MREMAP_FIXED;
/* Config to reuse get_source_mapping() to do an aligned mmap. */
struct config c = {
.src_alignment = SIZE_MB(1) + SIZE_KB(256),
- .region_size = SIZE_MB(6)
+ .region_size = SIZE_MB(6),
+ .use_relocate_anon = extra_flags & (MREMAP_RELOCATE_ANON |
+ MREMAP_MUST_RELOCATE_ANON),
};
src = get_source_mapping(c);
@@ -583,6 +625,12 @@ static void mremap_move_1mb_from_start(unsigned int pattern_seed,
goto out;
}
+ /* See comment in mremap_move_within_range(). */
+ if (extra_flags & MREMAP_MUST_RELOCATE_ANON)
+ madvise(src, c.region_size, MADV_NOHUGEPAGE);
+
+ mremap_flags |= extra_flags;
+
c.src_alignment = SIZE_MB(1) + SIZE_KB(256);
dest = get_source_mapping(c);
if (!dest) {
@@ -599,8 +647,8 @@ static void mremap_move_1mb_from_start(unsigned int pattern_seed,
*/
munmap(dest, SIZE_MB(1));
- void *new_ptr = mremap(src + SIZE_MB(1), SIZE_MB(1), SIZE_MB(1),
- MREMAP_MAYMOVE | MREMAP_FIXED, dest + SIZE_MB(1));
+ void *new_ptr = sys_mremap(src + SIZE_MB(1), SIZE_MB(1), SIZE_MB(1),
+ mremap_flags, dest + SIZE_MB(1));
if (new_ptr == MAP_FAILED) {
perror("mremap");
success = 0;
@@ -629,9 +677,10 @@ static void mremap_move_1mb_from_start(unsigned int pattern_seed,
perror("munmap dest");
if (success)
- ksft_test_result_pass("%s\n", test_name);
+ ksft_test_result_pass("%s%s\n", test_name, test_suffix);
+
else
- ksft_test_result_fail("%s\n", test_name);
+ ksft_test_result_fail("%s%s\n", test_name, test_suffix);
}
static void run_mremap_test_case(struct test test_case, int *failures,
@@ -640,13 +689,17 @@ static void run_mremap_test_case(struct test test_case, int *failures,
{
long long remap_time = remap_region(test_case.config, threshold_mb,
rand_addr);
+ char *relocate_anon_suffix = " [MREMAP_MUST_RELOCATE_ANON]";
+ struct config *c = &test_case.config;
if (remap_time < 0) {
if (test_case.expect_failure)
- ksft_test_result_xfail("%s\n\tExpected mremap failure\n",
- test_case.name);
+ ksft_test_result_xfail("%s%s\n\tExpected mremap failure\n",
+ test_case.name,
+ c->use_relocate_anon ? relocate_anon_suffix : "");
else {
- ksft_test_result_fail("%s\n", test_case.name);
+ ksft_test_result_fail("%s%s\n", test_case.name,
+ c->use_relocate_anon ? relocate_anon_suffix : "");
*failures += 1;
}
} else {
@@ -656,10 +709,13 @@ static void run_mremap_test_case(struct test test_case, int *failures,
*/
if (threshold_mb == VALIDATION_NO_THRESHOLD ||
test_case.config.region_size <= threshold_mb * _1MB)
- ksft_test_result_pass("%s\n\tmremap time: %12lldns\n",
- test_case.name, remap_time);
+ ksft_test_result_pass("%s%s\n\tmremap time: %12lldns\n",
+ test_case.name,
+ c->use_relocate_anon ? relocate_anon_suffix : "",
+ remap_time);
else
- ksft_test_result_pass("%s\n", test_case.name);
+ ksft_test_result_pass("%s%s\n", test_case.name,
+ c->use_relocate_anon ? relocate_anon_suffix : "");
}
}
@@ -703,8 +759,8 @@ static int parse_args(int argc, char **argv, unsigned int *threshold_mb,
return 0;
}
-#define MAX_TEST 15
-#define MAX_PERF_TEST 3
+#define MAX_TEST 30
+#define MAX_PERF_TEST 6
int main(int argc, char **argv)
{
int failures = 0;
@@ -721,12 +777,15 @@ int main(int argc, char **argv)
char *rand_addr;
size_t rand_size;
int num_expand_tests = 2;
- int num_misc_tests = 2;
+ int num_misc_tests = 6;
struct test test_cases[MAX_TEST] = {};
struct test perf_test_cases[MAX_PERF_TEST];
int page_size;
time_t t;
FILE *maps_fp;
+ bool use_relocate_anon = false;
+ struct test *test_case = test_cases;
+ struct test *perf_test_case = perf_test_cases;
pattern_seed = (unsigned int) time(&t);
@@ -763,66 +822,71 @@ int main(int argc, char **argv)
page_size = sysconf(_SC_PAGESIZE);
- /* Expected mremap failures */
- test_cases[0] = MAKE_TEST(page_size, page_size, page_size,
- OVERLAPPING, EXPECT_FAILURE,
- "mremap - Source and Destination Regions Overlapping");
-
- test_cases[1] = MAKE_TEST(page_size, page_size/4, page_size,
- NON_OVERLAPPING, EXPECT_FAILURE,
- "mremap - Destination Address Misaligned (1KB-aligned)");
- test_cases[2] = MAKE_TEST(page_size/4, page_size, page_size,
- NON_OVERLAPPING, EXPECT_FAILURE,
- "mremap - Source Address Misaligned (1KB-aligned)");
-
- /* Src addr PTE aligned */
- test_cases[3] = MAKE_TEST(PTE, PTE, PTE * 2,
- NON_OVERLAPPING, EXPECT_SUCCESS,
- "8KB mremap - Source PTE-aligned, Destination PTE-aligned");
-
- /* Src addr 1MB aligned */
- test_cases[4] = MAKE_TEST(_1MB, PTE, _2MB, NON_OVERLAPPING, EXPECT_SUCCESS,
- "2MB mremap - Source 1MB-aligned, Destination PTE-aligned");
- test_cases[5] = MAKE_TEST(_1MB, _1MB, _2MB, NON_OVERLAPPING, EXPECT_SUCCESS,
- "2MB mremap - Source 1MB-aligned, Destination 1MB-aligned");
-
- /* Src addr PMD aligned */
- test_cases[6] = MAKE_TEST(PMD, PTE, _4MB, NON_OVERLAPPING, EXPECT_SUCCESS,
- "4MB mremap - Source PMD-aligned, Destination PTE-aligned");
- test_cases[7] = MAKE_TEST(PMD, _1MB, _4MB, NON_OVERLAPPING, EXPECT_SUCCESS,
- "4MB mremap - Source PMD-aligned, Destination 1MB-aligned");
- test_cases[8] = MAKE_TEST(PMD, PMD, _4MB, NON_OVERLAPPING, EXPECT_SUCCESS,
- "4MB mremap - Source PMD-aligned, Destination PMD-aligned");
-
- /* Src addr PUD aligned */
- test_cases[9] = MAKE_TEST(PUD, PTE, _2GB, NON_OVERLAPPING, EXPECT_SUCCESS,
- "2GB mremap - Source PUD-aligned, Destination PTE-aligned");
- test_cases[10] = MAKE_TEST(PUD, _1MB, _2GB, NON_OVERLAPPING, EXPECT_SUCCESS,
- "2GB mremap - Source PUD-aligned, Destination 1MB-aligned");
- test_cases[11] = MAKE_TEST(PUD, PMD, _2GB, NON_OVERLAPPING, EXPECT_SUCCESS,
- "2GB mremap - Source PUD-aligned, Destination PMD-aligned");
- test_cases[12] = MAKE_TEST(PUD, PUD, _2GB, NON_OVERLAPPING, EXPECT_SUCCESS,
- "2GB mremap - Source PUD-aligned, Destination PUD-aligned");
-
- /* Src and Dest addr 1MB aligned. 5MB mremap. */
- test_cases[13] = MAKE_TEST(_1MB, _1MB, _5MB, NON_OVERLAPPING, EXPECT_SUCCESS,
- "5MB mremap - Source 1MB-aligned, Destination 1MB-aligned");
-
- /* Src and Dest addr 1MB aligned. 5MB mremap. */
- test_cases[14] = MAKE_TEST(_1MB, _1MB, _5MB, NON_OVERLAPPING, EXPECT_SUCCESS,
- "5MB mremap - Source 1MB-aligned, Dest 1MB-aligned with 40MB Preamble");
- test_cases[14].config.dest_preamble_size = 10 * _4MB;
-
- perf_test_cases[0] = MAKE_TEST(page_size, page_size, _1GB, NON_OVERLAPPING, EXPECT_SUCCESS,
- "1GB mremap - Source PTE-aligned, Destination PTE-aligned");
- /*
- * mremap 1GB region - Page table level aligned time
- * comparison.
- */
- perf_test_cases[1] = MAKE_TEST(PMD, PMD, _1GB, NON_OVERLAPPING, EXPECT_SUCCESS,
- "1GB mremap - Source PMD-aligned, Destination PMD-aligned");
- perf_test_cases[2] = MAKE_TEST(PUD, PUD, _1GB, NON_OVERLAPPING, EXPECT_SUCCESS,
- "1GB mremap - Source PUD-aligned, Destination PUD-aligned");
+ do {
+ /* Expected mremap failures */
+ *test_case++ = MAKE_TEST(page_size, page_size, page_size,
+ OVERLAPPING, use_relocate_anon, EXPECT_FAILURE,
+ "mremap - Source and Destination Regions Overlapping");
+
+ *test_case++ = MAKE_TEST(page_size, page_size/4, page_size,
+ NON_OVERLAPPING, use_relocate_anon, EXPECT_FAILURE,
+ "mremap - Destination Address Misaligned (1KB-aligned)");
+ *test_case++ = MAKE_TEST(page_size/4, page_size, page_size,
+ NON_OVERLAPPING, use_relocate_anon, EXPECT_FAILURE,
+ "mremap - Source Address Misaligned (1KB-aligned)");
+
+ /* Src addr PTE aligned */
+ *test_case++ = MAKE_TEST(PTE, PTE, PTE * 2,
+ NON_OVERLAPPING, use_relocate_anon, EXPECT_SUCCESS,
+ "8KB mremap - Source PTE-aligned, Destination PTE-aligned");
+
+ /* Src addr 1MB aligned */
+ *test_case++ = MAKE_TEST(_1MB, PTE, _2MB, NON_OVERLAPPING, use_relocate_anon, EXPECT_SUCCESS,
+ "2MB mremap - Source 1MB-aligned, Destination PTE-aligned");
+ *test_case++ = MAKE_TEST(_1MB, _1MB, _2MB, NON_OVERLAPPING, use_relocate_anon, EXPECT_SUCCESS,
+ "2MB mremap - Source 1MB-aligned, Destination 1MB-aligned");
+
+ /* Src addr PMD aligned */
+ *test_case++ = MAKE_TEST(PMD, PTE, _4MB, NON_OVERLAPPING, use_relocate_anon, EXPECT_SUCCESS,
+ "4MB mremap - Source PMD-aligned, Destination PTE-aligned");
+ *test_case++ = MAKE_TEST(PMD, _1MB, _4MB, NON_OVERLAPPING, use_relocate_anon, EXPECT_SUCCESS,
+ "4MB mremap - Source PMD-aligned, Destination 1MB-aligned");
+ *test_case++ = MAKE_TEST(PMD, PMD, _4MB, NON_OVERLAPPING, use_relocate_anon, EXPECT_SUCCESS,
+ "4MB mremap - Source PMD-aligned, Destination PMD-aligned");
+
+ /* Src addr PUD aligned */
+ *test_case++ = MAKE_TEST(PUD, PTE, _2GB, NON_OVERLAPPING, use_relocate_anon, EXPECT_SUCCESS,
+ "2GB mremap - Source PUD-aligned, Destination PTE-aligned");
+ *test_case++ = MAKE_TEST(PUD, _1MB, _2GB, NON_OVERLAPPING, use_relocate_anon, EXPECT_SUCCESS,
+ "2GB mremap - Source PUD-aligned, Destination 1MB-aligned");
+ *test_case++ = MAKE_TEST(PUD, PMD, _2GB, NON_OVERLAPPING, use_relocate_anon, EXPECT_SUCCESS,
+ "2GB mremap - Source PUD-aligned, Destination PMD-aligned");
+ *test_case++ = MAKE_TEST(PUD, PUD, _2GB, NON_OVERLAPPING, use_relocate_anon, EXPECT_SUCCESS,
+ "2GB mremap - Source PUD-aligned, Destination PUD-aligned");
+
+ /* Src and Dest addr 1MB aligned. 5MB mremap. */
+ *test_case++ = MAKE_TEST(_1MB, _1MB, _5MB, NON_OVERLAPPING, use_relocate_anon, EXPECT_SUCCESS,
+ "5MB mremap - Source 1MB-aligned, Destination 1MB-aligned");
+
+ /* Src and Dest addr 1MB aligned. 5MB mremap. */
+ *test_case = MAKE_TEST(_1MB, _1MB, _5MB, NON_OVERLAPPING, use_relocate_anon, EXPECT_SUCCESS,
+ "5MB mremap - Source 1MB-aligned, Dest 1MB-aligned with 40MB Preamble");
+ test_case++->config.dest_preamble_size = 10 * _4MB;
+
+ *perf_test_case++ = MAKE_TEST(page_size, page_size, _1GB, NON_OVERLAPPING,
+ use_relocate_anon, EXPECT_SUCCESS,
+ "1GB mremap - Source PTE-aligned, Destination PTE-aligned");
+ /*
+ * mremap 1GB region - Page table level aligned time
+ * comparison.
+ */
+ *perf_test_case++ = MAKE_TEST(PMD, PMD, _1GB, NON_OVERLAPPING, use_relocate_anon, EXPECT_SUCCESS,
+ "1GB mremap - Source PMD-aligned, Destination PMD-aligned");
+ *perf_test_case++ = MAKE_TEST(PUD, PUD, _1GB, NON_OVERLAPPING, use_relocate_anon, EXPECT_SUCCESS,
+ "1GB mremap - Source PUD-aligned, Destination PUD-aligned");
+
+ use_relocate_anon = !use_relocate_anon;
+ } while (use_relocate_anon);
run_perf_tests = (threshold_mb == VALIDATION_NO_THRESHOLD) ||
(threshold_mb * _1MB >= _1GB);
@@ -846,8 +910,18 @@ int main(int argc, char **argv)
fclose(maps_fp);
- mremap_move_within_range(pattern_seed, rand_addr);
- mremap_move_1mb_from_start(pattern_seed, rand_addr);
+ mremap_move_within_range(pattern_seed, rand_addr,
+ "", 0);
+ mremap_move_within_range(pattern_seed, rand_addr,
+ "[MREMAP_RELOCATE_ANON]", MREMAP_RELOCATE_ANON);
+ mremap_move_within_range(pattern_seed, rand_addr,
+ "[MREMAP_MUST_RELOCATE_ANON]", MREMAP_MUST_RELOCATE_ANON);
+ mremap_move_1mb_from_start(pattern_seed, rand_addr,
+ "", 0);
+ mremap_move_1mb_from_start(pattern_seed, rand_addr,
+ "[MREMAP_RELOCATE_ANON]", MREMAP_RELOCATE_ANON);
+ mremap_move_1mb_from_start(pattern_seed, rand_addr,
+ "[MREMAP_MUST_RELOCATE_ANON]", MREMAP_MUST_RELOCATE_ANON);
if (run_perf_tests) {
ksft_print_msg("\n%s\n",
--
2.49.0
next prev parent reply other threads:[~2025-06-09 13:27 UTC|newest]
Thread overview: 41+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-06-09 13:26 [PATCH 00/11] mm/mremap: introduce more mergeable mremap via MREMAP_RELOCATE_ANON Lorenzo Stoakes
2025-06-09 13:26 ` [PATCH 01/11] " Lorenzo Stoakes
2025-06-16 20:58 ` David Hildenbrand
2025-06-17 6:37 ` Harry Yoo
2025-06-17 9:52 ` Lorenzo Stoakes
2025-06-17 10:01 ` David Hildenbrand
2025-06-17 10:07 ` Lorenzo Stoakes
2025-06-17 12:07 ` David Hildenbrand
2025-06-17 11:15 ` Harry Yoo
2025-06-17 11:24 ` Lorenzo Stoakes
2025-06-17 11:49 ` David Hildenbrand
2025-06-17 20:09 ` Lorenzo Stoakes
2025-06-09 13:26 ` [PATCH 02/11] mm/mremap: add MREMAP_MUST_RELOCATE_ANON Lorenzo Stoakes
2025-06-09 13:26 ` [PATCH 03/11] mm/mremap: add MREMAP[_MUST]_RELOCATE_ANON support for large folios Lorenzo Stoakes
2025-06-09 13:26 ` [PATCH 04/11] tools UAPI: Update copy of linux/mman.h from the kernel sources Lorenzo Stoakes
2025-06-09 13:26 ` [PATCH 05/11] tools/testing/selftests: add sys_mremap() helper to vm_util.h Lorenzo Stoakes
2025-06-09 13:26 ` [PATCH 06/11] tools/testing/selftests: add mremap() cases that merge normally Lorenzo Stoakes
2025-06-09 13:26 ` [PATCH 07/11] tools/testing/selftests: add MREMAP_RELOCATE_ANON merge test cases Lorenzo Stoakes
2025-06-09 13:26 ` Lorenzo Stoakes [this message]
2025-06-09 13:26 ` [PATCH 09/11] tools/testing/selftests: have CoW self test use MREMAP_RELOCATE_ANON Lorenzo Stoakes
2025-06-09 13:26 ` [PATCH 10/11] tools/testing/selftests: test relocate anon in split huge page test Lorenzo Stoakes
2025-06-09 13:26 ` [PATCH 11/11] tools/testing/selftests: add MREMAP_RELOCATE_ANON fork tests Lorenzo Stoakes
2025-06-16 20:24 ` [PATCH 00/11] mm/mremap: introduce more mergeable mremap via MREMAP_RELOCATE_ANON David Hildenbrand
2025-06-16 20:41 ` David Hildenbrand
2025-06-17 8:34 ` Pedro Falcato
2025-06-17 8:45 ` David Hildenbrand
2025-06-17 10:57 ` Lorenzo Stoakes
2025-06-17 11:58 ` David Hildenbrand
2025-06-17 12:47 ` Lorenzo Stoakes
2025-06-20 18:59 ` Pedro Falcato
2025-06-20 19:28 ` Lorenzo Stoakes
2025-06-24 9:38 ` David Hildenbrand
2025-06-24 10:19 ` Lorenzo Stoakes
2025-06-24 12:05 ` David Hildenbrand
2025-06-17 10:20 ` Lorenzo Stoakes
2025-06-17 10:50 ` Lorenzo Stoakes
2025-06-17 5:42 ` Lai, Yi
2025-06-17 6:45 ` Harry Yoo
2025-06-17 9:33 ` Lorenzo Stoakes
2025-06-25 15:44 ` Lorenzo Stoakes
2025-06-25 15:58 ` Andrew Morton
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=25ed4f20f8874db9a496539aa9793013d22de06d.1749473726.git.lorenzo.stoakes@oracle.com \
--to=lorenzo.stoakes@oracle.com \
--cc=Liam.Howlett@oracle.com \
--cc=akpm@linux-foundation.org \
--cc=baohua@kernel.org \
--cc=baolin.wang@linux.alibaba.com \
--cc=david@redhat.com \
--cc=dev.jain@arm.com \
--cc=harry.yoo@oracle.com \
--cc=jannh@google.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=matenajakub@gmail.com \
--cc=npache@redhat.com \
--cc=pfalcato@suse.de \
--cc=richard.weiyang@gmail.com \
--cc=riel@surriel.com \
--cc=ryan.roberts@arm.com \
--cc=surenb@google.com \
--cc=vbabka@suse.cz \
--cc=willy@infradead.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