drm/ttm: Don't add swapped BOs to swap-LRU list
Subsystems (3)
PATCH 1/2 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 its 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.
v2: Check page_flags instead of swap_storage
--- drivers/gpu/drm/ttm/ttm_bo.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/gpu/drm/ttm/ttm_bo.c +2 -1
@@ -170,7 +170,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 |TTM_PAGE_FLAG_SWAPPED ))) {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
A message that is not in the archive (sent off-list or not yet received): 1516294577-29078-1-git-send-email-Felix.Kuehling-5C7GfCeVMHo@public.gmane.org
PATCH 2/2 drm/ttm: Don't unreserve swapped BOs that were previously reserved
If ttm_bo_swapout doesn't own the lock, don't release it. Someone else probably depends on it still being locked.
--- drivers/gpu/drm/ttm/ttm_bo.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/gpu/drm/ttm/ttm_bo.c +2 -2
@@ -1780,8 +1780,8 @@ int ttm_bo_swapout(struct ttm_bo_global *glob, struct ttm_operation_ctx *ctx)* Unreserve without putting on LRU to avoid swapping out an * already swapped buffer. */ - -reservation_object_unlock (bo->resv); +if (locked) +reservation_object_unlock (bo->resv);kref_put (&bo->list_kref, ttm_bo_release_list);return ret; }
Signature · 6 lines
2.7.4 _______________________________________________ amd-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/amd-gfx
RE: [PATCH 2/2] drm/ttm: Don't unreserve swapped BOs that were previously reserved
good catch!
Thanks
Roger(Hongbo.He)
-----Original Message-----
From: Kuehling, Felix
Sent: Friday, January 19, 2018 12:56 AM
To: [email protected]; [email protected]; Koenig, Christian <[email protected]>; He, Roger <[email protected]>
Cc: Kuehling, Felix <[email protected]>
Subject: [PATCH 2/2] drm/ttm: Don't unreserve swapped BOs that were previously reserved
If ttm_bo_swapout doesn't own the lock, don't release it. Someone else probably depends on it still being locked.
--- drivers/gpu/drm/ttm/ttm_bo.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/gpu/drm/ttm/ttm_bo.c +2 -2
@@ -1780,8 +1780,8 @@ int ttm_bo_swapout(struct ttm_bo_global *glob, struct ttm_operation_ctx *ctx)* Unreserve without putting on LRU to avoid swapping out an * already swapped buffer. */ - -reservation_object_unlock (bo->resv); +if (locked) +reservation_object_unlock (bo->resv);kref_put (&bo->list_kref, ttm_bo_release_list);return ret; }
--
2.7.4
_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
Am 18.01.2018 um 17:56 schrieb Felix Kuehling:
Quoted 10 lines
A BO that's already swapped would be added back to the swap-LRU list for example if its 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.
v2: Check
page_flagsinstead ofswap_storageSigned-off-by Felix Kuehling <[email protected]>
Quoted 9 lines
--- drivers/gpu/drm/ttm/ttm_bo.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)drivers/gpu/drm/ttm/ttm_bo.c +0
-0
drivers/gpu/drm/ttm/ttm_bo.c void ttm_bo_add_to_lru(struct ttm_buffer_object *bo) · line 177
Quoted 9 lines
drivers/gpu/drm/ttm/ttm_bo.c +2
-1@@ -170,7 +170,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 |TTM_PAGE_FLAG_SWAPPED ))) {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
Quoted 6 lines · Christian König
Am 18.01.2018 um 17:56 schrieb Felix Kuehling:
Quoted 5 lines
A BO that's already swapped would be added back to the swap-LRU list for example if its validation failed under high memory pressure. This could later lead to swapping it out again and leaking previous swap storage.
Quoted 7 lines
Quoted 5 lines
This commit adds a condition to prevent that from happening.
v2: Check
page_flagsinstead ofswap_storageSigned-off-by Felix Kuehling <[email protected]>Reviewed-by Christian König <[email protected]> for both.
Thanks. I pushed them to amd-staging-drm-next. I think patch 1 should also go to -fixes. Alex?
Regards,
Felix
Quoted 5 lines
Quoted 5 lines
---
drivers/gpu/drm/ttm/ttm_bo.c| 3 ++-1 file changed, 2 insertions(+), 1 deletion(-)
Quoted 14 lines
drivers/gpu/drm/ttm/ttm_bo.c void ttm_bo_add_to_lru(struct ttm_buffer_object *bo) · line 177
Quoted 13 lines
drivers/gpu/drm/ttm/ttm_bo.c +2
-0@@ -170,7 +170,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 | TTM_PAGE_FLAG_SWAPPED))) { 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
A message that is not in the archive (sent off-list or not yet received): 117acb40-1cc5-9ea0-0e64-5db554c8cf9b-5C7GfCeVMHo@public.gmane.org
________________________________
From: Kuehling, Felix
Sent: Thursday, January 18, 2018 4:12 PM
To: Koenig, Christian; [email protected]; [email protected]; He, Roger; Deucher, Alexander
Subject: Re: [PATCH 1/2] drm/ttm: Don't add swapped BOs to swap-LRU list
Quoted 6 lines · Christian König
Am 18.01.2018 um 17:56 schrieb Felix Kuehling:
Quoted 5 lines
A BO that's already swapped would be added back to the swap-LRU list for example if its validation failed under high memory pressure. This could later lead to swapping it out again and leaking previous swap storage.
Quoted 7 lines
Quoted 5 lines
This commit adds a condition to prevent that from happening.
v2: Check
page_flagsinstead ofswap_storageSigned-off-by Felix Kuehling <[email protected]>Reviewed-by Christian König <[email protected]> for both.
Thanks. I pushed them to amd-staging-drm-next. I think patch 1 should also go to -fixes. Alex?
Yup, already planning on it.
Alex
Regards,
Felix
Quoted 5 lines
Quoted 5 lines
--- drivers/gpu/drm/ttm/ttm_bo.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
Quoted 14 lines
drivers/gpu/drm/ttm/ttm_bo.c void ttm_bo_add_to_lru(struct ttm_buffer_object *bo) · line 177
Quoted 13 lines
drivers/gpu/drm/ttm/ttm_bo.c +2
-0@@ -170,7 +170,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 |TTM_PAGE_FLAG_SWAPPED ))) {list_add_tail (&bo->swap, &bo->glob->swap_lru[bo->priority]);kref_get (&bo->list_kref);
_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx