- /*
* To challenge spitting code, we will mremap page[x] of the
* thp[x] into a smaller area, and trigger the split from that
* smaller area. This will end up replacing the PMD mappings in
* the thp_area by PTE mappings first, leaving the THPs unsplit.
*/
- page_area = mmap(NULL, page_area_size, PROT_READ | PROT_WRITE,
MAP_ANONYMOUS | MAP_PRIVATE, -1, 0);
- if (page_area == MAP_FAILED) {
ksft_test_result_fail("Fail to allocate memory: %s\n", strerror(errno));
goto out;
- }
if (i % pagesize == 0 &&
!is_backed_by_folio(&pte_mapped[i], 0, pagemap_fd, kpageflags_fd))
thp_size++;
- for (i = 0; i < nr_thps; i++) {
tmp = mremap(thp_area + pmd_pagesize * i + pagesize * i,
pagesize, pagesize, MREMAP_MAYMOVE|MREMAP_FIXED,
page_area + pagesize * i);
Would this create one hole at the beginning of each 2M range and cause splitting underlining THP?
Yes, it will create a hole (this also happens in the old code).
As the comment above it now states: "leaving the THPs unsplit"
There is a check verifying that after this mremap code.