From: zhoucm1 <zhoucm1-5C7GfCeVMHo@public.gmane.org>
To: "Christian König"
<ckoenig.leichtzumerken-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>,
amd-gfx-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW@public.gmane.org
Subject: Re: [PATCH 6/6] drm/amdgpu: move VM BOs on LRU again
Date: Fri, 18 May 2018 14:49:36 +0800 [thread overview]
Message-ID: <353a585e-1cbb-4e56-c41b-bb82cbfa461d@amd.com> (raw)
In-Reply-To: <20180517094936.4293-6-christian.koenig-5C7GfCeVMHo@public.gmane.org>
CPU overhead is increased a bit, but we can optimize it later, the
series is Reviewed-by: Chunming Zhou <david1.zhou@amd.com>
On 2018年05月17日 17:49, Christian König wrote:
> Move all BOs belonging to a VM on the LRU with every submission.
>
> Signed-off-by: Christian König <christian.koenig@amd.com>
> ---
> drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c | 28 +++++++++++++++++++++++-----
> drivers/gpu/drm/amd/amdgpu/amdgpu_vm.h | 3 +++
> 2 files changed, 26 insertions(+), 5 deletions(-)
>
> diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c
> index f5dee4c6757c..ccba88cc8c54 100644
> --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c
> +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c
> @@ -251,6 +251,19 @@ int amdgpu_vm_validate_pt_bos(struct amdgpu_device *adev, struct amdgpu_vm *vm,
> }
> }
>
> + spin_lock(&glob->lru_lock);
> + list_for_each_entry(bo_base, &vm->idle, vm_status) {
> + struct amdgpu_bo *bo = bo_base->bo;
> +
> + if (!bo->parent)
> + continue;
> +
> + ttm_bo_move_to_lru_tail(&bo->tbo);
> + if (bo->shadow)
> + ttm_bo_move_to_lru_tail(&bo->shadow->tbo);
> + }
> + spin_unlock(&glob->lru_lock);
> +
> return r;
> }
>
> @@ -965,7 +978,7 @@ int amdgpu_vm_update_directories(struct amdgpu_device *adev,
> struct amdgpu_vm_bo_base,
> vm_status);
> bo_base->moved = false;
> - list_del_init(&bo_base->vm_status);
> + list_move(&bo_base->vm_status, &vm->idle);
>
> bo = bo_base->bo->parent;
> if (!bo)
> @@ -1571,10 +1584,14 @@ int amdgpu_vm_bo_update(struct amdgpu_device *adev,
> * the evicted list so that it gets validated again on the
> * next command submission.
> */
> - if (bo && bo->tbo.resv == vm->root.base.bo->tbo.resv &&
> - !(bo->preferred_domains &
> - amdgpu_mem_type_to_domain(bo->tbo.mem.mem_type)))
> - list_add_tail(&bo_va->base.vm_status, &vm->evicted);
> + if (bo && bo->tbo.resv == vm->root.base.bo->tbo.resv) {
> + uint32_t mem_type = bo->tbo.mem.mem_type;
> +
> + if (!(bo->preferred_domains & amdgpu_mem_type_to_domain(mem_type)))
> + list_add_tail(&bo_va->base.vm_status, &vm->evicted);
> + else
> + list_add(&bo_va->base.vm_status, &vm->idle);
> + }
>
> list_splice_init(&bo_va->invalids, &bo_va->valids);
> bo_va->cleared = clear;
> @@ -2368,6 +2385,7 @@ int amdgpu_vm_init(struct amdgpu_device *adev, struct amdgpu_vm *vm,
> INIT_LIST_HEAD(&vm->relocated);
> spin_lock_init(&vm->moved_lock);
> INIT_LIST_HEAD(&vm->moved);
> + INIT_LIST_HEAD(&vm->idle);
> INIT_LIST_HEAD(&vm->freed);
>
> /* create scheduler entity for page table updates */
> diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.h b/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.h
> index 0196b9a782f2..061b99a18cb8 100644
> --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.h
> +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.h
> @@ -178,6 +178,9 @@ struct amdgpu_vm {
> struct list_head moved;
> spinlock_t moved_lock;
>
> + /* All BOs of this VM not currently in the state machine */
> + struct list_head idle;
> +
> /* BO mappings freed, but not yet updated in the PT */
> struct list_head freed;
>
_______________________________________________
amd-gfx mailing list
amd-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/amd-gfx
next prev parent reply other threads:[~2018-05-18 6:49 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-05-17 9:49 [PATCH 1/6] drm/amdgpu: rework VM state machine lock handling v2 Christian König
[not found] ` <20180517094936.4293-1-christian.koenig-5C7GfCeVMHo@public.gmane.org>
2018-05-17 9:49 ` [PATCH 2/6] drm/amdgpu: cleanup amdgpu_vm_validate_pt_bos v2 Christian König
2018-05-17 9:49 ` [PATCH 3/6] drm/amdgpu: further optimize amdgpu_vm_handle_moved Christian König
2018-05-17 9:49 ` [PATCH 4/6] drm/amdgpu: kmap PDs/PTs in amdgpu_vm_update_directories Christian König
2018-05-17 9:49 ` [PATCH 5/6] drm/amdgpu: consistenly use VM moved flag Christian König
2018-05-17 9:49 ` [PATCH 6/6] drm/amdgpu: move VM BOs on LRU again Christian König
[not found] ` <20180517094936.4293-6-christian.koenig-5C7GfCeVMHo@public.gmane.org>
2018-05-18 6:49 ` zhoucm1 [this message]
2018-05-18 9:55 ` [PATCH 1/6] drm/amdgpu: rework VM state machine lock handling v2 Zhang, Jerry (Junwei)
[not found] ` <5AFEA313.8040905-5C7GfCeVMHo@public.gmane.org>
2018-05-19 8:00 ` Zhang, Jerry
[not found] ` <CY4PR12MB1414D3B8AE6ECEF5A9277A9AFF970-rpdhrqHFk04b0eJBKAp/BwdYzm3356FpvxpqHgZTriW3zl9H0oFU5g@public.gmane.org>
2018-05-22 13:07 ` Christian König
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=353a585e-1cbb-4e56-c41b-bb82cbfa461d@amd.com \
--to=zhoucm1-5c7gfcevmho@public.gmane.org \
--cc=amd-gfx-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW@public.gmane.org \
--cc=ckoenig.leichtzumerken-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox