drm/ttm: stop always moving BOs on the LRU on page fault
Subsystems (3)
PATCH 1/1 drm/ttm: stop always moving BOs on the LRU on page fault
Move the BO on the LRU only when it is actually moved by a DMA operation.
--- drivers/gpu/drm/ttm/ttm_bo_vm.c | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-)
drivers/gpu/drm/ttm/ttm_bo_vm.c +12 -7
@@ -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; }
Signature · 6 lines
2.14.1 _______________________________________________ dri-devel mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/dri-devel
Quoted 4 lines · Christian König
Move the BO on the LRU only when it is actually moved by a DMA operation.
Signed-off-by Christian König <[email protected]>
Signature · 6 lines
Earthling Michel Dänzer | http://www.amd.com Libre software enthusiast | Mesa and X developer _______________________________________________ dri-devel mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/dri-devel
A message that is not in the archive (sent off-list or not yet received): 20190111131525.1269-1-christian.koenig-5C7GfCeVMHo@public.gmane.org
drivers/gpu/drm/ttm/ttm_bo_vm.c static vm_fault_t ttm_bo_vm_fault(struct vm_fault *vmf) · line 179
Quoted 11 lines · Christian König
Move the BO on the LRU only when it is actually moved by a DMA operation.
[...]
drivers/gpu/drm/ttm/ttm_bo_vm.c +2
-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) {
Hmm, could a driver just update the existing fence instead of attaching a new one?
Signature · 6 lines
Earthling Michel Dänzer | http://www.amd.com Libre software enthusiast | Mesa and X developer _______________________________________________ amd-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/amd-gfx
A message that is not in the archive (sent off-list or not yet received): ed9615c4-99be-c690-6ea0-bbe3e107bab3-otUistvHUpPR7s880joybQ@public.gmane.org
Am 11.01.19 um 15:17 schrieb Michel Dänzer:
Quoted 6 lines · Christian König
Quoted 5 lines
Move the BO on the LRU only when it is actually moved by a DMA operation.
[...]
Quoted 8 lines
drivers/gpu/drm/ttm/ttm_bo_vm.c static vm_fault_t ttm_bo_vm_fault(struct vm_fault *vmf) · line 179
Quoted 6 lines
drivers/gpu/drm/ttm/ttm_bo_vm.c +2
-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) {Hmm, could a driver just update the existing fence instead of attaching a new one?
Mhm, not as far as I know. That would violate similar checks elsewhere.
Christian.
_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx
A message that is not in the archive (sent off-list or not yet received): 810303e7-d1bd-1e04-4e73-33d8202b2a05-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org
Quoted 17 lines · Christian König
Am 11.01.19 um 15:17 schrieb Michel Dänzer:
Quoted 6 lines · Christian König
Quoted 5 lines
Move the BO on the LRU only when it is actually moved by a DMA operation.
[...]
Quoted 9 lines
drivers/gpu/drm/ttm/ttm_bo_vm.c static vm_fault_t ttm_bo_vm_fault(struct · line 180
Quoted 7 lines
drivers/gpu/drm/ttm/ttm_bo_vm.c +2
-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) {Hmm, could a driver just update the existing fence instead of attaching a new one?
Quoted 1 line
Mhm, not as far as I know. That would violate similar checks elsewhere.
Makes sense, my R-b stands.
Signature · 6 lines
Earthling Michel Dänzer | http://www.amd.com Libre software enthusiast | Mesa and X developer _______________________________________________ amd-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/amd-gfx
Quoted 4 lines · Christian König
Move the BO on the LRU only when it is actually moved by a DMA operation.
Signed-off-by Christian König <[email protected]>
I just sent lru_notify v2 patches, please review them. With yours and mine, the OOM issue is fixed without negative effect.
-David
Quoted 54 lines
--- drivers/gpu/drm/ttm/ttm_bo_vm.c | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-)drivers/gpu/drm/ttm/ttm_bo_vm.c +11
-6@@ -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); }/*
drivers/gpu/drm/ttm/ttm_bo_vm.c static vm_fault_t ttm_bo_vm_fault(struct vm_fault *vmf) · line 302
Quoted 8 lines
drivers/gpu/drm/ttm/ttm_bo_vm.c +1
-1@@ -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
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx