Skip to content

Commit 787db3b

Browse files
sulixjlahtine-intel
authored andcommitted
drm/i915: Attempt to get pages without eviction first
In commit a78a8da ("drm/ttm: replace busy placement with flags v6"), __i915_ttm_get_pages was updated to use flags instead of the separate 'busy' placement list. However, the behaviour was subtly changed. Originally, the function would attempt to use the preferred placement without eviction, and give an opportunity to restart the operation before falling back to allowing eviction. This was unintentionally changed, as the preferred placement was not given the TTM_PL_FLAG_DESIRED flag, and so eviction could be triggered in that first pass. This caused thrashing, and a significant performance regression on DG2 systems with small BAR. For example, Minecraft and Team Fortress 2 would drop to single-digit framerates. Restore the original behaviour by marking the initial placement as desired on that first attempt. Also, rework this to use a separate struct ttm_palcement, as the individual placements are marked 'const', so hot-patching the flags is even more dodgy than before. Thanks to Justin Brewer for bisecting this. Fixes: a78a8da ("drm/ttm: replace busy placement with flags v6") Link: https://gitlab.freedesktop.org/drm/i915/kernel/-/issues/11255 Signed-off-by: David Gow <david@davidgow.net> Reviewed-by: Jonathan Cavitt <jonathan.cavitt@intel.com> Reviewed-by: Andi Shyti <andi.shyti@linux.intel.com> Signed-off-by: Andi Shyti <andi.shyti@linux.intel.com> Link: https://patchwork.freedesktop.org/patch/msgid/20240804091851.122186-3-david@davidgow.net (cherry picked from commit 92653f2) Signed-off-by: Joonas Lahtinen <joonas.lahtinen@linux.intel.com>
1 parent 264b5b5 commit 787db3b

File tree

1 file changed

+7
-5
lines changed

1 file changed

+7
-5
lines changed

drivers/gpu/drm/i915/gem/i915_gem_ttm.c

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -778,13 +778,16 @@ static int __i915_ttm_get_pages(struct drm_i915_gem_object *obj,
778778
.interruptible = true,
779779
.no_wait_gpu = false,
780780
};
781-
int real_num_busy;
781+
struct ttm_placement initial_placement;
782+
struct ttm_place initial_place;
782783
int ret;
783784

784785
/* First try only the requested placement. No eviction. */
785-
real_num_busy = placement->num_placement;
786-
placement->num_placement = 1;
787-
ret = ttm_bo_validate(bo, placement, &ctx);
786+
initial_placement.num_placement = 1;
787+
memcpy(&initial_place, placement->placement, sizeof(struct ttm_place));
788+
initial_place.flags |= TTM_PL_FLAG_DESIRED;
789+
initial_placement.placement = &initial_place;
790+
ret = ttm_bo_validate(bo, &initial_placement, &ctx);
788791
if (ret) {
789792
ret = i915_ttm_err_to_gem(ret);
790793
/*
@@ -799,7 +802,6 @@ static int __i915_ttm_get_pages(struct drm_i915_gem_object *obj,
799802
* If the initial attempt fails, allow all accepted placements,
800803
* evicting if necessary.
801804
*/
802-
placement->num_placement = real_num_busy;
803805
ret = ttm_bo_validate(bo, placement, &ctx);
804806
if (ret)
805807
return i915_ttm_err_to_gem(ret);

0 commit comments

Comments
 (0)