All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 2/2] drm/radeon: Use two-ended allocation by size
@ 2014-04-02 17:04 Lauri Kasanen
  2014-04-02 17:08 ` Alex Deucher
  0 siblings, 1 reply; 4+ messages in thread
From: Lauri Kasanen @ 2014-04-02 17:04 UTC (permalink / raw)
  To: dri-devel; +Cc: jglisse, Thomas Hellstrom

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.

Signed-off-by: Lauri Kasanen <cand@gmx.com>
---
 drivers/gpu/drm/radeon/radeon_object.c | 11 ++++++++++-
 1 file changed, 10 insertions(+), 1 deletion(-)

diff --git a/drivers/gpu/drm/radeon/radeon_object.c b/drivers/gpu/drm/radeon/radeon_object.c
index 1375ff8..6251456 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,15 @@ 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,
-- 
1.8.3.1

^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH 2/2] drm/radeon: Use two-ended allocation by size
  2014-04-02 17:04 [PATCH 2/2] drm/radeon: Use two-ended allocation by size Lauri Kasanen
@ 2014-04-02 17:08 ` Alex Deucher
  2014-04-02 17:33   ` [PATCH] drm/radeon: Use two-ended allocation by size, v2 Lauri Kasanen
  0 siblings, 1 reply; 4+ messages in thread
From: Alex Deucher @ 2014-04-02 17:08 UTC (permalink / raw)
  To: Lauri Kasanen
  Cc: Jerome Glisse, Thomas Hellstrom, Maling list - DRI developers

On Wed, Apr 2, 2014 at 1:04 PM, Lauri Kasanen <cand@gmx.com> wrote:
> 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.
>
> Signed-off-by: Lauri Kasanen <cand@gmx.com>
> ---
>  drivers/gpu/drm/radeon/radeon_object.c | 11 ++++++++++-
>  1 file changed, 10 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/gpu/drm/radeon/radeon_object.c b/drivers/gpu/drm/radeon/radeon_object.c
> index 1375ff8..6251456 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,15 @@ 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;
> +       }

Can you clean up the formatting of this chunk of code?  It's a bit
weird to read.

Alex

>  }
>
>  int radeon_bo_create(struct radeon_device *rdev,
> --
> 1.8.3.1
>
> _______________________________________________
> dri-devel mailing list
> dri-devel@lists.freedesktop.org
> http://lists.freedesktop.org/mailman/listinfo/dri-devel

^ permalink raw reply	[flat|nested] 4+ messages in thread

* [PATCH] drm/radeon: Use two-ended allocation by size, v2
  2014-04-02 17:08 ` Alex Deucher
@ 2014-04-02 17:33   ` Lauri Kasanen
  2014-04-02 18:02     ` Christian König
  0 siblings, 1 reply; 4+ messages in thread
From: Lauri Kasanen @ 2014-04-02 17:33 UTC (permalink / raw)
  To: Alex Deucher
  Cc: Jerome Glisse, Thomas Hellstrom, Maling list - DRI developers

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(-)

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,
-- 
1.8.3.1

^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH] drm/radeon: Use two-ended allocation by size, v2
  2014-04-02 17:33   ` [PATCH] drm/radeon: Use two-ended allocation by size, v2 Lauri Kasanen
@ 2014-04-02 18:02     ` Christian König
  0 siblings, 0 replies; 4+ messages in thread
From: Christian König @ 2014-04-02 18:02 UTC (permalink / raw)
  To: Lauri Kasanen, Alex Deucher
  Cc: Jerome Glisse, Thomas Hellstrom, Maling list - DRI developers

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,

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2014-04-02 18:03 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-04-02 17:04 [PATCH 2/2] drm/radeon: Use two-ended allocation by size Lauri Kasanen
2014-04-02 17:08 ` Alex Deucher
2014-04-02 17:33   ` [PATCH] drm/radeon: Use two-ended allocation by size, v2 Lauri Kasanen
2014-04-02 18:02     ` Christian König

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.