Lines Matching +full:total +full:- +full:timeout
1 // SPDX-License-Identifier: GPL-2.0
100 printf("usage: ksm_tests [-h] <test type> [-a prot] [-p page_count] [-l timeout]\n" in print_help()
101 "[-z use_zero_pages] [-m merge_across_nodes] [-s size]\n"); in print_help()
104 " -M (page merging)\n" in print_help()
105 " -Z (zero pages merging)\n" in print_help()
106 " -N (merging of pages in different NUMA nodes)\n" in print_help()
107 " -U (page unmerging)\n" in print_help()
108 " -P evaluate merging time and speed.\n" in print_help()
110 " must be provided using -s option\n" in print_help()
111 " -H evaluate merging time and speed of area allocated mostly with huge pages\n" in print_help()
113 " must be provided using -s option\n" in print_help()
114 " -C evaluate the time required to break COW of merged pages.\n\n"); in print_help()
116 printf(" -a: specify the access protections of pages.\n" in print_help()
119 printf(" -p: specify the number of pages to test.\n" in print_help()
121 printf(" -l: limit the maximum running time (in seconds) for a test.\n" in print_help()
123 printf(" -z: change use_zero_pages tunable\n" in print_help()
125 printf(" -m: change merge_across_nodes tunable\n" in print_help()
127 printf(" -s: the size of duplicated memory area (in MiB)\n"); in print_help()
134 void *map_ptr = mmap(ptr, map_size, PROT_WRITE, mapping, -1, 0); in allocate_memory()
150 static int ksm_do_scan(int scan_count, struct timespec start_time, int timeout) in ksm_do_scan() argument
166 if ((cur_time.tv_sec - start_time.tv_sec) > timeout) { in ksm_do_scan()
175 static int ksm_merge_pages(void *addr, size_t size, struct timespec start_time, int timeout) in ksm_merge_pages() argument
185 if (ksm_do_scan(2, start_time, timeout)) in ksm_merge_pages()
208 * and dupl_page_count - 1. in assert_ksm_pages_count()
212 pages_sharing == pages_shared * (max_page_sharing - 1)) in assert_ksm_pages_count()
216 pages_sharing == dupl_page_count - pages_shared) in assert_ksm_pages_count()
225 if (ksm_read_sysfs(KSM_FP("max_page_sharing"), &ksm_sysfs->max_page_sharing) || in ksm_save_def()
227 ksm_read_sysfs(KSM_FP("merge_across_nodes"), &ksm_sysfs->merge_across_nodes) || in ksm_save_def()
228 ksm_read_sysfs(KSM_FP("sleep_millisecs"), &ksm_sysfs->sleep_millisecs) || in ksm_save_def()
229 ksm_read_sysfs(KSM_FP("pages_to_scan"), &ksm_sysfs->pages_to_scan) || in ksm_save_def()
230 ksm_read_sysfs(KSM_FP("run"), &ksm_sysfs->run) || in ksm_save_def()
232 &ksm_sysfs->stable_node_chains_prune_millisecs) || in ksm_save_def()
233 ksm_read_sysfs(KSM_FP("use_zero_pages"), &ksm_sysfs->use_zero_pages)) in ksm_save_def()
241 if (ksm_write_sysfs(KSM_FP("max_page_sharing"), ksm_sysfs->max_page_sharing) || in ksm_restore()
243 ksm_write_sysfs(KSM_FP("merge_across_nodes"), ksm_sysfs->merge_across_nodes) || in ksm_restore()
244 ksm_write_sysfs(KSM_FP("pages_to_scan"), ksm_sysfs->pages_to_scan) || in ksm_restore()
245 ksm_write_sysfs(KSM_FP("run"), ksm_sysfs->run) || in ksm_restore()
246 ksm_write_sysfs(KSM_FP("sleep_millisecs"), ksm_sysfs->sleep_millisecs) || in ksm_restore()
248 ksm_sysfs->stable_node_chains_prune_millisecs) || in ksm_restore()
249 ksm_write_sysfs(KSM_FP("use_zero_pages"), ksm_sysfs->use_zero_pages)) in ksm_restore()
255 static int check_ksm_merge(int mapping, int prot, long page_count, int timeout, size_t page_size) in check_ksm_merge() argument
270 if (ksm_merge_pages(map_ptr, page_size * page_count, start_time, timeout)) in check_ksm_merge()
286 static int check_ksm_unmerge(int mapping, int prot, int timeout, size_t page_size) in check_ksm_unmerge() argument
302 if (ksm_merge_pages(map_ptr, page_size * page_count, start_time, timeout)) in check_ksm_unmerge()
305 /* change 1 byte in each of the 2 pages -- KSM must automatically unmerge them */ in check_ksm_unmerge()
306 memset(map_ptr, '-', 1); in check_ksm_unmerge()
310 if (ksm_do_scan(1, start_time, timeout)) in check_ksm_unmerge()
326 static int check_ksm_zero_page_merge(int mapping, int prot, long page_count, int timeout, in check_ksm_zero_page_merge() argument
345 if (ksm_merge_pages(map_ptr, page_size * page_count, start_time, timeout)) in check_ksm_zero_page_merge()
391 static int check_ksm_numa_merge(int mapping, int prot, int timeout, bool merge_across_nodes, in check_ksm_numa_merge() argument
428 if (ksm_merge_pages(numa1_map_ptr, page_size, start_time, timeout) || in check_ksm_numa_merge()
429 ksm_merge_pages(numa2_map_ptr, page_size, start_time, timeout)) in check_ksm_numa_merge()
455 static int ksm_merge_hugepages_time(int mapping, int prot, int timeout, size_t map_size) in ksm_merge_hugepages_time() argument
465 len -= len % HPAGE_SIZE; in ksm_merge_hugepages_time()
467 MAP_ANONYMOUS | MAP_NORESERVE | MAP_PRIVATE, -1, 0); in ksm_merge_hugepages_time()
468 map_ptr = map_ptr_orig + HPAGE_SIZE - (uintptr_t)map_ptr_orig % HPAGE_SIZE; in ksm_merge_hugepages_time()
497 if (ksm_merge_pages(map_ptr, map_size, start_time, timeout)) in ksm_merge_hugepages_time()
504 scan_time_ns = (end_time.tv_sec - start_time.tv_sec) * NSEC_PER_SEC + in ksm_merge_hugepages_time()
505 (end_time.tv_nsec - start_time.tv_nsec); in ksm_merge_hugepages_time()
507 printf("Total size: %lu MiB\n", map_size / MB); in ksm_merge_hugepages_time()
508 printf("Total time: %ld.%09ld s\n", scan_time_ns / NSEC_PER_SEC, in ksm_merge_hugepages_time()
522 static int ksm_merge_time(int mapping, int prot, int timeout, size_t map_size) in ksm_merge_time() argument
538 if (ksm_merge_pages(map_ptr, map_size, start_time, timeout)) in ksm_merge_time()
545 scan_time_ns = (end_time.tv_sec - start_time.tv_sec) * NSEC_PER_SEC + in ksm_merge_time()
546 (end_time.tv_nsec - start_time.tv_nsec); in ksm_merge_time()
548 printf("Total size: %lu MiB\n", map_size / MB); in ksm_merge_time()
549 printf("Total time: %ld.%09ld s\n", scan_time_ns / NSEC_PER_SEC, in ksm_merge_time()
563 static int ksm_cow_time(int mapping, int prot, int timeout, size_t page_size) in ksm_cow_time() argument
580 for (size_t i = 0; i < page_count - 1; i = i + 2) in ksm_cow_time()
581 memset(map_ptr + page_size * i, '-', 1); in ksm_cow_time()
587 cow_time_ns = (end_time.tv_sec - start_time.tv_sec) * NSEC_PER_SEC + in ksm_cow_time()
588 (end_time.tv_nsec - start_time.tv_nsec); in ksm_cow_time()
590 printf("Total size: %lu MiB\n\n", (page_size * page_count) / MB); in ksm_cow_time()
592 printf("Total time: %ld.%09ld s\n", cow_time_ns / NSEC_PER_SEC, in ksm_cow_time()
598 for (size_t i = 0; i < page_count - 1; i = i + 2) { in ksm_cow_time()
602 if (ksm_merge_pages(map_ptr, page_size * page_count, start_time, timeout)) in ksm_cow_time()
609 for (size_t i = 0; i < page_count - 1; i = i + 2) in ksm_cow_time()
610 memset(map_ptr + page_size * i, '-', 1); in ksm_cow_time()
616 cow_time_ns = (end_time.tv_sec - start_time.tv_sec) * NSEC_PER_SEC + in ksm_cow_time()
617 (end_time.tv_nsec - start_time.tv_nsec); in ksm_cow_time()
620 printf("Total time: %ld.%09ld s\n", cow_time_ns / NSEC_PER_SEC, in ksm_cow_time()
647 while ((opt = getopt(argc, argv, "ha:p:l:z:m:s:MUZNPCH")) != -1) { in main()
662 printf("Timeout value must be greater than 0\n"); in main()
751 printf("Option '-s' is required.\n"); in main()
759 printf("Option '-s' is required.\n"); in main()