Can begin Results

This commit is contained in:
Zhengyi Chen 2024-03-19 23:34:19 +00:00
parent f9adbf1f1d
commit fc777526ce
4 changed files with 44 additions and 8 deletions

View file

@ -174,6 +174,7 @@ ok:
return ret;
}
// FIXME: bugs in order == 12, alloc pg cnt == 32768
static vm_fault_t my_shmem_vmops_fault(struct vm_fault *vmf)
{
pr_info("[%s] vm_fault @ 0x%lx (vma + %ld pages).\n",
@ -184,10 +185,10 @@ static vm_fault_t my_shmem_vmops_fault(struct vm_fault *vmf)
mutex_lock(&my_shmem_allocs_mtx);
locked_retry:
if (fault_pg_offset < my_shmem_page_count) {
if (fault_pg_offset < my_shmem_page_count)
// => Already present, remap
return __my_shmem_fault_remap(vmf);
}
// else => allocate `1 << order` pages opportunistically...
struct my_shmem_alloc *new_alloc_handle = kzalloc(
sizeof(struct my_shmem_alloc), GFP_KERNEL
@ -201,19 +202,23 @@ locked_retry:
if (!new_alloc_pg)
goto err_alloc_pages;
// get_page(new_alloc_pg);
new_alloc_handle->page = new_alloc_pg;
new_alloc_handle->alloc_order = max_contiguous_alloc_order;
list_add_tail(&new_alloc_handle->list, &my_shmem_allocs);
my_shmem_page_count += ORDER_TO_PAGE_NR(new_alloc_handle->alloc_order);
pr_info("[%s] Allocated 1 << %ld pages: 0x%lx - 0x%lx. Current page count: %ld\n",
__func__, max_contiguous_alloc_order,
page_to_pfn(new_alloc_pg), page_to_pfn(new_alloc_pg) + (1 << max_contiguous_alloc_order),
my_shmem_page_count);
page_to_pfn(new_alloc_pg),
page_to_pfn(new_alloc_pg) + (1 << max_contiguous_alloc_order),
my_shmem_page_count
);
goto locked_retry;
err_alloc_pages:
pr_err("[%s] Allocation (ord: %ld) failed...\n",
__func__, max_contiguous_alloc_order
);
err_kzalloc_handle:
ret |= VM_FAULT_OOM;
err_generic: