Lines Matching refs:size

22 static int sz2ord(size_t size)  in sz2ord()  argument
24 return __builtin_ctzll(size / pagesize); in sz2ord()
52 static void *mmap_aligned(size_t size, int prot, int flags) in mmap_aligned() argument
54 size_t mmap_size = size * 2; in mmap_aligned()
61 mem = (char *)(((uintptr_t)mmap_mem + size - 1) & ~(size - 1)); in mmap_aligned()
63 munmap(mem + size, mmap_mem + mmap_size - mem - size); in mmap_aligned()
68 static void *alloc_one_folio(size_t size, bool private, bool hugetlb) in alloc_one_folio() argument
70 bool thp = !hugetlb && size > pagesize; in alloc_one_folio()
75 assert((size & (size - 1)) == 0); in alloc_one_folio()
90 settings.hugepages[sz2ord(size)].enabled = THP_ALWAYS; in alloc_one_folio()
92 settings.shmem_hugepages[sz2ord(size)].enabled = SHMEM_ALWAYS; in alloc_one_folio()
96 mem = mmap_aligned(size, prot, flags); in alloc_one_folio()
100 flags |= __builtin_ctzll(size) << MAP_HUGE_SHIFT; in alloc_one_folio()
103 mem = mmap(NULL, size, prot, flags, -1, 0); in alloc_one_folio()
111 assert(((uintptr_t)mem & (size - 1)) == 0); in alloc_one_folio()
119 for (addr = mem; addr < mem + size; addr += pagesize) { in alloc_one_folio()
121 munmap(mem, size); in alloc_one_folio()
126 memset(mem, 1, size); in alloc_one_folio()
134 static bool check_uffd_wp_state(void *mem, size_t size, bool expect) in check_uffd_wp_state() argument
139 for (addr = mem; addr < mem + size; addr += pagesize) { in check_uffd_wp_state()
152 static bool range_is_swapped(void *addr, size_t size) in range_is_swapped() argument
154 for (; size; addr += pagesize, size -= pagesize) in range_is_swapped()
160 static void test_one_folio(size_t size, bool private, bool swapout, bool hugetlb) in test_one_folio() argument
171 size, in test_one_folio()
177 mem = alloc_one_folio(size, private, hugetlb); in test_one_folio()
191 if (uffd_register(uffd, mem, size, false, true, false)) { in test_one_folio()
197 wp_prms.range.len = size; in test_one_folio()
204 madvise(mem, size, MADV_PAGEOUT); in test_one_folio()
205 if (!range_is_swapped(mem, size)) { in test_one_folio()
212 if (!check_uffd_wp_state(mem, size, true)) in test_one_folio()
220 addr = mmap_aligned(size, PROT_NONE, MAP_PRIVATE | MAP_ANONYMOUS); in test_one_folio()
225 if (mremap(mem, size, size, MREMAP_FIXED | MREMAP_MAYMOVE, addr) == MAP_FAILED) { in test_one_folio()
227 munmap(addr, size); in test_one_folio()
233 if (!check_uffd_wp_state(mem, size, false)) in test_one_folio()
238 size, in test_one_folio()
244 munmap(mem, size); in test_one_folio()