Lines Matching +full:s +full:- +full:merged
1 // SPDX-License-Identifier: GPL-2.0
20 #define KSM_FP(s) (KSM_SYSFS_PATH s) argument
64 fprintf(stderr, "f %s\n", file_path); in ksm_write_sysfs()
83 fprintf(stderr, "f %s\n", file_path); in ksm_read_sysfs()
133 fprintf(stderr, "f %s\n", file_name); in ksm_print_procfs()
139 printf("%s", buffer); in ksm_print_procfs()
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()
181 " Default: %s\n", KSM_PROT_STR_DEFAULT); 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()
234 if ((cur_time.tv_sec - start_time.tv_sec) > timeout) { in ksm_do_scan()
295 * there are 'leftover' pages that cannot be merged. For example, if there in assert_ksm_pages_count()
297 * merged and the 11th page won't be affected. As a result, when the number in assert_ksm_pages_count()
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()
366 /* verify that the right number of pages are merged */ in check_ksm_merge()
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()
408 /* check that unmerging was successful and 0 pages are currently merged */ in check_ksm_unmerge()
444 * verify that the right number of pages are merged: in check_ksm_zero_page_merge()
445 * 1) if use_zero_pages is set to 1, empty pages are merged in check_ksm_zero_page_merge()
448 * and merged as usual. in check_ksm_zero_page_merge()
528 * verify that the right number of pages are merged: in check_ksm_numa_merge()
529 * 1) if merge_across_nodes was enabled, 2 duplicate pages will be merged; in check_ksm_numa_merge()
530 * 2) if merge_across_nodes = 0, there must be 0 merged pages, since there is in check_ksm_numa_merge()
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()
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()
604 printf("Total time: %ld.%09ld s\n", scan_time_ns / NSEC_PER_SEC, in ksm_merge_hugepages_time()
606 printf("Average speed: %.3f MiB/s\n", (map_size / MB) / in ksm_merge_hugepages_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()
645 printf("Total time: %ld.%09ld s\n", scan_time_ns / NSEC_PER_SEC, in ksm_merge_time()
647 printf("Average speed: %.3f MiB/s\n", (map_size / MB) / in ksm_merge_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()
692 printf("Total time: %ld.%09ld s\n", scan_time_ns / NSEC_PER_SEC, in ksm_unmerge_time()
694 printf("Average speed: %.3f MiB/s\n", (map_size / MB) / in ksm_unmerge_time()
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()
734 printf("Not merged pages:\n"); in ksm_cow_time()
735 printf("Total time: %ld.%09ld s\n", cow_time_ns / NSEC_PER_SEC, in ksm_cow_time()
737 printf("Average speed: %.3f MiB/s\n\n", ((page_size * (page_count / 2)) / MB) / in ksm_cow_time()
741 for (size_t i = 0; i < page_count - 1; i = i + 2) { 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()
762 printf("Merged pages:\n"); in ksm_cow_time()
763 printf("Total time: %ld.%09ld s\n", cow_time_ns / NSEC_PER_SEC, in ksm_cow_time()
765 printf("Average speed: %.3f MiB/s\n", ((page_size * (page_count / 2)) / MB) / in ksm_cow_time()
791 while ((opt = getopt(argc, argv, "dha:p:l:z:m:s:t:MUZNPCHD")) != -1) { in main()
828 case 's': 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()