Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

drm/radeon: Use two-ended allocation by size, v2

This decreases eviction by up to 20%, by improving the fragmentation
quality. No harm in normal cases that fit VRAM fully (PTS gaming suite).

In some cases, even the VRAM-fitting cases improved slightly (openarena, urban terror).

512kb was measured as the most optimal threshold for 3d workloads common to radeon.
Other drivers may need different thresholds according to their workloads.

v2: Nicer formatting
Signed-off-by: Lauri Kasanen <cand@gmx.com>
Reviewed-by: Christian König <christian.koenig@amd.com>
Signed-off-by: Dave Airlie <airlied@redhat.com>

authored by

Lauri Kasanen and committed by
Dave Airlie
deadcb36 62347f9e

+12 -1
+12 -1
drivers/gpu/drm/radeon/radeon_object.c
··· 104 104 105 105 void radeon_ttm_placement_from_domain(struct radeon_bo *rbo, u32 domain) 106 106 { 107 - u32 c = 0; 107 + u32 c = 0, i; 108 108 109 109 rbo->placement.fpfn = 0; 110 110 rbo->placement.lpfn = 0; ··· 131 131 rbo->placements[c++] = TTM_PL_MASK_CACHING | TTM_PL_FLAG_SYSTEM; 132 132 rbo->placement.num_placement = c; 133 133 rbo->placement.num_busy_placement = c; 134 + 135 + /* 136 + * Use two-ended allocation depending on the buffer size to 137 + * improve fragmentation quality. 138 + * 512kb was measured as the most optimal number. 139 + */ 140 + if (rbo->tbo.mem.size > 512 * 1024) { 141 + for (i = 0; i < c; i++) { 142 + rbo->placements[i] |= TTM_PL_FLAG_TOPDOWN; 143 + } 144 + } 134 145 } 135 146 136 147 int radeon_bo_create(struct radeon_device *rdev,