From: zhoucm1 <zhoucm1-5C7GfCeVMHo@public.gmane.org>
To: "Christian König"
<ckoenig.leichtzumerken-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>,
dri-devel-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW@public.gmane.org
Cc: David1.Zhou-5C7GfCeVMHo@public.gmane.org,
amd-gfx-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW@public.gmane.org
Subject: Re: [PATCH] drm/ttm: stop always moving BOs on the LRU on page fault
Date: Mon, 14 Jan 2019 15:06:30 +0800 [thread overview]
Message-ID: <8246cd62-7be0-34cc-1bf3-e1c40f0265fb@amd.com> (raw)
In-Reply-To: <20190111131525.1269-1-christian.koenig-5C7GfCeVMHo@public.gmane.org>
On 2019年01月11日 21:15, Christian König wrote:
> Move the BO on the LRU only when it is actually moved by a DMA
> operation.
>
> Signed-off-by: Christian König <christian.koenig@amd.com>
Tested-And-Reviewed-by: Chunming Zhou <david1.zhou@amd.com>
I just sent lru_notify v2 patches, please review them. With yours and
mine, the OOM issue is fixed without negative effect.
-David
> ---
> drivers/gpu/drm/ttm/ttm_bo_vm.c | 19 ++++++++++++-------
> 1 file changed, 12 insertions(+), 7 deletions(-)
>
> diff --git a/drivers/gpu/drm/ttm/ttm_bo_vm.c b/drivers/gpu/drm/ttm/ttm_bo_vm.c
> index a1d977fbade5..e86a29a1e51f 100644
> --- a/drivers/gpu/drm/ttm/ttm_bo_vm.c
> +++ b/drivers/gpu/drm/ttm/ttm_bo_vm.c
> @@ -71,7 +71,7 @@ static vm_fault_t ttm_bo_vm_fault_idle(struct ttm_buffer_object *bo,
> ttm_bo_get(bo);
> up_read(&vmf->vma->vm_mm->mmap_sem);
> (void) dma_fence_wait(bo->moving, true);
> - ttm_bo_unreserve(bo);
> + reservation_object_unlock(bo->resv);
> ttm_bo_put(bo);
> goto out_unlock;
> }
> @@ -131,11 +131,7 @@ static vm_fault_t ttm_bo_vm_fault(struct vm_fault *vmf)
> * for reserve, and if it fails, retry the fault after waiting
> * for the buffer to become unreserved.
> */
> - err = ttm_bo_reserve(bo, true, true, NULL);
> - if (unlikely(err != 0)) {
> - if (err != -EBUSY)
> - return VM_FAULT_NOPAGE;
> -
> + if (unlikely(!reservation_object_trylock(bo->resv))) {
> if (vmf->flags & FAULT_FLAG_ALLOW_RETRY) {
> if (!(vmf->flags & FAULT_FLAG_RETRY_NOWAIT)) {
> ttm_bo_get(bo);
> @@ -165,6 +161,8 @@ static vm_fault_t ttm_bo_vm_fault(struct vm_fault *vmf)
> }
>
> if (bdev->driver->fault_reserve_notify) {
> + struct dma_fence *moving = dma_fence_get(bo->moving);
> +
> err = bdev->driver->fault_reserve_notify(bo);
> switch (err) {
> case 0:
> @@ -177,6 +175,13 @@ static vm_fault_t ttm_bo_vm_fault(struct vm_fault *vmf)
> ret = VM_FAULT_SIGBUS;
> goto out_unlock;
> }
> +
> + if (bo->moving != moving) {
> + spin_lock(&bdev->glob->lru_lock);
> + ttm_bo_move_to_lru_tail(bo, NULL);
> + spin_unlock(&bdev->glob->lru_lock);
> + }
> + dma_fence_put(moving);
> }
>
> /*
> @@ -291,7 +296,7 @@ static vm_fault_t ttm_bo_vm_fault(struct vm_fault *vmf)
> out_io_unlock:
> ttm_mem_io_unlock(man);
> out_unlock:
> - ttm_bo_unreserve(bo);
> + reservation_object_unlock(bo->resv);
> return ret;
> }
>
_______________________________________________
amd-gfx mailing list
amd-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/amd-gfx
prev parent reply other threads:[~2019-01-14 7:06 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-01-11 13:15 [PATCH] drm/ttm: stop always moving BOs on the LRU on page fault Christian König
2019-01-11 14:15 ` Michel Dänzer
[not found] ` <20190111131525.1269-1-christian.koenig-5C7GfCeVMHo@public.gmane.org>
2019-01-11 14:17 ` Michel Dänzer
[not found] ` <ed9615c4-99be-c690-6ea0-bbe3e107bab3-otUistvHUpPR7s880joybQ@public.gmane.org>
2019-01-11 19:12 ` Christian König
[not found] ` <810303e7-d1bd-1e04-4e73-33d8202b2a05-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
2019-01-14 16:27 ` Michel Dänzer
2019-01-14 7:06 ` zhoucm1 [this message]
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=8246cd62-7be0-34cc-1bf3-e1c40f0265fb@amd.com \
--to=zhoucm1-5c7gfcevmho@public.gmane.org \
--cc=David1.Zhou-5C7GfCeVMHo@public.gmane.org \
--cc=amd-gfx-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW@public.gmane.org \
--cc=ckoenig.leichtzumerken-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org \
--cc=dri-devel-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW@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