From: Ma Wupeng mawupeng1@huawei.com
euleros inclusion category: feature bugzilla: https://gitee.com/openeuler/kernel/issues/I7WLVX
---------------------------------------------
Stop use gm_fault during alloc/free sinice they are not related to fault.
Signed-off-by: Ma Wupeng mawupeng1@huawei.com --- drivers/remote_pager/msg_handler_origin.c | 17 ++++++++--------- include/linux/gmem.h | 6 ++++-- mm/mmap.c | 16 ++-------------- 3 files changed, 14 insertions(+), 25 deletions(-)
diff --git a/drivers/remote_pager/msg_handler_origin.c b/drivers/remote_pager/msg_handler_origin.c index 25a772eef031..59801560fe55 100644 --- a/drivers/remote_pager/msg_handler_origin.c +++ b/drivers/remote_pager/msg_handler_origin.c @@ -207,18 +207,18 @@ gm_ret_t gmem_unmap(struct gm_fault_t *gmf) return GM_RET_SUCCESS; }
-gm_ret_t gmem_alloc(struct gm_fault_t *gmf) +gm_ret_t gmem_alloc(struct mm_struct *mm, unsigned long va, unsigned long size, + unsigned long prot) { int ret = 0; struct wait_station *ws; struct comm_msg_rsp *rsp; - struct mm_struct *mm = gmf->mm; struct svm_proc *proc = search_svm_proc_by_mm(mm); struct gm_pager_msg_rq req = { .peer_pid = proc->peer_pid, - .va = gmf->va, - .size = gmf->size, - .prot = gmf->prot, + .va = va, + .size = size, + .prot = prot, };
if (!proc) { @@ -243,17 +243,16 @@ gm_ret_t gmem_alloc(struct gm_fault_t *gmf) return GM_RET_SUCCESS; }
-gm_ret_t gmem_free(struct gm_fault_t *gmf) +gm_ret_t gmem_free(struct mm_struct *mm, unsigned long va, unsigned long size) { int ret = 0; struct wait_station *ws; struct comm_msg_rsp *rsp; - struct mm_struct *mm = gmf->mm; struct svm_proc *proc = search_svm_proc_by_mm(mm); struct gm_pager_msg_rq req = { .peer_pid = proc->peer_pid, - .va = gmf->va, - .size = gmf->size, + .va = va, + .size = size, };
if (!proc) { diff --git a/include/linux/gmem.h b/include/linux/gmem.h index 128d9c4d88fd..6fd4580166f6 100644 --- a/include/linux/gmem.h +++ b/include/linux/gmem.h @@ -133,8 +133,10 @@ struct gm_mmu { unsigned long cookie;
/* Synchronize VMA in a peer OS to interact with the host OS */ - gm_ret_t (*peer_va_alloc_fixed)(struct gm_fault_t *gmf); - gm_ret_t (*peer_va_free)(struct gm_fault_t *gmf); + gm_ret_t (*peer_va_alloc_fixed)(struct mm_struct *mm, unsigned long va, + unsigned long size, unsigned long prot); + gm_ret_t (*peer_va_free)(struct mm_struct *mm, unsigned long va, + unsigned long size);
/* Create physical mappings on peer host. * If copy is set, copy data [dma_addr, dma_addr + size] to peer host diff --git a/mm/mmap.c b/mm/mmap.c index a28b17c3cc83..91cad54a353f 100644 --- a/mm/mmap.c +++ b/mm/mmap.c @@ -2473,11 +2473,7 @@ static void munmap_in_peer_devices(struct mm_struct *mm, if (!ctx->dev->mmu->peer_va_free) continue;
- gmf.va = start; - gmf.size = end - start; - gmf.dev = ctx->dev; - - ret = ctx->dev->mmu->peer_va_free(&gmf); + ret = ctx->dev->mmu->peer_va_free(mm, start, end - start); if (ret != GM_RET_SUCCESS) pr_debug("gmem: free_vma(start:%lx, len:%lx) ret %d\n", start, end - start, ret); @@ -2733,12 +2729,6 @@ static int alloc_va_in_peer_devices(struct mm_struct *mm, { gm_context_t *ctx, *tmp; gm_ret_t ret; - struct gm_fault_t gmf = { - .mm = mm, - .va = addr, - .size = len, - .prot = vm_flags, - };
pr_debug("gmem: start mmap, as %p\n", mm->gm_as); if (!mm->gm_as) @@ -2761,10 +2751,8 @@ static int alloc_va_in_peer_devices(struct mm_struct *mm, continue; }
- gmf.dev = ctx->dev; - pr_debug("gmem: call vma_alloc\n"); - ret = ctx->dev->mmu->peer_va_alloc_fixed(&gmf); + ret = ctx->dev->mmu->peer_va_alloc_fixed(mm, addr, len, vm_flags); if (ret != GM_RET_SUCCESS) { pr_debug("gmem: alloc_vma ret %d\n", ret); return ret;