MM: use ihk_mc_{alloc/free}_pages() everywhere and fix free_pages() on kmalloc()ed object bug
This commit is contained in:
@ -99,7 +99,7 @@ int devobj_create(int fd, size_t len, off_t off, struct memobj **objp, int *maxp
|
||||
}
|
||||
memset(obj, 0, sizeof(*obj));
|
||||
|
||||
obj->pfn_table = allocate_pages(pfn_npages, IHK_MC_AP_NOWAIT);
|
||||
obj->pfn_table = ihk_mc_alloc_pages(pfn_npages, IHK_MC_AP_NOWAIT);
|
||||
if (!obj->pfn_table) {
|
||||
error = -ENOMEM;
|
||||
kprintf("%s: error: fd: %d, len: %lu, off: %lu allocating PFN failed.\n",
|
||||
@ -141,7 +141,7 @@ int devobj_create(int fd, size_t len, off_t off, struct memobj **objp, int *maxp
|
||||
out:
|
||||
if (obj) {
|
||||
if (obj->pfn_table) {
|
||||
free_pages(obj->pfn_table, pfn_npages);
|
||||
ihk_mc_free_pages(obj->pfn_table, pfn_npages);
|
||||
}
|
||||
kfree(obj);
|
||||
}
|
||||
@ -196,7 +196,7 @@ static void devobj_release(struct memobj *memobj)
|
||||
}
|
||||
|
||||
if (obj->pfn_table) {
|
||||
free_pages(obj->pfn_table, pfn_npages);
|
||||
ihk_mc_free_pages(obj->pfn_table, pfn_npages);
|
||||
}
|
||||
kfree(free_obj);
|
||||
}
|
||||
|
||||
@ -375,8 +375,9 @@ static int process_msg_prepare_process(unsigned long rphys)
|
||||
n = p->num_sections;
|
||||
dkprintf("# of sections: %d\n", n);
|
||||
|
||||
if((pn = ihk_mc_allocate(sizeof(struct program_load_desc)
|
||||
+ sizeof(struct program_image_section) * n, IHK_MC_AP_NOWAIT)) == NULL){
|
||||
if((pn = kmalloc(sizeof(struct program_load_desc)
|
||||
+ sizeof(struct program_image_section) * n,
|
||||
IHK_MC_AP_NOWAIT)) == NULL){
|
||||
ihk_mc_unmap_virtual(p, npages, 0);
|
||||
ihk_mc_unmap_memory(NULL, phys, sz);
|
||||
return -ENOMEM;
|
||||
@ -385,7 +386,7 @@ static int process_msg_prepare_process(unsigned long rphys)
|
||||
+ sizeof(struct program_image_section) * n);
|
||||
|
||||
if((thread = create_thread(p->entry)) == NULL){
|
||||
ihk_mc_free(pn);
|
||||
kfree(pn);
|
||||
ihk_mc_unmap_virtual(p, npages, 1);
|
||||
ihk_mc_unmap_memory(NULL, phys, sz);
|
||||
return -ENOMEM;
|
||||
@ -435,7 +436,7 @@ static int process_msg_prepare_process(unsigned long rphys)
|
||||
dkprintf("new process : %p [%d] / table : %p\n", proc, proc->pid,
|
||||
vm->address_space->page_table);
|
||||
|
||||
ihk_mc_free(pn);
|
||||
kfree(pn);
|
||||
|
||||
ihk_mc_unmap_virtual(p, npages, 1);
|
||||
ihk_mc_unmap_memory(NULL, phys, sz);
|
||||
@ -443,7 +444,7 @@ static int process_msg_prepare_process(unsigned long rphys)
|
||||
|
||||
return 0;
|
||||
err:
|
||||
ihk_mc_free(pn);
|
||||
kfree(pn);
|
||||
ihk_mc_unmap_virtual(p, npages, 1);
|
||||
ihk_mc_unmap_memory(NULL, phys, sz);
|
||||
destroy_thread(thread);
|
||||
@ -452,7 +453,7 @@ err:
|
||||
|
||||
static void process_msg_init(struct ikc_scd_init_param *pcp, struct syscall_params *lparam)
|
||||
{
|
||||
lparam->response_va = allocate_pages(RESPONSE_PAGE_COUNT, 0);
|
||||
lparam->response_va = ihk_mc_alloc_pages(RESPONSE_PAGE_COUNT, 0);
|
||||
lparam->response_pa = virt_to_phys(lparam->response_va);
|
||||
|
||||
pcp->request_page = 0;
|
||||
|
||||
@ -739,7 +739,7 @@ int join_process_memory_range(struct process_vm *vm,
|
||||
memobj_release(merging->memobj);
|
||||
}
|
||||
list_del(&merging->list);
|
||||
ihk_mc_free(merging);
|
||||
kfree(merging);
|
||||
|
||||
error = 0;
|
||||
out:
|
||||
@ -835,8 +835,9 @@ int free_process_memory_range(struct process_vm *vm, struct vm_range *range)
|
||||
if (range->memobj) {
|
||||
memobj_release(range->memobj);
|
||||
}
|
||||
|
||||
list_del(&range->list);
|
||||
ihk_mc_free(range);
|
||||
kfree(range);
|
||||
|
||||
dkprintf("free_process_memory_range(%p,%lx-%lx): 0\n",
|
||||
vm, start0, end0);
|
||||
@ -1888,14 +1889,14 @@ unsigned long extend_process_region(struct process_vm *vm,
|
||||
aligned_end = (aligned_end + (LARGE_PAGE_SIZE - 1)) & LARGE_PAGE_MASK;
|
||||
/* Fill in the gap between old_aligned_end and aligned_end
|
||||
* with regular pages */
|
||||
if((p = allocate_pages((aligned_end - old_aligned_end) >> PAGE_SHIFT,
|
||||
if((p = ihk_mc_alloc_pages((aligned_end - old_aligned_end) >> PAGE_SHIFT,
|
||||
IHK_MC_AP_NOWAIT)) == NULL){
|
||||
return end;
|
||||
}
|
||||
if((rc = add_process_memory_range(vm, old_aligned_end,
|
||||
aligned_end, virt_to_phys(p), flag,
|
||||
LARGE_PAGE_SHIFT)) != 0){
|
||||
free_pages(p, (aligned_end - old_aligned_end) >> PAGE_SHIFT);
|
||||
ihk_mc_free_pages(p, (aligned_end - old_aligned_end) >> PAGE_SHIFT);
|
||||
return end;
|
||||
}
|
||||
|
||||
@ -1908,7 +1909,7 @@ unsigned long extend_process_region(struct process_vm *vm,
|
||||
(LARGE_PAGE_SIZE - 1)) & LARGE_PAGE_MASK;
|
||||
address = aligned_new_end;
|
||||
|
||||
if((p = allocate_pages((aligned_new_end - aligned_end + LARGE_PAGE_SIZE) >> PAGE_SHIFT,
|
||||
if((p = ihk_mc_alloc_pages((aligned_new_end - aligned_end + LARGE_PAGE_SIZE) >> PAGE_SHIFT,
|
||||
IHK_MC_AP_NOWAIT)) == NULL){
|
||||
return end;
|
||||
}
|
||||
@ -1916,16 +1917,16 @@ unsigned long extend_process_region(struct process_vm *vm,
|
||||
p_aligned = ((unsigned long)p + (LARGE_PAGE_SIZE - 1)) & LARGE_PAGE_MASK;
|
||||
|
||||
if (p_aligned > (unsigned long)p) {
|
||||
free_pages(p, (p_aligned - (unsigned long)p) >> PAGE_SHIFT);
|
||||
ihk_mc_free_pages(p, (p_aligned - (unsigned long)p) >> PAGE_SHIFT);
|
||||
}
|
||||
free_pages(
|
||||
ihk_mc_free_pages(
|
||||
(void *)(p_aligned + aligned_new_end - aligned_end),
|
||||
(LARGE_PAGE_SIZE - (p_aligned - (unsigned long)p)) >> PAGE_SHIFT);
|
||||
|
||||
if((rc = add_process_memory_range(vm, aligned_end,
|
||||
aligned_new_end, virt_to_phys((void *)p_aligned),
|
||||
flag, LARGE_PAGE_SHIFT)) != 0){
|
||||
free_pages(p, (aligned_new_end - aligned_end + LARGE_PAGE_SIZE) >> PAGE_SHIFT);
|
||||
ihk_mc_free_pages(p, (aligned_new_end - aligned_end + LARGE_PAGE_SIZE) >> PAGE_SHIFT);
|
||||
return end;
|
||||
}
|
||||
|
||||
@ -1943,7 +1944,7 @@ unsigned long extend_process_region(struct process_vm *vm,
|
||||
p=0;
|
||||
}else{
|
||||
|
||||
p = allocate_pages((aligned_new_end - aligned_end) >> PAGE_SHIFT, IHK_MC_AP_NOWAIT);
|
||||
p = ihk_mc_alloc_pages((aligned_new_end - aligned_end) >> PAGE_SHIFT, IHK_MC_AP_NOWAIT);
|
||||
|
||||
if (!p) {
|
||||
return end;
|
||||
@ -1952,7 +1953,7 @@ unsigned long extend_process_region(struct process_vm *vm,
|
||||
if((rc = add_process_memory_range(vm, aligned_end, aligned_new_end,
|
||||
(p==0?0:virt_to_phys(p)), flag, NULL, 0,
|
||||
PAGE_SHIFT)) != 0){
|
||||
free_pages(p, (aligned_new_end - aligned_end) >> PAGE_SHIFT);
|
||||
ihk_mc_free_pages(p, (aligned_new_end - aligned_end) >> PAGE_SHIFT);
|
||||
return end;
|
||||
}
|
||||
|
||||
|
||||
@ -75,7 +75,7 @@ sysfs_createf(struct sysfs_ops *ops, void *instance, int mode,
|
||||
dkprintf("sysfs_createf(%p,%p,%#o,%s,...)\n",
|
||||
ops, instance, mode, fmt);
|
||||
|
||||
param = allocate_pages(1, IHK_MC_AP_NOWAIT);
|
||||
param = ihk_mc_alloc_pages(1, IHK_MC_AP_NOWAIT);
|
||||
if (!param) {
|
||||
error = -ENOMEM;
|
||||
ekprintf("sysfs_createf:allocate_pages failed. %d\n", error);
|
||||
@ -134,7 +134,7 @@ sysfs_createf(struct sysfs_ops *ops, void *instance, int mode,
|
||||
error = 0;
|
||||
out:
|
||||
if (param) {
|
||||
free_pages(param, 1);
|
||||
ihk_mc_free_pages(param, 1);
|
||||
}
|
||||
if (error) {
|
||||
ekprintf("sysfs_createf(%p,%p,%#o,%s,...): %d\n",
|
||||
@ -156,7 +156,7 @@ sysfs_mkdirf(sysfs_handle_t *dirhp, const char *fmt, ...)
|
||||
|
||||
dkprintf("sysfs_mkdirf(%p,%s,...)\n", dirhp, fmt);
|
||||
|
||||
param = allocate_pages(1, IHK_MC_AP_NOWAIT);
|
||||
param = ihk_mc_alloc_pages(1, IHK_MC_AP_NOWAIT);
|
||||
if (!param) {
|
||||
error = -ENOMEM;
|
||||
ekprintf("sysfs_mkdirf:allocate_pages failed. %d\n", error);
|
||||
@ -208,7 +208,7 @@ sysfs_mkdirf(sysfs_handle_t *dirhp, const char *fmt, ...)
|
||||
|
||||
out:
|
||||
if (param) {
|
||||
free_pages(param, 1);
|
||||
ihk_mc_free_pages(param, 1);
|
||||
}
|
||||
if (error) {
|
||||
ekprintf("sysfs_mkdirf(%p,%s,...): %d\n", dirhp, fmt, error);
|
||||
@ -229,7 +229,7 @@ sysfs_symlinkf(sysfs_handle_t targeth, const char *fmt, ...)
|
||||
|
||||
dkprintf("sysfs_symlinkf(%#lx,%s,...)\n", targeth.handle, fmt);
|
||||
|
||||
param = allocate_pages(1, IHK_MC_AP_NOWAIT);
|
||||
param = ihk_mc_alloc_pages(1, IHK_MC_AP_NOWAIT);
|
||||
if (!param) {
|
||||
error = -ENOMEM;
|
||||
ekprintf("sysfs_symlinkf:allocate_pages failed. %d\n", error);
|
||||
@ -279,7 +279,7 @@ sysfs_symlinkf(sysfs_handle_t targeth, const char *fmt, ...)
|
||||
error = 0;
|
||||
out:
|
||||
if (param) {
|
||||
free_pages(param, 1);
|
||||
ihk_mc_free_pages(param, 1);
|
||||
}
|
||||
if (error) {
|
||||
ekprintf("sysfs_symlinkf(%#lx,%s,...): %d\n",
|
||||
@ -301,7 +301,7 @@ sysfs_lookupf(sysfs_handle_t *objhp, const char *fmt, ...)
|
||||
|
||||
dkprintf("sysfs_lookupf(%p,%s,...)\n", objhp, fmt);
|
||||
|
||||
param = allocate_pages(1, IHK_MC_AP_NOWAIT);
|
||||
param = ihk_mc_alloc_pages(1, IHK_MC_AP_NOWAIT);
|
||||
if (!param) {
|
||||
error = -ENOMEM;
|
||||
ekprintf("sysfs_lookupf:allocate_pages failed. %d\n", error);
|
||||
@ -353,7 +353,7 @@ sysfs_lookupf(sysfs_handle_t *objhp, const char *fmt, ...)
|
||||
|
||||
out:
|
||||
if (param) {
|
||||
free_pages(param, 1);
|
||||
ihk_mc_free_pages(param, 1);
|
||||
}
|
||||
if (error) {
|
||||
ekprintf("sysfs_lookupf(%p,%s,...): %d\n", objhp, fmt, error);
|
||||
@ -374,7 +374,7 @@ sysfs_unlinkf(int flags, const char *fmt, ...)
|
||||
|
||||
dkprintf("sysfs_unlinkf(%#x,%s,...)\n", flags, fmt);
|
||||
|
||||
param = allocate_pages(1, IHK_MC_AP_NOWAIT);
|
||||
param = ihk_mc_alloc_pages(1, IHK_MC_AP_NOWAIT);
|
||||
if (!param) {
|
||||
error = -ENOMEM;
|
||||
ekprintf("sysfs_unlinkf:allocate_pages failed. %d\n", error);
|
||||
@ -423,7 +423,7 @@ sysfs_unlinkf(int flags, const char *fmt, ...)
|
||||
error = 0;
|
||||
out:
|
||||
if (param) {
|
||||
free_pages(param, 1);
|
||||
ihk_mc_free_pages(param, 1);
|
||||
}
|
||||
if (error) {
|
||||
ekprintf("sysfs_unlinkf(%#x,%s,...): %d\n", flags, fmt, error);
|
||||
@ -601,14 +601,14 @@ sysfs_init(void)
|
||||
}
|
||||
|
||||
sysfs_data_bufsize = PAGE_SIZE;
|
||||
sysfs_data_buf = allocate_pages(1, IHK_MC_AP_NOWAIT);
|
||||
sysfs_data_buf = ihk_mc_alloc_pages(1, IHK_MC_AP_NOWAIT);
|
||||
if (!sysfs_data_buf) {
|
||||
error = -ENOMEM;
|
||||
ekprintf("sysfs_init:allocate_pages(buf) failed. %d\n", error);
|
||||
goto out;
|
||||
}
|
||||
|
||||
param = allocate_pages(1, IHK_MC_AP_NOWAIT);
|
||||
param = ihk_mc_alloc_pages(1, IHK_MC_AP_NOWAIT);
|
||||
if (!param) {
|
||||
error = -ENOMEM;
|
||||
ekprintf("sysfs_init:allocate_pages(param) failed. %d\n",
|
||||
@ -644,7 +644,7 @@ sysfs_init(void)
|
||||
error = 0;
|
||||
out:
|
||||
if (param) {
|
||||
free_pages(param, 1);
|
||||
ihk_mc_free_pages(param, 1);
|
||||
}
|
||||
if (error) {
|
||||
ekprintf("sysfs_init(): %d\n", error);
|
||||
|
||||
Reference in New Issue
Block a user