* [PATCH 1/2] drm/ttm: Don't add swapped BOs to swap-LRU list
@ 2018-01-18 16:56 Felix Kuehling
[not found] ` <1516294577-29078-1-git-send-email-Felix.Kuehling-5C7GfCeVMHo@public.gmane.org>
2018-01-18 18:09 ` [PATCH 1/2] drm/ttm: Don't add swapped BOs to swap-LRU list Christian König
0 siblings, 2 replies; 6+ messages in thread
From: Felix Kuehling @ 2018-01-18 16:56 UTC (permalink / raw)
To: amd-gfx, dri-devel, christian.koenig, Hongbo.He; +Cc: Felix Kuehling
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
Signed-off-by: Felix Kuehling <Felix.Kuehling@amd.com>
---
drivers/gpu/drm/ttm/ttm_bo.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/drivers/gpu/drm/ttm/ttm_bo.c b/drivers/gpu/drm/ttm/ttm_bo.c
index 2eb71ff..62518b6 100644
--- a/drivers/gpu/drm/ttm/ttm_bo.c
+++ b/drivers/gpu/drm/ttm/ttm_bo.c
@@ -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);
--
2.7.4
_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel
^ permalink raw reply related [flat|nested] 6+ messages in thread
* [PATCH 2/2] drm/ttm: Don't unreserve swapped BOs that were previously reserved
[not found] ` <1516294577-29078-1-git-send-email-Felix.Kuehling-5C7GfCeVMHo@public.gmane.org>
@ 2018-01-18 16:56 ` Felix Kuehling
2018-01-19 3:19 ` He, Roger
0 siblings, 1 reply; 6+ messages in thread
From: Felix Kuehling @ 2018-01-18 16:56 UTC (permalink / raw)
To: amd-gfx-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW,
dri-devel-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW,
christian.koenig-5C7GfCeVMHo, Hongbo.He-5C7GfCeVMHo
Cc: Felix Kuehling
If ttm_bo_swapout doesn't own the lock, don't release it. Someone
else probably depends on it still being locked.
Signed-off-by: Felix Kuehling <Felix.Kuehling@amd.com>
---
drivers/gpu/drm/ttm/ttm_bo.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/drivers/gpu/drm/ttm/ttm_bo.c b/drivers/gpu/drm/ttm/ttm_bo.c
index 62518b6..893003f 100644
--- a/drivers/gpu/drm/ttm/ttm_bo.c
+++ b/drivers/gpu/drm/ttm/ttm_bo.c
@@ -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
_______________________________________________
amd-gfx mailing list
amd-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/amd-gfx
^ permalink raw reply related [flat|nested] 6+ messages in thread
* Re: [PATCH 1/2] drm/ttm: Don't add swapped BOs to swap-LRU list
2018-01-18 16:56 [PATCH 1/2] drm/ttm: Don't add swapped BOs to swap-LRU list Felix Kuehling
[not found] ` <1516294577-29078-1-git-send-email-Felix.Kuehling-5C7GfCeVMHo@public.gmane.org>
@ 2018-01-18 18:09 ` Christian König
2018-01-18 21:12 ` Felix Kuehling
1 sibling, 1 reply; 6+ messages in thread
From: Christian König @ 2018-01-18 18:09 UTC (permalink / raw)
To: Felix Kuehling, amd-gfx, dri-devel, christian.koenig, Hongbo.He
Am 18.01.2018 um 17:56 schrieb Felix Kuehling:
> 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
>
> Signed-off-by: Felix Kuehling <Felix.Kuehling@amd.com>
Reviewed-by: Christian König <christian.koenig@amd.com> for both.
> ---
> drivers/gpu/drm/ttm/ttm_bo.c | 3 ++-
> 1 file changed, 2 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/gpu/drm/ttm/ttm_bo.c b/drivers/gpu/drm/ttm/ttm_bo.c
> index 2eb71ff..62518b6 100644
> --- a/drivers/gpu/drm/ttm/ttm_bo.c
> +++ b/drivers/gpu/drm/ttm/ttm_bo.c
> @@ -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
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH 1/2] drm/ttm: Don't add swapped BOs to swap-LRU list
2018-01-18 18:09 ` [PATCH 1/2] drm/ttm: Don't add swapped BOs to swap-LRU list Christian König
@ 2018-01-18 21:12 ` Felix Kuehling
[not found] ` <117acb40-1cc5-9ea0-0e64-5db554c8cf9b-5C7GfCeVMHo@public.gmane.org>
0 siblings, 1 reply; 6+ messages in thread
From: Felix Kuehling @ 2018-01-18 21:12 UTC (permalink / raw)
To: christian.koenig, amd-gfx, dri-devel, Hongbo.He, Deucher, Alexander
On 2018-01-18 01:09 PM, Christian König wrote:
> Am 18.01.2018 um 17:56 schrieb Felix Kuehling:
>> 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
>>
>> Signed-off-by: Felix Kuehling <Felix.Kuehling@amd.com>
>
> Reviewed-by: Christian König <christian.koenig@amd.com> for both.
Thanks. I pushed them to amd-staging-drm-next. I think patch 1 should
also go to -fixes. Alex?
Regards,
Felix
>
>> ---
>> drivers/gpu/drm/ttm/ttm_bo.c | 3 ++-
>> 1 file changed, 2 insertions(+), 1 deletion(-)
>>
>> diff --git a/drivers/gpu/drm/ttm/ttm_bo.c b/drivers/gpu/drm/ttm/ttm_bo.c
>> index 2eb71ff..62518b6 100644
>> --- a/drivers/gpu/drm/ttm/ttm_bo.c
>> +++ b/drivers/gpu/drm/ttm/ttm_bo.c
>> @@ -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
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH 1/2] drm/ttm: Don't add swapped BOs to swap-LRU list
[not found] ` <117acb40-1cc5-9ea0-0e64-5db554c8cf9b-5C7GfCeVMHo@public.gmane.org>
@ 2018-01-18 21:15 ` Deucher, Alexander
0 siblings, 0 replies; 6+ messages in thread
From: Deucher, Alexander @ 2018-01-18 21:15 UTC (permalink / raw)
To: Kuehling, Felix, Koenig, Christian,
amd-gfx-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW,
dri-devel-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW, He, Roger
[-- Attachment #1.1: Type: text/plain, Size: 1975 bytes --]
________________________________
From: Kuehling, Felix
Sent: Thursday, January 18, 2018 4:12 PM
To: Koenig, Christian; amd-gfx-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW@public.gmane.org; dri-devel-PD4FTy7X32mMSPqsTGOZug@public.gmane.orgesktop.org; He, Roger; Deucher, Alexander
Subject: Re: [PATCH 1/2] drm/ttm: Don't add swapped BOs to swap-LRU list
On 2018-01-18 01:09 PM, Christian König wrote:
> Am 18.01.2018 um 17:56 schrieb Felix Kuehling:
>> 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
>>
>> Signed-off-by: Felix Kuehling <Felix.Kuehling-5C7GfCeVMHo@public.gmane.org>
>
> Reviewed-by: Christian König <christian.koenig-5C7GfCeVMHo@public.gmane.org> 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
>
>> ---
>> drivers/gpu/drm/ttm/ttm_bo.c | 3 ++-
>> 1 file changed, 2 insertions(+), 1 deletion(-)
>>
>> diff --git a/drivers/gpu/drm/ttm/ttm_bo.c b/drivers/gpu/drm/ttm/ttm_bo.c
>> index 2eb71ff..62518b6 100644
>> --- a/drivers/gpu/drm/ttm/ttm_bo.c
>> +++ b/drivers/gpu/drm/ttm/ttm_bo.c
>> @@ -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);
>
[-- Attachment #1.2: Type: text/html, Size: 4064 bytes --]
[-- Attachment #2: Type: text/plain, Size: 154 bytes --]
_______________________________________________
amd-gfx mailing list
amd-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/amd-gfx
^ permalink raw reply [flat|nested] 6+ messages in thread
* RE: [PATCH 2/2] drm/ttm: Don't unreserve swapped BOs that were previously reserved
2018-01-18 16:56 ` [PATCH 2/2] drm/ttm: Don't unreserve swapped BOs that were previously reserved Felix Kuehling
@ 2018-01-19 3:19 ` He, Roger
0 siblings, 0 replies; 6+ messages in thread
From: He, Roger @ 2018-01-19 3:19 UTC (permalink / raw)
To: Kuehling, Felix, amd-gfx, dri-devel, Koenig, Christian
good catch!
Thanks
Roger(Hongbo.He)
-----Original Message-----
From: Kuehling, Felix
Sent: Friday, January 19, 2018 12:56 AM
To: amd-gfx@lists.freedesktop.org; dri-devel@lists.freedesktop.org; Koenig, Christian <Christian.Koenig@amd.com>; He, Roger <Hongbo.He@amd.com>
Cc: Kuehling, Felix <Felix.Kuehling@amd.com>
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.
Signed-off-by: Felix Kuehling <Felix.Kuehling@amd.com>
---
drivers/gpu/drm/ttm/ttm_bo.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/drivers/gpu/drm/ttm/ttm_bo.c b/drivers/gpu/drm/ttm/ttm_bo.c index 62518b6..893003f 100644
--- a/drivers/gpu/drm/ttm/ttm_bo.c
+++ b/drivers/gpu/drm/ttm/ttm_bo.c
@@ -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
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2018-01-19 3:19 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-01-18 16:56 [PATCH 1/2] drm/ttm: Don't add swapped BOs to swap-LRU list Felix Kuehling
[not found] ` <1516294577-29078-1-git-send-email-Felix.Kuehling-5C7GfCeVMHo@public.gmane.org>
2018-01-18 16:56 ` [PATCH 2/2] drm/ttm: Don't unreserve swapped BOs that were previously reserved Felix Kuehling
2018-01-19 3:19 ` He, Roger
2018-01-18 18:09 ` [PATCH 1/2] drm/ttm: Don't add swapped BOs to swap-LRU list Christian König
2018-01-18 21:12 ` Felix Kuehling
[not found] ` <117acb40-1cc5-9ea0-0e64-5db554c8cf9b-5C7GfCeVMHo@public.gmane.org>
2018-01-18 21:15 ` Deucher, Alexander
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.