Re: [RFC PATCH 12/18] drm/ttm: Do not evict BOs with higher priority

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Am 24.04.24 um 18:57 schrieb Friedrich Vock:
This makes buffer eviction significantly more stable by avoiding
ping-ponging caused by low-priority buffers evicting high-priority
buffers and vice versa.

And creates a deny of service for the whole system by fork() bombing.

This is another very big NAK.

Regards,
Christian.


Signed-off-by: Friedrich Vock <friedrich.vock@xxxxxx>
---
  drivers/gpu/drm/ttm/ttm_bo.c       | 9 +++++++--
  drivers/gpu/drm/ttm/ttm_resource.c | 5 +++--
  include/drm/ttm/ttm_bo.h           | 1 +
  3 files changed, 11 insertions(+), 4 deletions(-)

diff --git a/drivers/gpu/drm/ttm/ttm_bo.c b/drivers/gpu/drm/ttm/ttm_bo.c
index 3047c763eb4eb..eae54cd4a7ce9 100644
--- a/drivers/gpu/drm/ttm/ttm_bo.c
+++ b/drivers/gpu/drm/ttm/ttm_bo.c
@@ -776,6 +776,7 @@ static int ttm_mem_evict_wait_busy(struct ttm_buffer_object *busy_bo,
  int ttm_mem_evict_first(struct ttm_device *bdev,
  			struct ttm_resource_manager *man,
  			const struct ttm_place *place,
+			unsigned int max_priority,
  			struct ttm_operation_ctx *ctx,
  			struct ww_acquire_ctx *ticket)
  {
@@ -788,6 +789,8 @@ int ttm_mem_evict_first(struct ttm_device *bdev,
  	spin_lock(&bdev->lru_lock);
  	ttm_resource_manager_for_each_res(man, &cursor, res) {
  		bool busy;
+		if (res->bo->priority > max_priority)
+			break;

  		if (!ttm_bo_evict_swapout_allowable(res->bo, ctx, place,
  						    &locked, &busy)) {
@@ -930,8 +933,10 @@ static int ttm_bo_mem_force_space(struct ttm_buffer_object *bo,
  			return ret;
  		if (ctx->no_evict)
  			return -ENOSPC;
-		ret = ttm_mem_evict_first(bdev, man, place, ctx,
-					  ticket);
+		if (!bo->priority)
+			return -ENOSPC;
+		ret = ttm_mem_evict_first(bdev, man, place, bo->priority - 1,
+					  ctx, ticket);
  		if (unlikely(ret != 0))
  			return ret;
  	} while (1);
diff --git a/drivers/gpu/drm/ttm/ttm_resource.c b/drivers/gpu/drm/ttm/ttm_resource.c
index 1d6755a1153b1..63d4371adb519 100644
--- a/drivers/gpu/drm/ttm/ttm_resource.c
+++ b/drivers/gpu/drm/ttm/ttm_resource.c
@@ -431,8 +431,9 @@ int ttm_resource_manager_evict_all(struct ttm_device *bdev,
  	for (i = 0; i < TTM_MAX_BO_PRIORITY; ++i) {
  		while (!list_empty(&man->lru[i])) {
  			spin_unlock(&bdev->lru_lock);
-			ret = ttm_mem_evict_first(bdev, man, NULL, &ctx,
-						  NULL);
+			ret = ttm_mem_evict_first(bdev, man, NULL,
+						  TTM_MAX_BO_PRIORITY,
+						  &ctx, NULL);
  			if (ret)
  				return ret;
  			spin_lock(&bdev->lru_lock);
diff --git a/include/drm/ttm/ttm_bo.h b/include/drm/ttm/ttm_bo.h
index 8f4e6366c0417..91299a3b6fcfa 100644
--- a/include/drm/ttm/ttm_bo.h
+++ b/include/drm/ttm/ttm_bo.h
@@ -396,6 +396,7 @@ void ttm_bo_unpin(struct ttm_buffer_object *bo);
  int ttm_mem_evict_first(struct ttm_device *bdev,
  			struct ttm_resource_manager *man,
  			const struct ttm_place *place,
+			unsigned int max_priority,
  			struct ttm_operation_ctx *ctx,
  			struct ww_acquire_ctx *ticket);
  void ttm_mem_unevict_evicted(struct ttm_device *bdev,
--
2.44.0





[Index of Archives]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux