Skip to contentSkip to conversation

drm/ttm: return -EBUSY if waiting for busy BO fails

PATCH In review Kuehling, Felix 4 participants 4 messages Jun 26, 2019 3 messages not in the archive

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

PATCH 1/1 drm/ttm: return -EBUSY if waiting for busy BO fails

Returning -EAGAIN prevents ttm_bo_mem_space from trying alternate placements and can lead to live-locks in amdgpu_cs, retrying indefinitely and never succeeding.

Fixes cfcc52e477e4 ("drm/ttm: fix busy memory to fail other user v10")
CC Christian Koenig <[email protected]>
---
 drivers/gpu/drm/ttm/ttm_bo.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/gpu/drm/ttm/ttm_bo.c +1 -1
index c7de667d482a..58c403eda04e 100644
@@ -827,7 +827,7 @@ static int ttm_mem_evict_wait_busy(struct ttm_buffer_object *busy_bo,
 	if (!r)
 		reservation_object_unlock(busy_bo->resv);
 
-	return r == -EDEADLK ? -EAGAIN : r;
+	return r == -EDEADLK ? -EBUSY : r;
 }
 
 static int ttm_mem_evict_first(struct ttm_bo_device *bdev,
Signature · 6 lines
2.17.1

_______________________________________________
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): 20190626063958.19941-1-Felix.Kuehling-5C7GfCeVMHo@public.gmane.org

#2 lore raw

Am 26.06.19 um 08:40 schrieb Kuehling, Felix:

Quoted 7 lines

Returning -EAGAIN prevents ttm_bo_mem_space from trying alternate placements and can lead to live-locks in amdgpu_cs, retrying indefinitely and never succeeding.

Fixes cfcc52e477e4 ("drm/ttm: fix busy memory to fail other user v10")
CC Christian Koenig <[email protected]>

Crap, I feared that this could live-lock under some circumstances, but hoped that this would be a rather rare case.

How did you reproduce this?

Anyway patch is Reviewed-by: Christian König <[email protected]> for now.

Quoted 9 lines
---
  drivers/gpu/drm/ttm/ttm_bo.c | 2 +-
  1 file changed, 1 insertion(+), 1 deletion(-)
drivers/gpu/drm/ttm/ttm_bo.c +0 -0
index c7de667d482a..58c403eda04e 100644

drivers/gpu/drm/ttm/ttm_bo.c static int ttm_mem_evict_wait_busy(struct ttm_buffer_object *busy_bo, · line 833

Quoted 8 lines
drivers/gpu/drm/ttm/ttm_bo.c +1 -1
@@ -827,7 +827,7 @@ static int ttm_mem_evict_wait_busy(struct ttm_buffer_object *busy_bo,
  	if (!r)
  		reservation_object_unlock(busy_bo->resv);
 
-	return r == -EDEADLK ? -EAGAIN : r;
+	return r == -EDEADLK ? -EBUSY : r;
  }
 
  static int ttm_mem_evict_first(struct ttm_bo_device *bdev,

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

A message that is not in the archive (sent off-list or not yet received): 410e8232-4edc-78ea-dc5b-4385cda01266-5C7GfCeVMHo@public.gmane.org

#4 lore raw
Quoted 5 lines · Christian

Am 26.06.19 um 08:40 schrieb Kuehling, Felix:

Quoted 4 lines

Returning -EAGAIN prevents ttm_bo_mem_space from trying alternate placements and can lead to live-locks in amdgpu_cs, retrying indefinitely and never succeeding.

Quoted 7 lines
Quoted 3 lines
Fixes cfcc52e477e4 ("drm/ttm: fix busy memory to fail other user v10")
CC Christian Koenig <[email protected]>

Crap, I feared that this could live-lock under some circumstances, but hoped that this would be a rather rare case.

How did you reproduce this?

kfdtest --gtest_filter=KFDEvictTest.* --gtest_repeat=10

It runs two processes, both of which do graphics CS and KFD compute queues at the same time with enough memory pressure to cause frequent KFD evictions. It's meant to test KFD eviction code paths, but ended up finding a problem the graphics CS code path. :/

I was able to reproduce it right after your changes. With the latest version of the branch I can't reproduce it any more. Some other commit must have changed things enough to avoid the live lock.

I also tried writing a test that reproduced it only with amdgpu_cs calls (without KFD), but no luck yet.

Regards,
  Felix

Quoted 16 lines

Anyway patch is Reviewed-by: Christian König <[email protected]> for now.

Quoted 12 lines
---
   drivers/gpu/drm/ttm/ttm_bo.c | 2 +-
   1 file changed, 1 insertion(+), 1 deletion(-)
drivers/gpu/drm/ttm/ttm_bo.c +0 -0
index c7de667d482a..58c403eda04e 100644
@@ -827,7 +827,7 @@ static int ttm_mem_evict_wait_busy(struct ttm_buffer_object *busy_bo,
   	if (!r)
   		reservation_object_unlock(busy_bo->resv);
 
Quoted 5 lines

drivers/gpu/drm/ttm/ttm_bo.c static int ttm_mem_evict_wait_busy(struct ttm_buffer_object *busy_bo, · line 833

Quoted 5 lines
drivers/gpu/drm/ttm/ttm_bo.c +1 -1
-	return r == -EDEADLK ? -EAGAIN : r;
+	return r == -EDEADLK ? -EBUSY : r;
   }
 
   static int ttm_mem_evict_first(struct ttm_bo_device *bdev,

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

A message that is not in the archive (sent off-list or not yet received): 33c2b0f0-6747-1a36-117f-8e7fe12cbef0-5C7GfCeVMHo@public.gmane.org

#6 lore raw
Quoted 16 lines · Felix
Quoted 5 lines · Christian

Am 26.06.19 um 08:40 schrieb Kuehling, Felix:

Quoted 4 lines

Returning -EAGAIN prevents ttm_bo_mem_space from trying alternate placements and can lead to live-locks in amdgpu_cs, retrying indefinitely and never succeeding.

Quoted 7 lines
Quoted 3 lines
Fixes cfcc52e477e4 ("drm/ttm: fix busy memory to fail other user v10")
CC Christian Koenig <[email protected]>

Crap, I feared that this could live-lock under some circumstances, but hoped that this would be a rather rare case.

How did you reproduce this?

kfdtest --gtest_filter=KFDEvictTest.* --gtest_repeat=10

Quoted 8 lines

It runs two processes, both of which do graphics CS and KFD compute queues at the same time with enough memory pressure to cause frequent KFD evictions. It's meant to test KFD eviction code paths, but ended up finding a problem the graphics CS code path. :/

I was able to reproduce it right after your changes. With the latest version of the branch I can't reproduce it any more. Some other commit must have changed things enough to avoid the live lock.

Probably just luck, unless this was a very recent change. I'd also been seeing live-locks between memory-heavy piglit tests, last time just this Monday. But it didn't happen every time.

I'd been meaning to report this, but kept getting distracted by other stuff. Thanks for beating me to it, and for even coming up with a solution!

Signature · 6 lines
Earthling Michel Dänzer               |              https://www.amd.com
Libre software enthusiast             |             Mesa and X developer
_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx