Lines Matching defs:mem
134 static int child_memcmp_fn(char *mem, size_t size,
141 memcpy(old, mem, size);
149 return memcmp(old, mem, size);
152 static int child_vmsplice_memcmp_fn(char *mem, size_t size,
156 .iov_base = mem,
168 memcpy(old, mem, size);
181 if (munmap(mem, size) < 0)
199 typedef int (*child_fn)(char *mem, size_t size, struct comm_pipes *comm_pipes);
201 static void do_test_cow_in_parent(char *mem, size_t size, bool do_mprotect,
219 exit(fn(mem, size, &comm_pipes));
230 ret = mprotect(mem, size, PROT_READ);
231 ret |= mprotect(mem, size, PROT_READ|PROT_WRITE);
241 memset(mem, 0xff, size);
266 static void test_cow_in_parent(char *mem, size_t size, bool is_hugetlb)
268 do_test_cow_in_parent(mem, size, false, child_memcmp_fn, false);
271 static void test_cow_in_parent_mprotect(char *mem, size_t size, bool is_hugetlb)
273 do_test_cow_in_parent(mem, size, true, child_memcmp_fn, false);
276 static void test_vmsplice_in_child(char *mem, size_t size, bool is_hugetlb)
278 do_test_cow_in_parent(mem, size, false, child_vmsplice_memcmp_fn,
282 static void test_vmsplice_in_child_mprotect(char *mem, size_t size,
285 do_test_cow_in_parent(mem, size, true, child_vmsplice_memcmp_fn,
289 static void do_test_vmsplice_in_parent(char *mem, size_t size,
293 .iov_base = mem,
305 memcpy(old, mem, size);
335 memset(mem, 0xff, size);
350 if (munmap(mem, size) < 0) {
394 static void test_vmsplice_before_fork(char *mem, size_t size, bool is_hugetlb)
396 do_test_vmsplice_in_parent(mem, size, true, is_hugetlb);
399 static void test_vmsplice_after_fork(char *mem, size_t size, bool is_hugetlb)
401 do_test_vmsplice_in_parent(mem, size, false, is_hugetlb);
405 static void do_test_iouring(char *mem, size_t size, bool use_fork)
451 iov.iov_base = mem;
485 ret = mprotect(mem, size, PROT_READ);
487 ret |= mprotect(mem, size, PROT_READ | PROT_WRITE);
498 memset(mem, 0xff, size);
504 io_uring_prep_write_fixed(sqe, fd, mem, size, 0, 0);
536 ksft_test_result(!memcmp(mem, tmp, size),
556 static void test_iouring_ro(char *mem, size_t size, bool is_hugetlb)
558 do_test_iouring(mem, size, false);
561 static void test_iouring_fork(char *mem, size_t size, bool is_hugetlb)
563 do_test_iouring(mem, size, true);
575 static void do_test_ro_pin(char *mem, size_t size, enum ro_pin_test test,
645 ret = mprotect(mem, size, PROT_READ);
647 ret |= mprotect(mem, size, PROT_READ | PROT_WRITE);
658 args.addr = (__u64)(uintptr_t)mem;
671 memset(mem, 0xff, size);
682 ksft_test_result(!memcmp(mem, tmp, size),
705 static void test_ro_pin_on_shared(char *mem, size_t size, bool is_hugetlb)
707 do_test_ro_pin(mem, size, RO_PIN_TEST_SHARED, false);
710 static void test_ro_fast_pin_on_shared(char *mem, size_t size, bool is_hugetlb)
712 do_test_ro_pin(mem, size, RO_PIN_TEST_SHARED, true);
715 static void test_ro_pin_on_ro_previously_shared(char *mem, size_t size,
718 do_test_ro_pin(mem, size, RO_PIN_TEST_PREVIOUSLY_SHARED, false);
721 static void test_ro_fast_pin_on_ro_previously_shared(char *mem, size_t size,
724 do_test_ro_pin(mem, size, RO_PIN_TEST_PREVIOUSLY_SHARED, true);
727 static void test_ro_pin_on_ro_exclusive(char *mem, size_t size,
730 do_test_ro_pin(mem, size, RO_PIN_TEST_RO_EXCLUSIVE, false);
733 static void test_ro_fast_pin_on_ro_exclusive(char *mem, size_t size,
736 do_test_ro_pin(mem, size, RO_PIN_TEST_RO_EXCLUSIVE, true);
739 typedef void (*test_fn)(char *mem, size_t size, bool hugetlb);
743 char *mem;
746 mem = mmap(NULL, pagesize, PROT_READ | PROT_WRITE,
748 if (mem == MAP_FAILED) {
753 ret = madvise(mem, pagesize, MADV_NOHUGEPAGE);
761 memset(mem, 0, pagesize);
764 madvise(mem, pagesize, MADV_PAGEOUT);
765 if (!pagemap_is_swapped(pagemap_fd, mem)) {
771 fn(mem, pagesize, false);
773 munmap(mem, pagesize);
801 char *mem, *mmap_mem, *tmp, *mremap_mem = MAP_FAILED;
815 mem = (char *)(((uintptr_t)mmap_mem + thpsize) & ~(thpsize - 1));
817 ret = madvise(mem, thpsize, MADV_HUGEPAGE);
827 mem[0] = 0;
828 if (!pagemap_is_populated(pagemap_fd, mem + thpsize - pagesize)) {
832 memset(mem, 0, thpsize);
847 ret = mprotect(mem + pagesize, pagesize, PROT_READ);
852 ret = mprotect(mem + pagesize, pagesize, PROT_READ | PROT_WRITE);
864 ret = madvise(mem + pagesize, thpsize - pagesize, MADV_DONTNEED);
879 if (mem == MAP_FAILED) {
883 tmp = mremap(mem + mremap_size, mremap_size, mremap_size,
897 ret = madvise(mem + pagesize, thpsize - pagesize, MADV_DONTFORK);
911 ret = madvise(mem + pagesize, thpsize - pagesize, MADV_DOFORK);
925 madvise(mem, size, MADV_PAGEOUT);
926 if (!range_is_swapped(mem, size)) {
935 fn(mem, size, false);
1001 char *mem, *dummy;
1008 mem = mmap(NULL, hugetlbsize, PROT_READ | PROT_WRITE, flags, -1, 0);
1009 if (mem == MAP_FAILED) {
1015 memset(mem, 0, hugetlbsize);
1028 fn(mem, hugetlbsize, true);
1030 munmap(mem, hugetlbsize);
1220 static void do_test_anon_thp_collapse(char *mem, size_t size,
1237 ret = mprotect(mem + pagesize, pagesize, PROT_READ);
1242 ret = mprotect(mem + pagesize, pagesize, PROT_READ | PROT_WRITE);
1251 ret = madvise(mem, size, MADV_COLLAPSE);
1263 ret = madvise(mem + size / 2, size / 2, MADV_DONTFORK);
1271 ret = madvise(mem, size / 2, MADV_DONTFORK);
1289 exit(child_memcmp_fn(mem, size, &comm_pipes));
1292 exit(child_memcmp_fn(mem, size / 2, &comm_pipes));
1295 exit(child_memcmp_fn(mem + size / 2, size / 2,
1315 ret = madvise(mem, size, MADV_DOFORK);
1325 ret = madvise(mem, size, MADV_COLLAPSE);
1339 memset(mem, 0xff, size);
1353 static void test_anon_thp_collapse_unshared(char *mem, size_t size,
1357 do_test_anon_thp_collapse(mem, size, ANON_THP_COLLAPSE_UNSHARED);
1360 static void test_anon_thp_collapse_fully_shared(char *mem, size_t size,
1364 do_test_anon_thp_collapse(mem, size, ANON_THP_COLLAPSE_FULLY_SHARED);
1367 static void test_anon_thp_collapse_lower_shared(char *mem, size_t size,
1371 do_test_anon_thp_collapse(mem, size, ANON_THP_COLLAPSE_LOWER_SHARED);
1374 static void test_anon_thp_collapse_upper_shared(char *mem, size_t size,
1378 do_test_anon_thp_collapse(mem, size, ANON_THP_COLLAPSE_UPPER_SHARED);
1443 typedef void (*non_anon_test_fn)(char *mem, const char *smem, size_t size);
1445 static void test_cow(char *mem, const char *smem, size_t size)
1453 memset(mem, 0xff, size);
1461 static void test_ro_pin(char *mem, const char *smem, size_t size)
1463 do_test_ro_pin(mem, size, RO_PIN_TEST, false);
1466 static void test_ro_fast_pin(char *mem, const char *smem, size_t size)
1468 do_test_ro_pin(mem, size, RO_PIN_TEST, true);
1473 char *mem, *smem, tmp;
1477 mem = mmap(NULL, pagesize, PROT_READ | PROT_WRITE,
1479 if (mem == MAP_FAILED) {
1485 if (mem == MAP_FAILED) {
1491 tmp = *mem + *smem;
1494 fn(mem, smem, pagesize);
1496 munmap(mem, pagesize);
1503 char *mem, *smem, *mmap_mem, *mmap_smem, tmp;
1530 mem = (char *)(((uintptr_t)mmap_mem + pmdsize) & ~(pmdsize - 1));
1533 ret = madvise(mem, pmdsize, MADV_HUGEPAGE);
1545 tmp = *mem + *smem;
1547 if (!pagemap_is_populated(pagemap_fd, mem + pagesize) ||
1553 fn(mem, smem, pmdsize);
1562 char *mem, *smem, tmp;
1580 mem = mmap(NULL, pagesize, PROT_READ | PROT_WRITE, MAP_PRIVATE, fd, 0);
1581 if (mem == MAP_FAILED) {
1586 if (mem == MAP_FAILED) {
1592 tmp = *mem + *smem;
1595 fn(mem, smem, pagesize);
1597 munmap(mem, pagesize);
1606 char *mem, *smem, tmp;
1631 mem = mmap(NULL, pagesize, PROT_READ | PROT_WRITE, MAP_PRIVATE, fd, 0);
1632 if (mem == MAP_FAILED) {
1637 if (mem == MAP_FAILED) {
1643 tmp = *mem + *smem;
1646 fn(mem, smem, pagesize);
1648 munmap(mem, pagesize);
1659 char *mem, *smem, tmp;
1680 mem = mmap(NULL, hugetlbsize, PROT_READ | PROT_WRITE, MAP_PRIVATE, fd,
1682 if (mem == MAP_FAILED) {
1687 if (mem == MAP_FAILED) {
1693 tmp = *mem + *smem;
1696 fn(mem, smem, hugetlbsize);
1698 munmap(mem, hugetlbsize);
1699 if (mem != MAP_FAILED)