mremap_test contains three perf tests that report the time taken to move 1GB mappings with different page table level alignments. Although they validate the remapped data, their main purpose it to report timing information. The recorded time also does not affect the test result. Also, they are skipped with the default validation threshold. Remove these tests and the timing infrastructure from mremap_test.c. The regular tests continue to cover PUD and PMD aligned remaps. Suggested-by: David Hildenbrand (Arm) Signed-off-by: Sarthak Sharma --- tools/testing/selftests/mm/mremap_test.c | 61 +++--------------------- 1 file changed, 7 insertions(+), 54 deletions(-) diff --git a/tools/testing/selftests/mm/mremap_test.c b/tools/testing/selftests/mm/mremap_test.c index 7b4c9ab3bf14..04ea072f8cd1 100644 --- a/tools/testing/selftests/mm/mremap_test.c +++ b/tools/testing/selftests/mm/mremap_test.c @@ -13,7 +13,6 @@ #include #include #include -#include #include #include @@ -23,7 +22,6 @@ #define EXPECT_FAILURE 1 #define NON_OVERLAPPING 0 #define OVERLAPPING 1 -#define NS_PER_SEC 1000000000ULL #define VALIDATION_DEFAULT_THRESHOLD 4 /* 4MB */ #define VALIDATION_NO_THRESHOLD 0 /* Verify the entire region */ @@ -897,12 +895,11 @@ static void mremap_move_multi_invalid_vmas(FILE *maps_fp, unsigned long page_siz } #endif /* __NR_userfaultfd */ -/* Returns the time taken for the remap on success else returns -1. */ -static long long remap_region(struct config c, unsigned int threshold_mb) +static int remap_region(struct config c, unsigned int threshold_mb) { void *addr, *tmp_addr, *src_addr, *dest_addr, *dest_preamble_addr = NULL; - struct timespec t_start = {0, 0}, t_end = {0, 0}; - long long start_ns, end_ns, align_mask, ret, offset; + long long align_mask, offset; + int ret = 0; unsigned long long threshold; char *preamble_pattern; @@ -963,10 +960,8 @@ static long long remap_region(struct config c, unsigned int threshold_mb) memcpy(dest_preamble_addr, preamble_pattern, c.dest_preamble_size); } - clock_gettime(CLOCK_MONOTONIC, &t_start); dest_addr = mremap(src_addr, c.region_size, c.region_size, MREMAP_MAYMOVE|MREMAP_FIXED, (char *) addr); - clock_gettime(CLOCK_MONOTONIC, &t_end); if (dest_addr == MAP_FAILED) { ksft_print_msg("mremap failed: %s\n", strerror(errno)); @@ -989,16 +984,7 @@ static long long remap_region(struct config c, unsigned int threshold_mb) goto clean_up_dest; } - start_ns = t_start.tv_sec * NS_PER_SEC + t_start.tv_nsec; - end_ns = t_end.tv_sec * NS_PER_SEC + t_end.tv_nsec; - ret = end_ns - start_ns; - -/* - * Since the destination address is specified using MREMAP_FIXED, subsequent - * mremap will unmap any previous mapping at the address range specified by - * dest_addr and region_size. This significantly affects the remap time of - * subsequent tests. So we clean up mappings after each test. - */ +/* Clean up mappings after each test. */ clean_up_dest: munmap(dest_addr, c.region_size); clean_up_dest_preamble: @@ -1076,9 +1062,9 @@ static void mremap_move_1mb_from_start(void) static void run_mremap_test_case(struct test test_case, unsigned int threshold_mb) { - long long remap_time = remap_region(test_case.config, threshold_mb); + int ret = remap_region(test_case.config, threshold_mb); - if (remap_time < 0) { + if (ret < 0) { if (test_case.expect_failure) ksft_test_result_xfail("%s: expected mremap failure\n", test_case.name); @@ -1088,14 +1074,6 @@ static void run_mremap_test_case(struct test test_case, if (test_case.expect_failure) ksft_test_result_fail("%s: unexpected mremap success\n", test_case.name); - /* - * Comparing mremap time is only applicable if entire region - * was faulted in. - */ - else if (threshold_mb == VALIDATION_NO_THRESHOLD || - test_case.config.region_size <= threshold_mb * _1MB) - ksft_test_result_pass("%s: mremap time: %12lldns\n", - test_case.name, remap_time); else ksft_test_result_pass("%s\n", test_case.name); } @@ -1149,11 +1127,9 @@ static void fill_pattern(uint32_t *pattern, size_t pattern_size, size_t page_siz } #define MAX_TEST 15 -#define MAX_PERF_TEST 3 int main(int argc, char **argv) { unsigned int i; - int run_perf_tests; unsigned int threshold_mb = VALIDATION_DEFAULT_THRESHOLD; /* hard-coded test configs */ @@ -1164,7 +1140,6 @@ int main(int argc, char **argv) int num_expand_tests = 2; int num_misc_tests = 9; struct test test_cases[MAX_TEST] = {}; - struct test perf_test_cases[MAX_PERF_TEST]; int page_size; FILE *maps_fp; @@ -1251,22 +1226,7 @@ int main(int argc, char **argv) "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"); - - run_perf_tests = (threshold_mb == VALIDATION_NO_THRESHOLD) || - (threshold_mb * _1MB >= _1GB); - - ksft_set_plan(ARRAY_SIZE(test_cases) + (run_perf_tests ? - ARRAY_SIZE(perf_test_cases) : 0) + num_expand_tests + num_misc_tests); + ksft_set_plan(ARRAY_SIZE(test_cases) + num_expand_tests + num_misc_tests); for (i = 0; i < ARRAY_SIZE(test_cases); i++) run_mremap_test_case(test_cases[i], threshold_mb); @@ -1293,13 +1253,6 @@ int main(int argc, char **argv) fclose(maps_fp); - if (run_perf_tests) { - ksft_print_msg("%s\n", - "mremap HAVE_MOVE_PMD/PUD optimization time comparison for 1GB region:"); - for (i = 0; i < ARRAY_SIZE(perf_test_cases); i++) - run_mremap_test_case(perf_test_cases[i], threshold_mb); - } - munmap(pattern, pattern_size); ksft_finished(); -- 2.53.0