drm/ttm: add ttm_bo_move_to_lru_tail function
Subsystems (4)
PATCH 1/3 drm/ttm: add ttm_bo_move_to_lru_tail function
From: Christian König <[email protected]>
This allows the drivers to move a BO to the end of the LRU without removing and adding it again.
--- drivers/gpu/drm/ttm/ttm_bo.c | 20 ++++++++++++++++++++ include/drm/ttm/ttm_bo_api.h | 10 ++++++++++ 2 files changed, 30 insertions(+)
drivers/gpu/drm/ttm/ttm_bo.c +20 -0
@@ -228,6 +228,26 @@ void ttm_bo_del_sub_from_lru(struct ttm_buffer_object *bo) }EXPORT_SYMBOL (ttm_bo_del_sub_from_lru); +void ttm_bo_move_to_lru_tail (struct ttm_buffer_object *bo) +{ +struct ttm_bo_device *bdev = bo->bdev; +struct ttm_mem_type_manager *man; + +lockdep_assert_held (&bo->resv->lock.base); + +if (!list_empty (&bo->swap)) { +list_del (&bo->swap); +list_add_tail (&bo->swap, &bo->glob->swap_lru); + } + +if (!list_empty (&bo->lru)) { + man = &bdev->man[bo->mem.mem_type]; +list_del (&bo->lru); +list_add_tail (&bo->lru, &man->lru); + } +} +EXPORT_SYMBOL (ttm_bo_move_to_lru_tail); +/* * Call bo->mutex locked. */
include/drm/ttm/ttm_bo_api.h +10 -0
@@ -383,6 +383,16 @@ extern void ttm_bo_add_to_lru(struct ttm_buffer_object *bo);*/ extern int ttm_bo_del_from_lru (struct ttm_buffer_object *bo); +/** +* ttm_bo_move_to_lru_tail +* +* @bo: The buffer object. +* +* Move this BO to the tail of all lru lists used to lookup and reserve an +* object. This function must be called with struct ttm_bo_global::lru_lock +* held, and is used to make a BO less likely to be considered for eviction. +*/ +extern void ttm_bo_move_to_lru_tail (struct ttm_buffer_object *bo);/** * ttm_bo_lock_delayed_workqueue
Signature · 6 lines
2.5.0 _______________________________________________ dri-devel mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/dri-devel
PATCH 2/3 drm/amdgpu: move VM page tables to the LRU end on CS
From: Christian König <[email protected]>
This makes it less likely to run into an ENOMEM because VM page tables are evicted last.
--- drivers/gpu/drm/amd/amdgpu/amdgpu.h | 3 ++- drivers/gpu/drm/amd/amdgpu/amdgpu_cs.c | 2 +- drivers/gpu/drm/amd/amdgpu/amdgpu_gem.c | 2 +- drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c | 10 ++++++++-- 4 files changed, 12 insertions(+), 5 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu.h +2 -1
@@ -987,7 +987,8 @@ void amdgpu_vm_fini(struct amdgpu_device *adev, struct amdgpu_vm *vm);void amdgpu_vm_get_pd_bo (struct amdgpu_vm *vm,struct list_head *validated,struct amdgpu_bo_list_entry *entry); -void amdgpu_vm_get_pt_bos (struct amdgpu_vm *vm,struct list_head *duplicates); +void amdgpu_vm_get_pt_bos (struct amdgpu_device *adev,struct amdgpu_vm *vm, +struct list_head *duplicates);int amdgpu_vm_grab_id (struct amdgpu_vm *vm,struct amdgpu_ring *ring,struct amdgpu_sync *sync); void amdgpu_vm_flush(struct amdgpu_ring *ring,
drivers/gpu/drm/amd/amdgpu/amdgpu_cs.c +1 -1
@@ -419,7 +419,7 @@ static int amdgpu_cs_parser_relocs(struct amdgpu_cs_parser *p)if (unlikely (r !=0 )) goto error_reserve; -amdgpu_vm_get_pt_bos (&fpriv->vm, &duplicates); +amdgpu_vm_get_pt_bos (p->adev, &fpriv->vm, &duplicates); r =amdgpu_cs_list_validate (p->adev, &fpriv->vm, &p->validated);if (r)
drivers/gpu/drm/amd/amdgpu/amdgpu_gem.c +1 -1
@@ -467,7 +467,7 @@ static void amdgpu_gem_va_update_vm(struct amdgpu_device *adev,if (r) goto error_print; -amdgpu_vm_get_pt_bos (bo_va->vm, &duplicates); +amdgpu_vm_get_pt_bos (adev, bo_va->vm, &duplicates);list_for_each_entry (entry, &list, head) { domain =amdgpu_mem_type_to_domain (entry->bo->mem.mem_type);/* if anything is swapped out don't swap it in here,
drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c +8 -2
@@ -106,19 +106,25 @@ void amdgpu_vm_get_pd_bo(struct amdgpu_vm *vm,* Add the page directory to the BO duplicates list * for command submission. */ -void amdgpu_vm_get_pt_bos (struct amdgpu_vm *vm,struct list_head *duplicates) +void amdgpu_vm_get_pt_bos (struct amdgpu_device *adev,struct amdgpu_vm *vm, +struct list_head *duplicates) { +struct ttm_bo_global *glob = adev->mman.bdev.glob;unsigned i; -/* add the vm page table to the list */ +/* add the vm page table to the list and move them to the LRU tail */ +spin_lock (&glob->lru_lock);for (i =0 ; i <= vm->max_pde_used; ++i) {struct amdgpu_bo_list_entry *entry = &vm->page_tables[i].entry;if (!entry->robj)continue ; +ttm_bo_move_to_lru_tail (&entry->robj->tbo);list_add (&entry->tv.head, duplicates); } + +spin_unlock (&glob->lru_lock); }/**
Signature · 6 lines
2.5.0 _______________________________________________ dri-devel mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/dri-devel
PATCH 3/3 drm/amdgpu: validate duplicates first
In reply to Christian KönigFrom: Christian König <[email protected]>
Most VM BOs end up in the duplicates list, validate it first make -ENOMEM less likely.
--- drivers/gpu/drm/amd/amdgpu/amdgpu_cs.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_cs.c +2 -2
@@ -421,11 +421,11 @@ static int amdgpu_cs_parser_relocs(struct amdgpu_cs_parser *p)amdgpu_vm_get_pt_bos (p->adev, &fpriv->vm, &duplicates); - r =amdgpu_cs_list_validate (p->adev, &fpriv->vm, &p->validated); + r =amdgpu_cs_list_validate (p->adev, &fpriv->vm, &duplicates);if (r) goto error_validate; - r =amdgpu_cs_list_validate (p->adev, &fpriv->vm, &duplicates); + r =amdgpu_cs_list_validate (p->adev, &fpriv->vm, &p->validated); error_validate:if (r)
Signature · 6 lines
2.5.0 _______________________________________________ dri-devel mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/dri-devel
Quoted 7 lines · Christian König
From: Christian König <[email protected]>
This allows the drivers to move a BO to the end of the LRU without removing and adding it again.
Signed-off-by Christian König <[email protected]>Reviewed-by Chunming Zhou <[email protected]>
This series is:
Unless there are any objections to the ttm patch, I'd like to pull this series into my drm-next tree.
Alex
Quoted 60 lines
--- drivers/gpu/drm/ttm/ttm_bo.c | 20 ++++++++++++++++++++ include/drm/ttm/ttm_bo_api.h | 10 ++++++++++ 2 files changed, 30 insertions(+)drivers/gpu/drm/ttm/ttm_bo.c +20
-0@@ -228,6 +228,26 @@ void ttm_bo_del_sub_from_lru(struct ttm_buffer_object *bo) }EXPORT_SYMBOL (ttm_bo_del_sub_from_lru); +void ttm_bo_move_to_lru_tail (struct ttm_buffer_object *bo) +{ +struct ttm_bo_device *bdev = bo->bdev; +struct ttm_mem_type_manager *man; + +lockdep_assert_held (&bo->resv->lock.base); + +if (!list_empty (&bo->swap)) { +list_del (&bo->swap); +list_add_tail (&bo->swap, &bo->glob->swap_lru); + } + +if (!list_empty (&bo->lru)) { + man = &bdev->man[bo->mem.mem_type]; +list_del (&bo->lru); +list_add_tail (&bo->lru, &man->lru); + } +} +EXPORT_SYMBOL (ttm_bo_move_to_lru_tail); +/* * Call bo->mutex locked. */ include/drm/ttm/ttm_bo_api.h +10
-1@@ -383,6 +383,16 @@ extern void ttm_bo_add_to_lru(struct ttm_buffer_object *bo);*/ extern int ttm_bo_del_from_lru (struct ttm_buffer_object *bo); +/** +* ttm_bo_move_to_lru_tail +* +* @bo: The buffer object. +* +* Move this BO to the tail of all lru lists used to lookup and reserve an +* object. This function must be called with struct ttm_bo_global::lru_lock +* held, and is used to make a BO less likely to be considered for eviction. +*/ +extern void ttm_bo_move_to_lru_tail (struct ttm_buffer_object *bo);/** * ttm_bo_lock_delayed_workqueue -- 2.5.0
Quoted 4 lines
_______________________________________________
dri-devel mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/dri-devel
_______________________________________________
dri-devel mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/dri-devel
Am 05.01.2016 um 22:34 schrieb Alex Deucher:
Quoted 6 lines · Christian König
Quoted 5 lines
From: Christian König <[email protected]>
This allows the drivers to move a BO to the end of the LRU without removing and adding it again.
Quoted 7 lines
Quoted 2 lines
Signed-off-by Christian König <[email protected]>Reviewed-by Chunming Zhou <[email protected]>This series is:
Reviewed-by Alex Deucher <[email protected]>Unless there are any objections to the ttm patch, I'd like to pull this series into my drm-next tree.
I have objections!
Ok seriously, David and I have found quite a bug around that in TTM. We need to fix that before we can push this patch.
Christian.
Quoted 63 lines
Alex
Quoted 60 lines
--- drivers/gpu/drm/ttm/ttm_bo.c | 20 ++++++++++++++++++++ include/drm/ttm/ttm_bo_api.h | 10 ++++++++++ 2 files changed, 30 insertions(+)drivers/gpu/drm/ttm/ttm_bo.c +20
-0@@ -228,6 +228,26 @@ void ttm_bo_del_sub_from_lru(struct ttm_buffer_object *bo) }EXPORT_SYMBOL (ttm_bo_del_sub_from_lru); +void ttm_bo_move_to_lru_tail (struct ttm_buffer_object *bo) +{ +struct ttm_bo_device *bdev = bo->bdev; +struct ttm_mem_type_manager *man; + +lockdep_assert_held (&bo->resv->lock.base); + +if (!list_empty (&bo->swap)) { +list_del (&bo->swap); +list_add_tail (&bo->swap, &bo->glob->swap_lru); + } + +if (!list_empty (&bo->lru)) { + man = &bdev->man[bo->mem.mem_type]; +list_del (&bo->lru); +list_add_tail (&bo->lru, &man->lru); + } +} +EXPORT_SYMBOL (ttm_bo_move_to_lru_tail); +/* * Call bo->mutex locked. */ include/drm/ttm/ttm_bo_api.h +10
-1@@ -383,6 +383,16 @@ extern void ttm_bo_add_to_lru(struct ttm_buffer_object *bo);*/ extern int ttm_bo_del_from_lru (struct ttm_buffer_object *bo); +/** +* ttm_bo_move_to_lru_tail +* +* @bo: The buffer object. +* +* Move this BO to the tail of all lru lists used to lookup and reserve an +* object. This function must be called with struct ttm_bo_global::lru_lock +* held, and is used to make a BO less likely to be considered for eviction. +*/ +extern void ttm_bo_move_to_lru_tail (struct ttm_buffer_object *bo);/** * ttm_bo_lock_delayed_workqueue -- 2.5.0
Quoted 4 lines
Quoted 4 lines
_______________________________________________
dri-devel mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/dri-devel
_______________________________________________
dri-devel mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/dri-devel
Quoted 16 lines · Christian König
Am 05.01.2016 um 22:34 schrieb Alex Deucher:
Quoted 15 lines
Quoted 8 lines · Christian König
From: Christian König <[email protected]>
This allows the drivers to move a BO to the end of the LRU without removing and adding it again.
Signed-off-by Christian König <[email protected]>Reviewed-by Chunming Zhou <[email protected]>This series is:
Reviewed-by Alex Deucher <[email protected]>
Quoted 8 lines
Quoted 2 lines
Unless there are any objections to the ttm patch, I'd like to pull this series into my drm-next tree.
I have objections!
Ok seriously, David and I have found quite a bug around that in TTM. We need to fix that before we can push this patch.
I've already included this in my most recent fixes pull request to Dave. Should I ask him not to pull and drop this set or is the other patch you just sent enough to fix it?
Thanks,
Alex
Quoted 72 lines
Christian.
Quoted 68 lines
Alex
Quoted 65 lines
--- drivers/gpu/drm/ttm/ttm_bo.c | 20 ++++++++++++++++++++ include/drm/ttm/ttm_bo_api.h | 10 ++++++++++ 2 files changed, 30 insertions(+)drivers/gpu/drm/ttm/ttm_bo.c +20
-0@@ -228,6 +228,26 @@ void ttm_bo_del_sub_from_lru(struct ttm_buffer_object *bo) }EXPORT_SYMBOL (ttm_bo_del_sub_from_lru); +void ttm_bo_move_to_lru_tail (struct ttm_buffer_object *bo) +{ +struct ttm_bo_device *bdev = bo->bdev; +struct ttm_mem_type_manager *man; + +lockdep_assert_held (&bo->resv->lock.base); + +if (!list_empty (&bo->swap)) { +list_del (&bo->swap); +list_add_tail (&bo->swap, &bo->glob->swap_lru); + } + +if (!list_empty (&bo->lru)) { + man = &bdev->man[bo->mem.mem_type]; +list_del (&bo->lru); +list_add_tail (&bo->lru, &man->lru); + } +} +EXPORT_SYMBOL (ttm_bo_move_to_lru_tail); +/* * Call bo->mutex locked. */include/drm/ttm/ttm_bo_api.h +6
-0@@ -383,6 +383,16 @@ extern void ttm_bo_add_to_lru(structttm_buffer_object *bo); */ extern int ttm_bo_del_from_lru (struct ttm_buffer_object *bo); +/** +* ttm_bo_move_to_lru_tail +* +* @bo: The buffer object. +* +* Move this BO to the tail of all lru lists used to lookup and reserve an
+ * object. This function must be called with structttm_bo_global::lru_lock
+ * held, and is used to make a BO less likely to be considered for eviction.
+ */
+extern voidttm_bo_move_to_lru_tail(struct ttm_buffer_object *bo);/**
*ttm_bo_lock_delayed_workqueue
--
2.5.0
Quoted 6 lines
Quoted 4 lines
Quoted 4 lines
_______________________________________________
dri-devel mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/dri-devel
_______________________________________________
dri-devel mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/dri-devel