Lines Matching +full:total +full:- +full:timeout

1 // SPDX-License-Identifier: GPL-2.0
160 printf("usage: ksm_tests [-h] <test type> [-a prot] [-p page_count] [-l timeout]\n" in print_help()
161 "[-z use_zero_pages] [-m merge_across_nodes] [-s size]\n"); in print_help()
164 " -M (page merging)\n" in print_help()
165 " -Z (zero pages merging)\n" in print_help()
166 " -N (merging of pages in different NUMA nodes)\n" in print_help()
167 " -U (page unmerging)\n" in print_help()
168 " -P evaluate merging time and speed.\n" in print_help()
170 " must be provided using -s option\n" in print_help()
171 " -H evaluate merging time and speed of area allocated mostly with huge pages\n" in print_help()
173 " must be provided using -s option\n" in print_help()
174 " -D evaluate unmerging time and speed when disabling KSM.\n" in print_help()
176 " must be provided using -s option\n" in print_help()
177 " -C evaluate the time required to break COW of merged pages.\n\n"); in print_help()
179 printf(" -a: specify the access protections of pages.\n" in print_help()
182 printf(" -p: specify the number of pages to test.\n" in print_help()
184 printf(" -l: limit the maximum running time (in seconds) for a test.\n" in print_help()
186 printf(" -z: change use_zero_pages tunable\n" in print_help()
188 printf(" -m: change merge_across_nodes tunable\n" in print_help()
190 printf(" -d: turn debugging output on\n"); in print_help()
191 printf(" -s: the size of duplicated memory area (in MiB)\n"); in print_help()
192 printf(" -t: KSM merge type\n" in print_help()
202 void *map_ptr = mmap(ptr, map_size, PROT_WRITE, mapping, -1, 0); in allocate_memory()
218 static int ksm_do_scan(int scan_count, struct timespec start_time, int timeout) in ksm_do_scan() argument
234 if ((cur_time.tv_sec - start_time.tv_sec) > timeout) { in ksm_do_scan()
244 struct timespec start_time, int timeout) in ksm_merge_pages() argument
262 if (ksm_do_scan(2, start_time, timeout)) in ksm_merge_pages()
269 struct timespec start_time, int timeout) in ksm_unmerge_pages() argument
300 * and dupl_page_count - 1. in assert_ksm_pages_count()
304 pages_sharing == pages_shared * (max_page_sharing - 1)) in assert_ksm_pages_count()
308 pages_sharing == dupl_page_count - pages_shared) in assert_ksm_pages_count()
317 if (ksm_read_sysfs(KSM_FP("max_page_sharing"), &ksm_sysfs->max_page_sharing) || in ksm_save_def()
319 ksm_read_sysfs(KSM_FP("merge_across_nodes"), &ksm_sysfs->merge_across_nodes) || in ksm_save_def()
320 ksm_read_sysfs(KSM_FP("sleep_millisecs"), &ksm_sysfs->sleep_millisecs) || in ksm_save_def()
321 ksm_read_sysfs(KSM_FP("pages_to_scan"), &ksm_sysfs->pages_to_scan) || in ksm_save_def()
322 ksm_read_sysfs(KSM_FP("run"), &ksm_sysfs->run) || in ksm_save_def()
324 &ksm_sysfs->stable_node_chains_prune_millisecs) || in ksm_save_def()
325 ksm_read_sysfs(KSM_FP("use_zero_pages"), &ksm_sysfs->use_zero_pages)) in ksm_save_def()
333 if (ksm_write_sysfs(KSM_FP("max_page_sharing"), ksm_sysfs->max_page_sharing) || in ksm_restore()
335 ksm_write_sysfs(KSM_FP("merge_across_nodes"), ksm_sysfs->merge_across_nodes) || in ksm_restore()
336 ksm_write_sysfs(KSM_FP("pages_to_scan"), ksm_sysfs->pages_to_scan) || in ksm_restore()
337 ksm_write_sysfs(KSM_FP("run"), ksm_sysfs->run) || in ksm_restore()
338 ksm_write_sysfs(KSM_FP("sleep_millisecs"), ksm_sysfs->sleep_millisecs) || in ksm_restore()
340 ksm_sysfs->stable_node_chains_prune_millisecs) || in ksm_restore()
341 ksm_write_sysfs(KSM_FP("use_zero_pages"), ksm_sysfs->use_zero_pages)) in ksm_restore()
348 long page_count, int timeout, size_t page_size) in check_ksm_merge() argument
363 if (ksm_merge_pages(merge_type, map_ptr, page_size * page_count, start_time, timeout)) in check_ksm_merge()
381 static int check_ksm_unmerge(int merge_type, int mapping, int prot, int timeout, size_t page_size) in check_ksm_unmerge() argument
397 if (ksm_merge_pages(merge_type, map_ptr, page_size * page_count, start_time, timeout)) in check_ksm_unmerge()
400 /* change 1 byte in each of the 2 pages -- KSM must automatically unmerge them */ in check_ksm_unmerge()
401 memset(map_ptr, '-', 1); in check_ksm_unmerge()
405 if (ksm_do_scan(1, start_time, timeout)) in check_ksm_unmerge()
422 int timeout, bool use_zero_pages, size_t page_size) in check_ksm_zero_page_merge() argument
440 if (ksm_merge_pages(merge_type, map_ptr, page_size * page_count, start_time, timeout)) in check_ksm_zero_page_merge()
486 static int check_ksm_numa_merge(int merge_type, int mapping, int prot, int timeout, in check_ksm_numa_merge() argument
523 if (ksm_merge_pages(merge_type, numa1_map_ptr, page_size, start_time, timeout) || in check_ksm_numa_merge()
524 ksm_merge_pages(merge_type, numa2_map_ptr, page_size, start_time, timeout)) in check_ksm_numa_merge()
551 int timeout, size_t map_size) in ksm_merge_hugepages_time() argument
561 len -= len % HPAGE_SIZE; in ksm_merge_hugepages_time()
563 MAP_ANONYMOUS | MAP_NORESERVE | MAP_PRIVATE, -1, 0); in ksm_merge_hugepages_time()
564 map_ptr = map_ptr_orig + HPAGE_SIZE - (uintptr_t)map_ptr_orig % HPAGE_SIZE; in ksm_merge_hugepages_time()
593 if (ksm_merge_pages(merge_type, map_ptr, map_size, start_time, timeout)) in ksm_merge_hugepages_time()
600 scan_time_ns = (end_time.tv_sec - start_time.tv_sec) * NSEC_PER_SEC + in ksm_merge_hugepages_time()
601 (end_time.tv_nsec - start_time.tv_nsec); in ksm_merge_hugepages_time()
603 printf("Total size: %lu MiB\n", map_size / MB); in ksm_merge_hugepages_time()
604 printf("Total time: %ld.%09ld s\n", scan_time_ns / NSEC_PER_SEC, in ksm_merge_hugepages_time()
618 static int ksm_merge_time(int merge_type, int mapping, int prot, int timeout, size_t map_size) in ksm_merge_time() argument
634 if (ksm_merge_pages(merge_type, map_ptr, map_size, start_time, timeout)) in ksm_merge_time()
641 scan_time_ns = (end_time.tv_sec - start_time.tv_sec) * NSEC_PER_SEC + in ksm_merge_time()
642 (end_time.tv_nsec - start_time.tv_nsec); in ksm_merge_time()
644 printf("Total size: %lu MiB\n", map_size / MB); in ksm_merge_time()
645 printf("Total time: %ld.%09ld s\n", scan_time_ns / NSEC_PER_SEC, in ksm_merge_time()
659 static int ksm_unmerge_time(int merge_type, int mapping, int prot, int timeout, size_t map_size) in ksm_unmerge_time() argument
674 if (ksm_merge_pages(merge_type, map_ptr, map_size, start_time, timeout)) in ksm_unmerge_time()
681 if (ksm_unmerge_pages(map_ptr, map_size, start_time, timeout)) in ksm_unmerge_time()
688 scan_time_ns = (end_time.tv_sec - start_time.tv_sec) * NSEC_PER_SEC + in ksm_unmerge_time()
689 (end_time.tv_nsec - start_time.tv_nsec); in ksm_unmerge_time()
691 printf("Total size: %lu MiB\n", map_size / MB); in ksm_unmerge_time()
692 printf("Total time: %ld.%09ld s\n", scan_time_ns / NSEC_PER_SEC, in ksm_unmerge_time()
706 static int ksm_cow_time(int merge_type, int mapping, int prot, int timeout, size_t page_size) in ksm_cow_time() argument
723 for (size_t i = 0; i < page_count - 1; i = i + 2) in ksm_cow_time()
724 memset(map_ptr + page_size * i, '-', 1); in ksm_cow_time()
730 cow_time_ns = (end_time.tv_sec - start_time.tv_sec) * NSEC_PER_SEC + in ksm_cow_time()
731 (end_time.tv_nsec - start_time.tv_nsec); in ksm_cow_time()
733 printf("Total size: %lu MiB\n\n", (page_size * page_count) / MB); in ksm_cow_time()
735 printf("Total time: %ld.%09ld s\n", cow_time_ns / NSEC_PER_SEC, in ksm_cow_time()
741 for (size_t i = 0; i < page_count - 1; i = i + 2) { in ksm_cow_time()
745 if (ksm_merge_pages(merge_type, map_ptr, page_size * page_count, start_time, timeout)) in ksm_cow_time()
752 for (size_t i = 0; i < page_count - 1; i = i + 2) in ksm_cow_time()
753 memset(map_ptr + page_size * i, '-', 1); in ksm_cow_time()
759 cow_time_ns = (end_time.tv_sec - start_time.tv_sec) * NSEC_PER_SEC + in ksm_cow_time()
760 (end_time.tv_nsec - start_time.tv_nsec); in ksm_cow_time()
763 printf("Total time: %ld.%09ld s\n", cow_time_ns / NSEC_PER_SEC, in ksm_cow_time()
791 while ((opt = getopt(argc, argv, "dha:p:l:z:m:s:t:MUZNPCHD")) != -1) { in main()
806 printf("Timeout value must be greater than 0\n"); in main()
914 printf("Option '-s' is required.\n"); in main()
922 printf("Option '-s' is required.\n"); in main()
930 printf("Option '-s' is required.\n"); in main()