Lines Matching refs:mem

163 	char *mem;  in gethugetlb_mem()  local
170 mem = shmat(*shmid, 0, 0); in gethugetlb_mem()
171 if (mem == (char *)-1) { in gethugetlb_mem()
176 mem = mmap(NULL, size, PROT_READ | PROT_WRITE, in gethugetlb_mem()
178 if (mem == MAP_FAILED) in gethugetlb_mem()
182 return mem; in gethugetlb_mem()
188 char *mem, *vec; in userfaultfd_tests() local
191 mem = mmap(NULL, mem_size, PROT_NONE, MAP_PRIVATE | MAP_ANON, -1, 0); in userfaultfd_tests()
192 if (mem == MAP_FAILED) in userfaultfd_tests()
195 wp_init(mem, mem_size); in userfaultfd_tests()
198 mprotect(mem, mem_size/8, PROT_READ|PROT_WRITE); in userfaultfd_tests()
199 mprotect(mem + 1 * mem_size/8, mem_size/8, PROT_READ); in userfaultfd_tests()
200 mprotect(mem + 2 * mem_size/8, mem_size/8, PROT_READ|PROT_WRITE); in userfaultfd_tests()
201 mprotect(mem + 3 * mem_size/8, mem_size/8, PROT_READ); in userfaultfd_tests()
202 mprotect(mem + 4 * mem_size/8, mem_size/8, PROT_READ|PROT_WRITE); in userfaultfd_tests()
203 mprotect(mem + 5 * mem_size/8, mem_size/8, PROT_NONE); in userfaultfd_tests()
204 mprotect(mem + 6 * mem_size/8, mem_size/8, PROT_READ|PROT_WRITE); in userfaultfd_tests()
205 mprotect(mem + 7 * mem_size/8, mem_size/8, PROT_READ); in userfaultfd_tests()
207 wp_addr_range(mem + (mem_size/16), mem_size - 2 * (mem_size/8)); in userfaultfd_tests()
208 wp_addr_range(mem, mem_size); in userfaultfd_tests()
213 written = pagemap_ioctl(mem, mem_size, vec, 1, PM_SCAN_WP_MATCHING | PM_SCAN_CHECK_WPASYNC, in userfaultfd_tests()
220 wp_free(mem, mem_size); in userfaultfd_tests()
221 munmap(mem, mem_size); in userfaultfd_tests()
241 char *mem, *m[2]; in sanity_tests_sd() local
255 mem = mmap(NULL, mem_size, PROT_READ | PROT_WRITE, MAP_PRIVATE | MAP_ANON, -1, 0); in sanity_tests_sd()
256 if (mem == MAP_FAILED) in sanity_tests_sd()
259 wp_init(mem, mem_size); in sanity_tests_sd()
260 wp_addr_range(mem, mem_size); in sanity_tests_sd()
263 ksft_test_result(pagemap_ioctl(mem, 0, vec, vec_size, 0, in sanity_tests_sd()
267 ksft_test_result(pagemap_ioctl(mem, mem_size, NULL, vec_size, 0, in sanity_tests_sd()
271 ksft_test_result(pagemap_ioctl(mem, mem_size, vec, 0, 0, in sanity_tests_sd()
275 ksft_test_result(pagemap_ioctl(mem, mem_size, 0, 0, 0, in sanity_tests_sd()
279 ksft_test_result(pagemap_ioctl(mem, mem_size, vec, vec_size, -1, in sanity_tests_sd()
283 ksft_test_result(pagemap_ioctl(mem, mem_size, vec, vec_size, in sanity_tests_sd()
288 ksft_test_result(pagemap_ioctl(mem, mem_size, vec, vec_size, 0, in sanity_tests_sd()
292 ksft_test_result(pagemap_ioctl(mem, mem_size, vec, vec_size, 0, in sanity_tests_sd()
296 ksft_test_result(pagemap_ioctl(mem, mem_size, vec, vec_size, 0, in sanity_tests_sd()
300 ksft_test_result(pagemap_ioctl(mem, mem_size, vec, vec_size, in sanity_tests_sd()
305 ksft_test_result(pagemap_ioctl(mem, mem_size, vec, vec_size, in sanity_tests_sd()
312 ret = pagemap_ioctl(mem, mem_size, vec, vec_size, in sanity_tests_sd()
319 mem[i]++; in sanity_tests_sd()
321 ret = pagemap_ioctl(mem, mem_size, vec, vec_size, 0, 0, PAGE_IS_WRITTEN, 0, in sanity_tests_sd()
330 ret = pagemap_ioctl(mem, mem_size, vec, vec_size, in sanity_tests_sd()
336 ret2 = pagemap_ioctl(mem, mem_size, vec, 2, 0, 0, PAGE_IS_WRITTEN, 0, 0, in sanity_tests_sd()
341 ret3 = pagemap_ioctl(mem, mem_size, vec, vec_size, in sanity_tests_sd()
353 mem[i]++; in sanity_tests_sd()
354 mem[(mem_size/page_size - 1) * page_size]++; in sanity_tests_sd()
356 ret = pagemap_ioctl(mem, mem_size, vec, vec_size, in sanity_tests_sd()
362 ret2 = pagemap_ioctl(mem, mem_size, vec, vec_size, in sanity_tests_sd()
374 memset(mem, -1, mem_size); in sanity_tests_sd()
377 ret = pagemap_ioctl(mem + page_size, 2 * page_size, vec, 1, in sanity_tests_sd()
383 ret2 = pagemap_ioctl(mem, mem_size, vec2, vec_size, 0, 0, in sanity_tests_sd()
389 vec[0].start == (uintptr_t)(mem + page_size) && in sanity_tests_sd()
390 ret2 == 2 && LEN(vec2[0]) == 1 && vec2[0].start == (uintptr_t)mem && in sanity_tests_sd()
392 vec2[1].start == (uintptr_t)(mem + 3 * page_size), in sanity_tests_sd()
395 wp_free(mem, mem_size); in sanity_tests_sd()
396 munmap(mem, mem_size); in sanity_tests_sd()
440 mem = mmap(NULL, mem_size, PROT_READ | PROT_WRITE, MAP_PRIVATE | MAP_ANON, -1, 0); in sanity_tests_sd()
441 if (mem == MAP_FAILED) in sanity_tests_sd()
444 wp_init(mem, mem_size); in sanity_tests_sd()
445 wp_addr_range(mem, mem_size); in sanity_tests_sd()
447 ret = pagemap_ioctl(mem, mem_size, vec, vec_size, in sanity_tests_sd()
454 mem[i * page_size]++; in sanity_tests_sd()
456 ret = pagemap_ioctl(mem, mem_size, vec, vec_size, in sanity_tests_sd()
464 ret = pagemap_ioctl(mem, mem_size, vec, vec_size, in sanity_tests_sd()
472 ret = pagemap_ioctl(mem, mem_size, vec, vec_size, in sanity_tests_sd()
483 wp_free(mem, mem_size); in sanity_tests_sd()
484 munmap(mem, mem_size); in sanity_tests_sd()
495 mem = mmap(NULL, mem_size, PROT_READ | PROT_WRITE, MAP_PRIVATE | MAP_ANON, -1, 0); in sanity_tests_sd()
496 if (mem == MAP_FAILED) in sanity_tests_sd()
499 wp_init(mem, mem_size); in sanity_tests_sd()
500 wp_addr_range(mem, mem_size); in sanity_tests_sd()
504 walk_end = (long)mem; in sanity_tests_sd()
508 mem[i]++; in sanity_tests_sd()
514 ret = pagemap_ioc((void *)walk_end, mem_size-(walk_end - (long)mem), vec, in sanity_tests_sd()
534 wp_free(mem, mem_size); in sanity_tests_sd()
535 munmap(mem, mem_size); in sanity_tests_sd()
545 mem = mmap(NULL, mem_size, PROT_READ | PROT_WRITE, MAP_PRIVATE | MAP_ANON, -1, 0); in sanity_tests_sd()
546 if (mem == MAP_FAILED) in sanity_tests_sd()
549 wp_init(mem, mem_size); in sanity_tests_sd()
550 wp_addr_range(mem, mem_size); in sanity_tests_sd()
552 memset(mem, 0, mem_size); in sanity_tests_sd()
554 ret = pagemap_ioc(mem, 0, vec, vec_size, 0, in sanity_tests_sd()
558 ksft_test_result(ret == 0 && walk_end == (long)mem, in sanity_tests_sd()
561 ret = pagemap_ioc(mem, 0, vec, vec_size, PM_SCAN_WP_MATCHING | PM_SCAN_CHECK_WPASYNC, in sanity_tests_sd()
565 ksft_test_result(ret == 0 && walk_end == (long)mem, in sanity_tests_sd()
568 ret = pagemap_ioc(mem, 0, vec, 0, PM_SCAN_WP_MATCHING | PM_SCAN_CHECK_WPASYNC, in sanity_tests_sd()
572 ksft_test_result(ret == 0 && walk_end == (long)mem, in sanity_tests_sd()
575 ret = pagemap_ioc(mem, mem_size, vec, vec_size, 0, in sanity_tests_sd()
579 ksft_test_result(ret == 1 && walk_end == (long)(mem + mem_size), in sanity_tests_sd()
582 ret = pagemap_ioc(mem, mem_size, vec, 1, 0, in sanity_tests_sd()
586 ksft_test_result(ret == 1 && walk_end == (long)(mem + mem_size), in sanity_tests_sd()
589 ret = pagemap_ioc(mem, mem_size, vec, 1, 0, in sanity_tests_sd()
593 ksft_test_result(ret == 1 && walk_end == (long)(mem + mem_size), in sanity_tests_sd()
596 ret = pagemap_ioc(mem, mem_size, vec, vec_size, 0, in sanity_tests_sd()
600 ksft_test_result(ret == 1 && walk_end == (long)(mem + mem_size/2), in sanity_tests_sd()
603 ret = pagemap_ioc(mem, mem_size, vec, vec_size, 0, in sanity_tests_sd()
607 ksft_test_result(ret == 1 && walk_end == (long)(mem + page_size), in sanity_tests_sd()
610 ret = pagemap_ioc(mem, mem_size, vec, vec_size, 0, in sanity_tests_sd()
614 ksft_test_result(ret == 1 && walk_end == (long)(mem + mem_size), in sanity_tests_sd()
617 wp_addr_range(mem, mem_size); in sanity_tests_sd()
619 mem[i]++; in sanity_tests_sd()
621 ret = pagemap_ioc(mem, mem_size, vec, vec_size, 0, in sanity_tests_sd()
625 ksft_test_result(ret == vec_size/2 && walk_end == (long)(mem + mem_size), in sanity_tests_sd()
628 ret = pagemap_ioc(mem, mem_size, vec, 1, 0, in sanity_tests_sd()
632 ksft_test_result(ret == 1 && walk_end == (long)(mem + page_size * 2), in sanity_tests_sd()
635 ret = pagemap_ioc(mem, mem_size, vec, 1, 0, in sanity_tests_sd()
639 ksft_test_result(ret == 1 && walk_end == (long)(mem + page_size * 2), in sanity_tests_sd()
642 ret = pagemap_ioc(mem, mem_size, vec, vec_size/2, 0, in sanity_tests_sd()
646 ksft_test_result(ret == vec_size/2 && walk_end == (long)(mem + mem_size), in sanity_tests_sd()
649 ret = pagemap_ioc(mem, mem_size, vec, vec_size, 0, in sanity_tests_sd()
653 ksft_test_result(ret == vec_size/2 && walk_end == (long)(mem + mem_size), in sanity_tests_sd()
656 ret = pagemap_ioc(mem, mem_size, vec, vec_size, 0, in sanity_tests_sd()
660 ksft_test_result(ret == vec_size/2 && walk_end == (long)(mem + mem_size), in sanity_tests_sd()
663 ret = pagemap_ioc(mem, mem_size, vec, vec_size, 0, in sanity_tests_sd()
667 ksft_test_result(ret == 1 && walk_end == (long)(mem + page_size * 2), in sanity_tests_sd()
671 wp_free(mem, mem_size); in sanity_tests_sd()
672 munmap(mem, mem_size); in sanity_tests_sd()
677 int base_tests(char *prefix, char *mem, int mem_size, int skip) in base_tests() argument
698 written = pagemap_ioctl(mem, mem_size, vec, 1, PM_SCAN_WP_MATCHING | PM_SCAN_CHECK_WPASYNC, in base_tests()
706 memset(mem, -1, mem_size); in base_tests()
708 written = pagemap_ioctl(mem, mem_size, vec, 1, 0, 0, PAGE_IS_WRITTEN, 0, 0, in base_tests()
717 written = pagemap_ioctl(mem, mem_size, vec, 1, PM_SCAN_WP_MATCHING | PM_SCAN_CHECK_WPASYNC, in base_tests()
722 memset(mem + page_size, 0, mem_size - (2 * page_size)); in base_tests()
724 written = pagemap_ioctl(mem, mem_size, vec, 1, PM_SCAN_WP_MATCHING | PM_SCAN_CHECK_WPASYNC, in base_tests()
732 written = pagemap_ioctl(mem, mem_size, vec, 1, 0, 0, in base_tests()
741 written = pagemap_ioctl(mem, mem_size, vec, 1, PM_SCAN_WP_MATCHING | PM_SCAN_CHECK_WPASYNC, in base_tests()
746 mem[vec_size/2 * page_size]++; in base_tests()
748 written = pagemap_ioctl(mem, mem_size, vec, vec_size, 0, 0, PAGE_IS_WRITTEN, in base_tests()
757 written = pagemap_ioctl(mem, mem_size, vec, 1, PM_SCAN_WP_MATCHING | PM_SCAN_CHECK_WPASYNC, in base_tests()
762 mem[vec_size/2 * page_size]++; in base_tests()
763 mem[(vec_size/2 + 1) * page_size]++; in base_tests()
765 written = pagemap_ioctl(&mem[vec_size/2 * page_size], 2 * page_size, vec, 1, 0, in base_tests()
770 ksft_test_result(written == 1 && vec[0].start == (uintptr_t)(&mem[vec_size/2 * page_size]) in base_tests()
1052 char *mem, *fmem; in sanity_tests() local
1061 mem = mmap(NULL, mem_size, PROT_READ | PROT_WRITE, MAP_PRIVATE | MAP_ANON, -1, 0); in sanity_tests()
1062 if (mem == MAP_FAILED || vec == MAP_FAILED) in sanity_tests()
1065 wp_init(mem, mem_size); in sanity_tests()
1066 wp_addr_range(mem, mem_size); in sanity_tests()
1068 ksft_test_result(pagemap_ioctl(mem, mem_size, vec, vec_size, in sanity_tests()
1072 ksft_test_result(pagemap_ioctl(mem, mem_size, vec, vec_size, 0, 0, in sanity_tests()
1075 ksft_test_result(pagemap_ioctl(mem, mem_size, vec, vec_size, 0, 0, in sanity_tests()
1078 ksft_test_result(pagemap_ioctl(mem, mem_size, vec, vec_size, 0, 0, in sanity_tests()
1081 ksft_test_result(pagemap_ioctl(mem, mem_size, vec, vec_size, 0, 0, in sanity_tests()
1085 wp_free(mem, mem_size); in sanity_tests()
1086 munmap(mem, mem_size); in sanity_tests()
1089 mem = mmap(NULL, mem_size, PROT_READ | PROT_WRITE, MAP_PRIVATE | MAP_ANON, -1, 0); in sanity_tests()
1090 if (mem == MAP_FAILED) in sanity_tests()
1092 wp_init(mem, mem_size); in sanity_tests()
1093 wp_addr_range(mem, mem_size); in sanity_tests()
1095 memset(mem, 0, mem_size); in sanity_tests()
1097 ret = pagemap_ioctl(mem, mem_size, vec, vec_size, 0, 0, in sanity_tests()
1099 ksft_test_result(ret >= 0 && vec[0].start == (uintptr_t)mem && LEN(vec[0]) == vec_size && in sanity_tests()
1105 ret = pagemap_ioctl(mem, mem_size, vec, vec_size, 0, 0, in sanity_tests()
1107 ksft_test_result(ret >= 0 && vec[0].start == (uintptr_t)mem && LEN(vec[0]) == vec_size && in sanity_tests()
1113 ret = pagemap_ioctl(mem, mem_size, vec, vec_size, 0, 0, in sanity_tests()
1115 ksft_test_result(ret >= 0 && vec[0].start == (uintptr_t)mem && LEN(vec[0]) == vec_size && in sanity_tests()
1122 ret = pagemap_ioctl(mem, mem_size, vec, vec_size, 0, 0, in sanity_tests()
1127 ret = pagemap_ioctl(mem, mem_size, vec, vec_size, 0, 0, in sanity_tests()
1131 wp_free(mem, mem_size); in sanity_tests()
1132 munmap(mem, mem_size); in sanity_tests()
1135 mem = mmap(NULL, mem_size, PROT_READ | PROT_WRITE, MAP_PRIVATE | MAP_ANON, -1, 0); in sanity_tests()
1136 if (mem == MAP_FAILED) in sanity_tests()
1138 wp_init(mem, mem_size); in sanity_tests()
1139 wp_addr_range(mem, mem_size); in sanity_tests()
1141 memset(mem, 0, mem_size); in sanity_tests()
1143 ret = pagemap_ioctl(mem, mem_size, vec, vec_size, in sanity_tests()
1146 ksft_test_result(ret >= 0 && vec[0].start == (uintptr_t)mem && LEN(vec[0]) == vec_size && in sanity_tests()
1149 wp_free(mem, mem_size); in sanity_tests()
1150 munmap(mem, mem_size); in sanity_tests()
1223 char *mem, *mem2; in mprotect_tests() local
1233 mem = mmap(0, 2 * page_size, PROT_READ|PROT_WRITE, MAP_PRIVATE | MAP_ANON, -1, 0); in mprotect_tests()
1234 if (mem == MAP_FAILED) in mprotect_tests()
1236 wp_init(mem, 2 * page_size); in mprotect_tests()
1237 wp_addr_range(mem, 2 * page_size); in mprotect_tests()
1240 memset(mem, 1, 2 * page_size); in mprotect_tests()
1242 ret = pagemap_ioctl(mem, 2 * page_size, &vec, 1, 0, 0, PAGE_IS_WRITTEN, in mprotect_tests()
1250 wp_addr_range(mem, 2 * page_size); in mprotect_tests()
1252 ksft_test_result(pagemap_ioctl(mem, 2 * page_size, &vec, 1, 0, 0, in mprotect_tests()
1257 mem2 = mmap(mem + page_size, page_size, PROT_READ|PROT_WRITE, in mprotect_tests()
1265 mprotect(mem, page_size, PROT_NONE); in mprotect_tests()
1266 mprotect(mem, 2 * page_size, PROT_READ); in mprotect_tests()
1267 mprotect(mem, 2 * page_size, PROT_READ|PROT_WRITE); in mprotect_tests()
1270 memset(mem, 2, 2 * page_size); in mprotect_tests()
1273 mprotect(mem, page_size, PROT_NONE); in mprotect_tests()
1274 mprotect(mem, page_size, PROT_READ); in mprotect_tests()
1275 mprotect(mem, page_size, PROT_READ|PROT_WRITE); in mprotect_tests()
1277 ret = pagemap_ioctl(mem, 2 * page_size, &vec, 1, 0, 0, PAGE_IS_WRITTEN, in mprotect_tests()
1286 wp_addr_range(mem, 2 * page_size); in mprotect_tests()
1288 memset(mem, 'A', 2 * page_size); in mprotect_tests()
1290 ret = pagemap_ioctl(mem, 2 * page_size, &vec, 1, 0, 0, PAGE_IS_WRITTEN, in mprotect_tests()
1298 wp_free(mem, 2 * page_size); in mprotect_tests()
1299 munmap(mem, 2 * page_size); in mprotect_tests()
1310 static ssize_t get_dirty_pages_reset(char *mem, unsigned int count, in get_dirty_pages_reset() argument
1318 arg.start = (uintptr_t)mem; in get_dirty_pages_reset()
1320 arg.end = (uintptr_t)(mem + count * page_size); in get_dirty_pages_reset()
1344 void *thread_proc(void *mem) in thread_proc() argument
1346 int *m = mem; in thread_proc()
1388 char *mem; in transact_test() local
1397 mem = mmap(NULL, 0x1000 * nthreads * pages_per_thread, PROT_READ | PROT_WRITE, in transact_test()
1399 if (mem == MAP_FAILED) in transact_test()
1402 wp_init(mem, 0x1000 * nthreads * pages_per_thread); in transact_test()
1403 wp_addr_range(mem, 0x1000 * nthreads * pages_per_thread); in transact_test()
1405 memset(mem, 0, 0x1000 * nthreads * pages_per_thread); in transact_test()
1407 count = get_dirty_pages_reset(mem, nthreads * pages_per_thread, 1, page_size); in transact_test()
1409 count = get_dirty_pages_reset(mem, nthreads * pages_per_thread, 1, page_size); in transact_test()
1414 pthread_create(&th, NULL, thread_proc, mem + 0x1000 * i * pages_per_thread); in transact_test()
1424 count = get_dirty_pages_reset(mem, nthreads * pages_per_thread, 1, in transact_test()
1435 c = get_dirty_pages_reset(mem, nthreads * pages_per_thread, 1, page_size); in transact_test()
1479 char *mem, *map, *fmem; in main() local
1503 mem = mmap(NULL, mem_size, PROT_READ | PROT_WRITE, MAP_PRIVATE | MAP_ANON, -1, 0); in main()
1504 if (mem == MAP_FAILED) in main()
1506 wp_init(mem, mem_size); in main()
1507 wp_addr_range(mem, mem_size); in main()
1509 base_tests("Page testing:", mem, mem_size, 0); in main()
1511 wp_free(mem, mem_size); in main()
1512 munmap(mem, mem_size); in main()
1516 mem = mmap(NULL, mem_size, PROT_READ | PROT_WRITE, MAP_PRIVATE | MAP_ANON, -1, 0); in main()
1517 if (mem == MAP_FAILED) in main()
1519 wp_init(mem, mem_size); in main()
1520 wp_addr_range(mem, mem_size); in main()
1522 base_tests("Large Page testing:", mem, mem_size, 0); in main()
1524 wp_free(mem, mem_size); in main()
1525 munmap(mem, mem_size); in main()
1541 mem = gethugetlb_mem(mem_size, &shmid); in main()
1542 if (mem) { in main()
1543 wp_init(mem, mem_size); in main()
1544 wp_addr_range(mem, mem_size); in main()
1546 base_tests("Hugetlb shmem testing:", mem, mem_size, 0); in main()
1548 wp_free(mem, mem_size); in main()
1555 mem = gethugetlb_mem(mem_size, NULL); in main()
1556 if (mem) { in main()
1557 wp_init(mem, mem_size); in main()
1558 wp_addr_range(mem, mem_size); in main()
1560 base_tests("Hugetlb mem testing:", mem, mem_size, 0); in main()
1562 wp_free(mem, mem_size); in main()
1572 mem = mmap(NULL, mem_size, PROT_READ | PROT_WRITE, MAP_SHARED, fd, 0); in main()
1573 if (mem != MAP_FAILED) { in main()
1574 wp_init(mem, mem_size); in main()
1575 wp_addr_range(mem, mem_size); in main()
1577 base_tests("Hugetlb shmem testing:", mem, mem_size, 0); in main()
1579 wp_free(mem, mem_size); in main()