diff mbox

[16/21] drm/i915/gtt: Pin vma during virtual address allocation

Message ID 1432314314-23530-17-git-send-email-mika.kuoppala@intel.com (mailing list archive)
State New, archived
Headers show

Commit Message

Mika Kuoppala May 22, 2015, 5:05 p.m. UTC
Dynamic page table allocation might wake the shrinker
when memory is requested for page table structures.
As this happens when we try to allocate the virtual address
during binding, our vma might be among the targets for eviction.
We should do i915_vma_pin() and do pin early in there like Chris
suggests but this is interim solution.

Shield our vma from shrinker by incrementing pin count before
the virtual address is allocated.

The proper place to fix this would be in gem, inside of
i915_vma_pin(). But we don't have that yet so take the short
cut as a intermediate solution.

Testcase: igt/gem_ctx_thrash
Signed-off-by: Mika Kuoppala <mika.kuoppala@intel.com>
---
 drivers/gpu/drm/i915/i915_gem_gtt.c | 3 +++
 1 file changed, 3 insertions(+)

Comments

Michel Thierry June 3, 2015, 2:27 p.m. UTC | #1
On 5/22/2015 6:05 PM, Mika Kuoppala wrote:
> Dynamic page table allocation might wake the shrinker
> when memory is requested for page table structures.
> As this happens when we try to allocate the virtual address
> during binding, our vma might be among the targets for eviction.
> We should do i915_vma_pin() and do pin early in there like Chris
> suggests but this is interim solution.
>
> Shield our vma from shrinker by incrementing pin count before
> the virtual address is allocated.
>
> The proper place to fix this would be in gem, inside of
> i915_vma_pin(). But we don't have that yet so take the short
> cut as a intermediate solution.
>
> Testcase: igt/gem_ctx_thrash
> Signed-off-by: Mika Kuoppala <mika.kuoppala@intel.com>
Reviewed-by: Michel Thierry <michel.thierry@intel.com>
> ---
>   drivers/gpu/drm/i915/i915_gem_gtt.c | 3 +++
>   1 file changed, 3 insertions(+)
>
> diff --git a/drivers/gpu/drm/i915/i915_gem_gtt.c b/drivers/gpu/drm/i915/i915_gem_gtt.c
> index a2a0c88..b938964 100644
> --- a/drivers/gpu/drm/i915/i915_gem_gtt.c
> +++ b/drivers/gpu/drm/i915/i915_gem_gtt.c
> @@ -2916,9 +2916,12 @@ int i915_vma_bind(struct i915_vma *vma, enum i915_cache_level cache_level,
>                                      vma->node.size,
>                                      VM_TO_TRACE_NAME(vma->vm));
>
> +               /* XXX: i915_vma_pin() will fix this +- hack */
> +               vma->pin_count++;
>                  ret = vma->vm->allocate_va_range(vma->vm,
>                                                   vma->node.start,
>                                                   vma->node.size);
> +               vma->pin_count--;
>                  if (ret)
>                          return ret;
>          }
> --
> 1.9.1
>
> _______________________________________________
> Intel-gfx mailing list
> Intel-gfx@lists.freedesktop.org
> http://lists.freedesktop.org/mailman/listinfo/intel-gfx
diff mbox

Patch

diff --git a/drivers/gpu/drm/i915/i915_gem_gtt.c b/drivers/gpu/drm/i915/i915_gem_gtt.c
index a2a0c88..b938964 100644
--- a/drivers/gpu/drm/i915/i915_gem_gtt.c
+++ b/drivers/gpu/drm/i915/i915_gem_gtt.c
@@ -2916,9 +2916,12 @@  int i915_vma_bind(struct i915_vma *vma, enum i915_cache_level cache_level,
 				    vma->node.size,
 				    VM_TO_TRACE_NAME(vma->vm));
 
+		/* XXX: i915_vma_pin() will fix this +- hack */
+		vma->pin_count++;
 		ret = vma->vm->allocate_va_range(vma->vm,
 						 vma->node.start,
 						 vma->node.size);
+		vma->pin_count--;
 		if (ret)
 			return ret;
 	}