diff mbox

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

Message ID 20140402203342.b7b1b04a.cand@gmx.com (mailing list archive)
State Accepted
Headers show

Commit Message

Lauri Kasanen April 2, 2014, 5:33 p.m. UTC
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>
---
 drivers/gpu/drm/radeon/radeon_object.c | 13 ++++++++++++-
 1 file changed, 12 insertions(+), 1 deletion(-)

Comments

Christian König April 2, 2014, 6:02 p.m. UTC | #1
Am 02.04.2014 19:33, schrieb Lauri Kasanen:
> 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>

> ---
>   drivers/gpu/drm/radeon/radeon_object.c | 13 ++++++++++++-
>   1 file changed, 12 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/gpu/drm/radeon/radeon_object.c b/drivers/gpu/drm/radeon/radeon_object.c
> index 1375ff8..19bec0d 100644
> --- a/drivers/gpu/drm/radeon/radeon_object.c
> +++ b/drivers/gpu/drm/radeon/radeon_object.c
> @@ -104,7 +104,7 @@ bool radeon_ttm_bo_is_radeon_bo(struct ttm_buffer_object *bo)
>   
>   void radeon_ttm_placement_from_domain(struct radeon_bo *rbo, u32 domain)
>   {
> -	u32 c = 0;
> +	u32 c = 0, i;
>   
>   	rbo->placement.fpfn = 0;
>   	rbo->placement.lpfn = 0;
> @@ -131,6 +131,17 @@ void radeon_ttm_placement_from_domain(struct radeon_bo *rbo, u32 domain)
>   		rbo->placements[c++] = TTM_PL_MASK_CACHING | TTM_PL_FLAG_SYSTEM;
>   	rbo->placement.num_placement = c;
>   	rbo->placement.num_busy_placement = c;
> +
> +	/*
> +	 * Use two-ended allocation depending on the buffer size to
> +	 * improve fragmentation quality.
> +	 * 512kb was measured as the most optimal number.
> +	 */
> +	if (rbo->tbo.mem.size > 512 * 1024) {
> +		for (i = 0; i < c; i++) {
> +			rbo->placements[i] |= TTM_PL_FLAG_TOPDOWN;
> +		}
> +	}
>   }
>   
>   int radeon_bo_create(struct radeon_device *rdev,
diff mbox

Patch

diff --git a/drivers/gpu/drm/radeon/radeon_object.c b/drivers/gpu/drm/radeon/radeon_object.c
index 1375ff8..19bec0d 100644
--- a/drivers/gpu/drm/radeon/radeon_object.c
+++ b/drivers/gpu/drm/radeon/radeon_object.c
@@ -104,7 +104,7 @@  bool radeon_ttm_bo_is_radeon_bo(struct ttm_buffer_object *bo)
 
 void radeon_ttm_placement_from_domain(struct radeon_bo *rbo, u32 domain)
 {
-	u32 c = 0;
+	u32 c = 0, i;
 
 	rbo->placement.fpfn = 0;
 	rbo->placement.lpfn = 0;
@@ -131,6 +131,17 @@  void radeon_ttm_placement_from_domain(struct radeon_bo *rbo, u32 domain)
 		rbo->placements[c++] = TTM_PL_MASK_CACHING | TTM_PL_FLAG_SYSTEM;
 	rbo->placement.num_placement = c;
 	rbo->placement.num_busy_placement = c;
+
+	/*
+	 * Use two-ended allocation depending on the buffer size to
+	 * improve fragmentation quality.
+	 * 512kb was measured as the most optimal number.
+	 */
+	if (rbo->tbo.mem.size > 512 * 1024) {
+		for (i = 0; i < c; i++) {
+			rbo->placements[i] |= TTM_PL_FLAG_TOPDOWN;
+		}
+	}
 }
 
 int radeon_bo_create(struct radeon_device *rdev,