All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Thomas Hellström" <thomas.hellstrom@linux.intel.com>
To: Matthew Auld <matthew.auld@intel.com>, intel-gfx@lists.freedesktop.org
Cc: dri-devel@lists.freedesktop.org,
	"Christian König" <christian.koenig@amd.com>
Subject: Re: [Intel-gfx] [PATCH v3 08/12] drm/i915/ttm: add tt shmem backend
Date: Thu, 16 Sep 2021 15:45:59 +0200	[thread overview]
Message-ID: <eea198e7003983b3bd77b23c2f70cd366afa507f.camel@linux.intel.com> (raw)
In-Reply-To: <20210915185954.3114858-8-matthew.auld@intel.com>

On Wed, 2021-09-15 at 19:59 +0100, Matthew Auld wrote:
> For cached objects we can allocate our pages directly in shmem. This
> should make it possible(in a later patch) to utilise the existing
> i915-gem shrinker code for such objects. For now this is still
> disabled.
> 
> Signed-off-by: Matthew Auld <matthew.auld@intel.com>
> Cc: Thomas Hellström <thomas.hellstrom@linux.intel.com>
> Cc: Christian König <christian.koenig@amd.com>
> ---
>  drivers/gpu/drm/i915/gem/i915_gem_object.h |   8 +
>  drivers/gpu/drm/i915/gem/i915_gem_shmem.c  |  14 +-
>  drivers/gpu/drm/i915/gem/i915_gem_ttm.c    | 217 ++++++++++++++++++-
> --
>  3 files changed, 209 insertions(+), 30 deletions(-)
> 
> 

...

