Commit 1ec39923 authored by Christian König's avatar Christian König

drm/ttm: rework BO delayed delete. v2

This patch reworks the whole delayed deletion of BOs which aren't idle.

Instead of having two counters for the BO structure we resurrect the BO
when we find that a deleted BO is not idle yet.

This has many advantages, especially that we don't need to
increment/decrement the BOs reference counter any more when it
moves on the LRUs.

v2: remove duplicate ttm_tt_destroy, fix holde lock for LRU move
Signed-off-by: default avatarChristian König <christian.koenig@amd.com>
Reviewed-by: default avatarxinhui pan <xinhui.pan@amd.com>
Link: https://patchwork.freedesktop.org/patch/352912/
parent b1df3a2b
This diff is collapsed.
...@@ -507,7 +507,6 @@ static int ttm_buffer_object_transfer(struct ttm_buffer_object *bo, ...@@ -507,7 +507,6 @@ static int ttm_buffer_object_transfer(struct ttm_buffer_object *bo,
fbo->base.moving = NULL; fbo->base.moving = NULL;
drm_vma_node_reset(&fbo->base.base.vma_node); drm_vma_node_reset(&fbo->base.base.vma_node);
kref_init(&fbo->base.list_kref);
kref_init(&fbo->base.kref); kref_init(&fbo->base.kref);
fbo->base.destroy = &ttm_transfered_destroy; fbo->base.destroy = &ttm_transfered_destroy;
fbo->base.acc_size = 0; fbo->base.acc_size = 0;
......
...@@ -135,18 +135,14 @@ struct ttm_tt; ...@@ -135,18 +135,14 @@ struct ttm_tt;
* @num_pages: Actual number of pages. * @num_pages: Actual number of pages.
* @acc_size: Accounted size for this object. * @acc_size: Accounted size for this object.
* @kref: Reference count of this buffer object. When this refcount reaches * @kref: Reference count of this buffer object. When this refcount reaches
* zero, the object is put on the delayed delete list. * zero, the object is destroyed or put on the delayed delete list.
* @list_kref: List reference count of this buffer object. This member is
* used to avoid destruction while the buffer object is still on a list.
* Lru lists may keep one refcount, the delayed delete list, and kref != 0
* keeps one refcount. When this refcount reaches zero,
* the object is destroyed.
* @mem: structure describing current placement. * @mem: structure describing current placement.
* @persistent_swap_storage: Usually the swap storage is deleted for buffers * @persistent_swap_storage: Usually the swap storage is deleted for buffers
* pinned in physical memory. If this behaviour is not desired, this member * pinned in physical memory. If this behaviour is not desired, this member
* holds a pointer to a persistent shmem object. * holds a pointer to a persistent shmem object.
* @ttm: TTM structure holding system pages. * @ttm: TTM structure holding system pages.
* @evicted: Whether the object was evicted without user-space knowing. * @evicted: Whether the object was evicted without user-space knowing.
* @deleted: True if the object is only a zombie and already deleted.
* @lru: List head for the lru list. * @lru: List head for the lru list.
* @ddestroy: List head for the delayed destroy list. * @ddestroy: List head for the delayed destroy list.
* @swap: List head for swap LRU list. * @swap: List head for swap LRU list.
...@@ -183,9 +179,7 @@ struct ttm_buffer_object { ...@@ -183,9 +179,7 @@ struct ttm_buffer_object {
/** /**
* Members not needing protection. * Members not needing protection.
*/ */
struct kref kref; struct kref kref;
struct kref list_kref;
/** /**
* Members protected by the bo::resv::reserved lock. * Members protected by the bo::resv::reserved lock.
...@@ -195,6 +189,7 @@ struct ttm_buffer_object { ...@@ -195,6 +189,7 @@ struct ttm_buffer_object {
struct file *persistent_swap_storage; struct file *persistent_swap_storage;
struct ttm_tt *ttm; struct ttm_tt *ttm;
bool evicted; bool evicted;
bool deleted;
/** /**
* Members protected by the bdev::lru_lock. * Members protected by the bdev::lru_lock.
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment