Re: [Intel-gfx] [PATCH 12/20] drm/i915/ttm: make eviction mappable aware

Thomas Hellström
2022-02-02T13:42:04Z

On 1/26/22 16:21, Matthew Auld wrote:
> If we need to make room for some some mappable object, then we should
> only victimize objects that have one or pages that occupy the visible
> portion of LMEM. Let's also create a new priority hint for objects that
> are placed in mappable memory, where we know that CPU access was
> requested, that way we hopefully victimize these last.
>
> Signed-off-by: Matthew Auld <matthew.auld@intel.com>
> Cc: Thomas Hellström <thomas.hellstrom@linux.intel.com>
> ---
> drivers/gpu/drm/i915/gem/i915_gem_ttm.c | 65 ++++++++++++++++++++++++-
> 1 file changed, 63 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/gpu/drm/i915/gem/i915_gem_ttm.c b/drivers/gpu/drm/i915/gem/i915_gem_ttm.c
> index e4cd6ccf5ab1..8376e4c3d290 100644
> --- a/drivers/gpu/drm/i915/gem/i915_gem_ttm.c
> +++ b/drivers/gpu/drm/i915/gem/i915_gem_ttm.c
> @@ -5,8 +5,10 @@
>
> #include <drm/ttm/ttm_bo_driver.h>
> #include <drm/ttm/ttm_placement.h>
> +#include <drm/drm_buddy.h>
>
> #include "i915_drv.h"
> +#include "i915_ttm_buddy_manager.h"
> #include "intel_memory_region.h"
> #include "intel_region_ttm.h"
>
> @@ -20,6 +22,7 @@
> #define I915_TTM_PRIO_PURGE 0
> #define I915_TTM_PRIO_NO_PAGES 1
> #define I915_TTM_PRIO_HAS_PAGES 2
> +#define I915_TTM_PRIO_NEEDS_CPU_ACCESS 3
>
> /*
> * Size of struct ttm_place vector in on-stack struct ttm_placement allocs
> @@ -337,6 +340,7 @@ static bool i915_ttm_eviction_valuable(struct ttm_buffer_object *bo,
> const struct ttm_place *place)
> {
> struct drm_i915_gem_object *obj = i915_ttm_to_gem(bo);
> + struct ttm_resource *res = bo->resource;
>
> if (!obj)
> return false;
> @@ -350,7 +354,48 @@ static bool i915_ttm_eviction_valuable(struct ttm_buffer_object *bo,
> return false;
>
> /* Will do for now. Our pinned objects are still on TTM's LRU lists */
> - return i915_gem_object_evictable(obj);
> + if (!i915_gem_object_evictable(obj))
> + return false;
> +
> + switch (res->mem_type) {
> + case TTM_PL_PRIV: {

We should use the I915_ placements for better readability.

Otherwise Reviewed-by: Thomas Hellström <thomas.hellstrom@linux.intel.com>