>  }
> @@ -223,6 +349,10 @@ static bool i915_ttm_eviction_valuable(struct
> ttm_buffer_object *bo,
>  {
>         struct drm_i915_gem_object *obj = i915_ttm_to_gem(bo);
>  
> +       if (place->mem_type == TTM_PL_SYSTEM &&
> +           bo->ttm && bo->ttm->page_flags & I915_TTM_TT_SHMEM)
> +               return false;
> +


Should we use ttm_bo_pin() / ttm_bo_unpin() to remove the bo from the
TTM LRU lists when it's SHMEM populated, and change the above to a
GEM_BUG_ON()?


>         /* Will do for now. Our pinned objects are still on TTM's LRU
> lists */
>         return i915_gem_object_evictable(obj);
>  }
> @@ -316,9 +446,11 @@ static void
> i915_ttm_adjust_gem_after_move(struct drm_i915_gem_object *obj)
>         i915_gem_object_set_cache_coherency(obj, cache_level);
>  }
>  
> -static void i915_ttm_purge(struct drm_i915_gem_object *obj)
> +static void i915_ttm_writeback(struct drm_i915_gem_object *obj)
>  {
>         struct ttm_buffer_object *bo = i915_gem_to_ttm(obj);
> +       struct i915_ttm_tt *i915_tt =
> +               container_of(bo->ttm, typeof(*i915_tt), ttm);
>         struct ttm_operation_ctx ctx = {
>                 .interruptible = true,
>                 .no_wait_gpu = false,
> @@ -326,18 +458,52 @@ static void i915_ttm_purge(struct
> drm_i915_gem_object *obj)
>         struct ttm_placement place = {};
>         int ret;
>  
> -       if (obj->mm.madv == __I915_MADV_PURGED)
> +       if (!bo->ttm || !(bo->ttm->page_flags & I915_TTM_TT_SHMEM))
>                 return;
>  
> -       /* TTM's purge interface. Note that we might be reentering.
> */
> +       i915_tt->backup = true;
>         ret = ttm_bo_validate(bo, &place, &ctx);

It looks like writeback() becomes the backend's primary callback for
shrinking, although for the shmem backend, this is put_pages(), and the
writeback() callback is only called if needed to accelerate shmem's
transfer of pages to the swap cache. It appears like this will break
the shrinker reporting of shrunken pages?

Should we try to do the primary shrinking from the put_pages() callback
instead, like the shmem backend? Although we'd have to allow NULL pages
in put_pages() to account for evicted-to-shmem and adjust other
backends if necessary.



> -       if (!ret) {
> -               obj->write_domain = 0;
> -               obj->read_domains = 0;
> -               i915_ttm_adjust_gem_after_move(obj);
> -               i915_ttm_free_cached_io_st(obj);
> -               obj->mm.madv = __I915_MADV_PURGED;
> +       i915_tt->backup = false;
> +       if (ret)
> +               return;
> +
> +       __shmem_writeback(obj->base.size, i915_tt->filp->f_mapping);
> +}
> +



WARNING: multiple messages have this Message-ID (diff)
From: "Thomas Hellström" <thomas.hellstrom@linux.intel.com>
To: Matthew Auld <matthew.auld@intel.com>, intel-gfx@lists.freedesktop.org
Cc: dri-devel@lists.freedesktop.org,
	"Christian König" <christian.koenig@amd.com>
Subject: Re: [PATCH v3 08/12] drm/i915/ttm: add tt shmem backend
Date: Thu, 16 Sep 2021 15:45:59 +0200	[thread overview]
Message-ID: <eea198e7003983b3bd77b23c2f70cd366afa507f.camel@linux.intel.com> (raw)
In-Reply-To: <20210915185954.3114858-8-matthew.auld@intel.com>

On Wed, 2021-09-15 at 19:59 +0100, Matthew Auld wrote:
> For cached objects we can allocate our pages directly in shmem. This
> should make it possible(in a later patch) to utilise the existing
> i915-gem shrinker code for such objects. For now this is still
> disabled.
> 
> Signed-off-by: Matthew Auld <matthew.auld@intel.com>
> Cc: Thomas Hellström <thomas.hellstrom@linux.intel.com>
> Cc: Christian König <christian.koenig@amd.com>
> ---
>  drivers/gpu/drm/i915/gem/i915_gem_object.h |   8 +
>  drivers/gpu/drm/i915/gem/i915_gem_shmem.c  |  14 +-
>  drivers/gpu/drm/i915/gem/i915_gem_ttm.c    | 217 ++++++++++++++++++-
> --
>  3 files changed, 209 insertions(+), 30 deletions(-)
> 
> 

...

>  }
> @@ -223,6 +349,10 @@ static bool i915_ttm_eviction_valuable(struct
> ttm_buffer_object *bo,
>  {
>         struct drm_i915_gem_object *obj = i915_ttm_to_gem(bo);
>  
> +       if (place->mem_type == TTM_PL_SYSTEM &&
> +           bo->ttm && bo->ttm->page_flags & I915_TTM_TT_SHMEM)
> +               return false;
> +


Should we use ttm_bo_pin() / ttm_bo_unpin() to remove the bo from the
TTM LRU lists when it's SHMEM populated, and change the above to a
GEM_BUG_ON()?


>         /* Will do for now. Our pinned objects are still on TTM's LRU
> lists */
>         return i915_gem_object_evictable(obj);
>  }
> @@ -316,9 +446,11 @@ static void
> i915_ttm_adjust_gem_after_move(struct drm_i915_gem_object *obj)
>         i915_gem_object_set_cache_coherency(obj, cache_level);
>  }
>  
> -static void i915_ttm_purge(struct drm_i915_gem_object *obj)
> +static void i915_ttm_writeback(struct drm_i915_gem_object *obj)
>  {
>         struct ttm_buffer_object *bo = i915_gem_to_ttm(obj);
> +       struct i915_ttm_tt *i915_tt =
> +               container_of(bo->ttm, typeof(*i915_tt), ttm);
>         struct ttm_operation_ctx ctx = {
>                 .interruptible = true,
>                 .no_wait_gpu = false,
> @@ -326,18 +458,52 @@ static void i915_ttm_purge(struct
> drm_i915_gem_object *obj)
>         struct ttm_placement place = {};
>         int ret;
>  
> -       if (obj->mm.madv == __I915_MADV_PURGED)
> +       if (!bo->ttm || !(bo->ttm->page_flags & I915_TTM_TT_SHMEM))
>                 return;
>  
> -       /* TTM's purge interface. Note that we might be reentering.
> */
> +       i915_tt->backup = true;
>         ret = ttm_bo_validate(bo, &place, &ctx);

It looks like writeback() becomes the backend's primary callback for
shrinking, although for the shmem backend, this is put_pages(), and the
writeback() callback is only called if needed to accelerate shmem's
transfer of pages to the swap cache. It appears like this will break
the shrinker reporting of shrunken pages?

Should we try to do the primary shrinking from the put_pages() callback
instead, like the shmem backend? Although we'd have to allow NULL pages
in put_pages() to account for evicted-to-shmem and adjust other
backends if necessary.



> -       if (!ret) {
> -               obj->write_domain = 0;
> -               obj->read_domains = 0;
> -               i915_ttm_adjust_gem_after_move(obj);
> -               i915_ttm_free_cached_io_st(obj);
> -               obj->mm.madv = __I915_MADV_PURGED;
> +       i915_tt->backup = false;
> +       if (ret)
> +               return;
> +
> +       __shmem_writeback(obj->base.size, i915_tt->filp->f_mapping);
> +}
> +



  reply	other threads:[~2021-09-16 13:46 UTC|newest]

Thread overview: 47+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-09-15 18:59 [Intel-gfx] [PATCH v3 01/12] drm/ttm: stop setting page->index for the ttm_tt Matthew Auld
2021-09-15 18:59 ` Matthew Auld
2021-09-15 18:59 ` [Intel-gfx] [PATCH v3 02/12] drm/ttm: move ttm_tt_{add, clear}_mapping into amdgpu Matthew Auld
2021-09-15 18:59   ` Matthew Auld
2021-09-16  6:45   ` [Intel-gfx] " Christian König
2021-09-16  6:45     ` [PATCH v3 02/12] drm/ttm: move ttm_tt_{add,clear}_mapping " Christian König
2021-09-15 18:59 ` [Intel-gfx] [PATCH v3 03/12] drm/ttm: remove TTM_PAGE_FLAG_NO_RETRY Matthew Auld
2021-09-15 18:59   ` Matthew Auld
2021-09-16  6:46   ` [Intel-gfx] " Christian König
2021-09-16  6:46     ` Christian König
2021-09-15 18:59 ` [Intel-gfx] [PATCH v3 04/12] drm/ttm: s/FLAG_SG/FLAG_EXTERNAL/ Matthew Auld
2021-09-15 18:59   ` Matthew Auld
2021-09-16  6:50   ` [Intel-gfx] " Christian König
2021-09-16  6:50     ` Christian König
2021-09-15 18:59 ` [Intel-gfx] [PATCH v3 05/12] drm/ttm: add some kernel-doc for TTM_PAGE_FLAG_* Matthew Auld
2021-09-15 18:59   ` Matthew Auld
2021-09-16  6:52   ` [Intel-gfx] " Christian König
2021-09-16  6:52     ` Christian König
2021-09-15 18:59 ` [Intel-gfx] [PATCH v3 06/12] drm/ttm: add TTM_PAGE_FLAG_EXTERNAL_MAPPABLE Matthew Auld
2021-09-15 18:59   ` Matthew Auld
2021-09-16  6:55   ` [Intel-gfx] " Christian König
2021-09-16  6:55     ` Christian König
2021-09-16  9:03     ` [Intel-gfx] " Thomas Hellström
2021-09-16  9:03       ` Thomas Hellström
2021-09-16  9:58       ` [Intel-gfx] " Matthew Auld
2021-09-16  9:58         ` Matthew Auld
2021-09-16 10:06         ` [Intel-gfx] " Thomas Hellström
2021-09-16 10:06           ` Thomas Hellström
2021-09-15 18:59 ` [Intel-gfx] [PATCH v3 07/12] drm/i915/gem: Break out some shmem backend utils Matthew Auld
2021-09-15 18:59   ` Matthew Auld
2021-09-15 18:59 ` [Intel-gfx] [PATCH v3 08/12] drm/i915/ttm: add tt shmem backend Matthew Auld
2021-09-15 18:59   ` Matthew Auld
2021-09-16 13:45   ` Thomas Hellström [this message]
2021-09-16 13:45     ` Thomas Hellström
2021-09-15 18:59 ` [Intel-gfx] [PATCH v3 09/12] drm/i915/ttm: use cached system pages when evicting lmem Matthew Auld
2021-09-15 18:59   ` Matthew Auld
2021-09-15 18:59 ` [Intel-gfx] [PATCH v3 10/12] drm/i915: try to simplify make_{un}shrinkable Matthew Auld
2021-09-15 18:59   ` Matthew Auld
2021-09-15 18:59 ` [Intel-gfx] [PATCH v3 11/12] drm/i915/ttm: make evicted shmem pages visible to the shrinker Matthew Auld
2021-09-15 18:59   ` Matthew Auld
2021-09-15 18:59 ` [Intel-gfx] [PATCH v3 12/12] drm/i915/ttm: enable shmem tt backend Matthew Auld
2021-09-15 18:59   ` Matthew Auld
2021-09-15 19:32 ` [Intel-gfx] ✗ Fi.CI.CHECKPATCH: warning for series starting with [v3,01/12] drm/ttm: stop setting page->index for the ttm_tt Patchwork
2021-09-15 19:34 ` [Intel-gfx] ✗ Fi.CI.SPARSE: " Patchwork
2021-09-15 20:01 ` [Intel-gfx] ✗ Fi.CI.BAT: failure " Patchwork
2021-09-16  6:47 ` [Intel-gfx] [PATCH v3 01/12] " Christian König
2021-09-16  6:47   ` Christian König

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=eea198e7003983b3bd77b23c2f70cd366afa507f.camel@linux.intel.com \
    --to=thomas.hellstrom@linux.intel.com \
    --cc=christian.koenig@amd.com \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=intel-gfx@lists.freedesktop.org \
    --cc=matthew.auld@intel.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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.