Skip to contentSkip to conversation

drm/amdgpu: fix amdgpu_ttm_bo_eviction_valuable

PATCH In review Christian König 3 participants 3 messages Apr 20, 2017 – Apr 21, 2017 2 messages not in the archive

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

PATCH 1/1 drm/amdgpu: fix amdgpu_ttm_bo_eviction_valuable

From: Christian König <[email protected]>

BOs not mapped into the GART are always valuable for an eviction. Otherwise we don't correctly swap them out on VRAM evictions during memory pressure.

---
 drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c | 18 +++++++++++++-----
 1 file changed, 13 insertions(+), 5 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c +13 -5
index e5d460e..ab7317e 100644
@@ -1040,11 +1040,17 @@ uint64_t amdgpu_ttm_tt_pte_flags(struct amdgpu_device *adev, struct ttm_tt *ttm,
 static bool amdgpu_ttm_bo_eviction_valuable(struct ttm_buffer_object *bo,
 					    const struct ttm_place *place)
 {
-	if (bo->mem.mem_type == TTM_PL_VRAM &&
-	    bo->mem.start == AMDGPU_BO_INVALID_OFFSET) {
-		unsigned long num_pages = bo->mem.num_pages;
-		struct drm_mm_node *node = bo->mem.mm_node;
+	unsigned long num_pages = bo->mem.num_pages;
+	struct drm_mm_node *node = bo->mem.mm_node;
 
+	if (bo->mem.start != AMDGPU_BO_INVALID_OFFSET)
+		return ttm_bo_eviction_valuable(bo, place);
+
+	switch (bo->mem.mem_type) {
+	case TTM_PL_TT:
+		return true;
+
+	case TTM_PL_VRAM:
 		/* Check each drm MM node individually */
 		while (num_pages) {
 			if (place->fpfn < (node->start + node->size) &&
@@ -1054,8 +1060,10 @@ static bool amdgpu_ttm_bo_eviction_valuable(struct ttm_buffer_object *bo,
 			num_pages -= node->size;
 			++node;
 		}
+		break;
 
-		return false;
+	default:
+		break;
 	}
 
 	return ttm_bo_eviction_valuable(bo, place);
Signature · 6 lines
2.5.0

_______________________________________________
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): 1492688977-1757-1-git-send-email-deathsimple-ANTagKRnAhcb1SvskN2V4Q@public.gmane.org

Reviewed-by
#2 lore raw
Quoted 6 lines · Christian König

From: Christian König <[email protected]>

BOs not mapped into the GART are always valuable for an eviction. Otherwise we don't correctly swap them out on VRAM evictions during memory pressure.

Quoted 45 lines
---
 drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c | 18 +++++++++++++-----
 1 file changed, 13 insertions(+), 5 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c +13 -6
index e5d460e..ab7317e 100644
@@ -1040,11 +1040,17 @@ uint64_t amdgpu_ttm_tt_pte_flags(struct amdgpu_device *adev, struct ttm_tt *ttm,
 static bool amdgpu_ttm_bo_eviction_valuable(struct ttm_buffer_object *bo,
                                            const struct ttm_place *place)
 {
-       if (bo->mem.mem_type == TTM_PL_VRAM &&
-           bo->mem.start == AMDGPU_BO_INVALID_OFFSET) {
-               unsigned long num_pages = bo->mem.num_pages;
-               struct drm_mm_node *node = bo->mem.mm_node;
+       unsigned long num_pages = bo->mem.num_pages;
+       struct drm_mm_node *node = bo->mem.mm_node;
 
+       if (bo->mem.start != AMDGPU_BO_INVALID_OFFSET)
+               return ttm_bo_eviction_valuable(bo, place);
+
+       switch (bo->mem.mem_type) {
+       case TTM_PL_TT:
+               return true;
+
+       case TTM_PL_VRAM:
                /* Check each drm MM node individually */
                while (num_pages) {
                        if (place->fpfn < (node->start + node->size) &&
@@ -1054,8 +1060,10 @@ static bool amdgpu_ttm_bo_eviction_valuable(struct ttm_buffer_object *bo,
                        num_pages -= node->size;
                        ++node;
                }
+               break;
 
-               return false;
+       default:
+               break;
        }
 
        return ttm_bo_eviction_valuable(bo, place);
--

2.5.0

Quoted 4 lines

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

_______________________________________________
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): CADnq5_N2KHdP3vkiY4Cfg6dKEqk1kF8_17N6s9H_0E7yQNDciA-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org

#4 lore raw
Quoted 9 lines · Alex Deucher
Quoted 6 lines · Christian König

From: Christian König <[email protected]>

BOs not mapped into the GART are always valuable for an eviction. Otherwise we don't correctly swap them out on VRAM evictions during memory pressure.

Although it doesn't fix my issue, it seems more reasonable compared previous, Reviewed-by: Chunming Zhou <[email protected]>

Quoted 46 lines
Quoted 46 lines
---
  drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c | 18 +++++++++++++-----
  1 file changed, 13 insertions(+), 5 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c +13 -6
index e5d460e..ab7317e 100644
@@ -1040,11 +1040,17 @@ uint64_t amdgpu_ttm_tt_pte_flags(struct amdgpu_device *adev, struct ttm_tt *ttm,
  static bool amdgpu_ttm_bo_eviction_valuable(struct ttm_buffer_object *bo,
                                             const struct ttm_place *place)
  {
-       if (bo->mem.mem_type == TTM_PL_VRAM &&
-           bo->mem.start == AMDGPU_BO_INVALID_OFFSET) {
-               unsigned long num_pages = bo->mem.num_pages;
-               struct drm_mm_node *node = bo->mem.mm_node;
+       unsigned long num_pages = bo->mem.num_pages;
+       struct drm_mm_node *node = bo->mem.mm_node;
 
+       if (bo->mem.start != AMDGPU_BO_INVALID_OFFSET)
+               return ttm_bo_eviction_valuable(bo, place);
+
+       switch (bo->mem.mem_type) {
+       case TTM_PL_TT:
+               return true;
+
+       case TTM_PL_VRAM:
                 /* Check each drm MM node individually */
                 while (num_pages) {
                         if (place->fpfn < (node->start + node->size) &&
@@ -1054,8 +1060,10 @@ static bool amdgpu_ttm_bo_eviction_valuable(struct ttm_buffer_object *bo,
                         num_pages -= node->size;
                         ++node;
                 }
+               break;
 
-               return false;
+       default:
+               break;
         }
 
         return ttm_bo_eviction_valuable(bo, place);
--

2.5.0

Quoted 8 lines
Quoted 4 lines

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

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

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