Skip to contentSkip to conversation

drm/ttm: Don't add swapped BOs to swap-LRU list

PATCH In review Felix Kuehling 2 participants 2 messages Jan 18, 2018

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 drm/ttm: Don't add swapped BOs to swap-LRU list

A BO that's already swapped would be added back to the swap-LRU list for example if it validation failed under high memory pressure. This could later lead to swapping it out again and leaking previous swap storage.

This commit adds a condition to prevent that from happening.

---
 drivers/gpu/drm/ttm/ttm_bo.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/gpu/drm/ttm/ttm_bo.c +2 -1
index 97c3da6..7192473 100644
@@ -175,7 +175,8 @@ void ttm_bo_add_to_lru(struct ttm_buffer_object *bo)
 		list_add_tail(&bo->lru, &man->lru[bo->priority]);
 		kref_get(&bo->list_kref);
 
-		if (bo->ttm && !(bo->ttm->page_flags & TTM_PAGE_FLAG_SG)) {
+		if (bo->ttm && !(bo->ttm->page_flags & TTM_PAGE_FLAG_SG) &&
+		    !bo->ttm->swap_storage) {
 			list_add_tail(&bo->swap,
 				      &bo->glob->swap_lru[bo->priority]);
 			kref_get(&bo->list_kref);
Signature · 6 lines
2.7.4

_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
#1 lore raw

Am 18.01.2018 um 06:16 schrieb Felix Kuehling:

Quoted 17 lines

A BO that's already swapped would be added back to the swap-LRU list for example if it validation failed under high memory pressure. This could later lead to swapping it out again and leaking previous swap storage.

This commit adds a condition to prevent that from happening.

---
  drivers/gpu/drm/ttm/ttm_bo.c | 3 ++-
  1 file changed, 2 insertions(+), 1 deletion(-)
drivers/gpu/drm/ttm/ttm_bo.c +0 -0
index 97c3da6..7192473 100644

drivers/gpu/drm/ttm/ttm_bo.c void ttm_bo_add_to_lru(struct ttm_buffer_object *bo) · line 179

Quoted 6 lines
drivers/gpu/drm/ttm/ttm_bo.c +2 -1
@@ -175,7 +175,8 @@ void ttm_bo_add_to_lru(struct ttm_buffer_object *bo)
  		list_add_tail(&bo->lru, &man->lru[bo->priority]);
  		kref_get(&bo->list_kref);
 
-		if (bo->ttm && !(bo->ttm->page_flags & TTM_PAGE_FLAG_SG)) {
+		if (bo->ttm && !(bo->ttm->page_flags & TTM_PAGE_FLAG_SG) &&
+		    !bo->ttm->swap_storage) {

Good catch, but using ttm->swap_storage is the wrong indicator cause on some drivers that is always set to something IIRC.

You need to use ttm->page_flags & TTM_PAGE_FLAG_SWAPPED here.

Regards,
Christian.

drivers/gpu/drm/ttm/ttm_bo.c void ttm_bo_add_to_lru(struct ttm_buffer_object *bo) · line 182

Quoted 3 lines
drivers/gpu/drm/ttm/ttm_bo.c +0 -0
  			list_add_tail(&bo->swap,
  				      &bo->glob->swap_lru[bo->priority]);
  			kref_get(&bo->list_kref);

_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel