dri-devel.lists.freedesktop.org archive mirror
 help / color / mirror / Atom feed
From: "Ville Syrjälä" <ville.syrjala@linux.intel.com>
To: Matthew Auld <matthew.auld@intel.com>
Cc: intel-gfx@lists.freedesktop.org, dri-devel@lists.freedesktop.org,
	Chris Wilson <chris@chris-wilson.co.uk>
Subject: Re: [PATCH v2] drm/i915/gem: Pin the L-shape quirked object as unshrinkable
Date: Fri, 14 May 2021 16:20:23 +0300	[thread overview]
Message-ID: <YJ55F8f4s3jSOGKY@intel.com> (raw)
In-Reply-To: <20210513120756.622515-1-matthew.auld@intel.com>

On Thu, May 13, 2021 at 01:07:56PM +0100, Matthew Auld wrote:
> From: Chris Wilson <chris@chris-wilson.co.uk>
> 
> When instantiating a tiled object on an L-shaped memory machine, we mark
> the object as unshrinkable to prevent the shrinker from trying to swap
> out the pages. We have to do this as we do not know the swizzling on the
> individual pages, and so the data will be scrambled across swap out/in.
> 
> Not only do we need to move the object off the shrinker list, we need to
> mark the object with shrink_pin so that the counter is consistent across
> calls to madvise.
> 
> v2: in the madvise ioctl we need to check if the object is currently
> shrinkable/purgeable, not if the object type supports shrinking
> 
> Fixes: 0175969e489a ("drm/i915/gem: Use shrinkable status for unknown swizzle quirks")
> References: https://gitlab.freedesktop.org/drm/intel/-/issues/3293
> Reported-by: Ville Syrjälä <ville.syrjala@linux.intel.com>
> Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
> Signed-off-by: Matthew Auld <matthew.auld@intel.com>

This one seems to fare better than v1.

Tested-by: Ville Syrjälä <ville.syrjala@linux.intel.com>

> ---
>  drivers/gpu/drm/i915/gem/i915_gem_pages.c |  2 ++
>  drivers/gpu/drm/i915/i915_gem.c           | 11 +++++------
>  2 files changed, 7 insertions(+), 6 deletions(-)
> 
> diff --git a/drivers/gpu/drm/i915/gem/i915_gem_pages.c b/drivers/gpu/drm/i915/gem/i915_gem_pages.c
> index aed8a37ccdc9..7361971c177d 100644
> --- a/drivers/gpu/drm/i915/gem/i915_gem_pages.c
> +++ b/drivers/gpu/drm/i915/gem/i915_gem_pages.c
> @@ -63,6 +63,8 @@ void __i915_gem_object_set_pages(struct drm_i915_gem_object *obj,
>  	    i915->quirks & QUIRK_PIN_SWIZZLED_PAGES) {
>  		GEM_BUG_ON(i915_gem_object_has_tiling_quirk(obj));
>  		i915_gem_object_set_tiling_quirk(obj);
> +		GEM_BUG_ON(!list_empty(&obj->mm.link));
> +		atomic_inc(&obj->mm.shrink_pin);
>  		shrinkable = false;
>  	}
>  
> diff --git a/drivers/gpu/drm/i915/i915_gem.c b/drivers/gpu/drm/i915/i915_gem.c
> index d0018c5f88bd..cffd7f4f87dc 100644
> --- a/drivers/gpu/drm/i915/i915_gem.c
> +++ b/drivers/gpu/drm/i915/i915_gem.c
> @@ -1009,12 +1009,11 @@ i915_gem_madvise_ioctl(struct drm_device *dev, void *data,
>  		obj->mm.madv = args->madv;
>  
>  	if (i915_gem_object_has_pages(obj)) {
> -		struct list_head *list;
> +		unsigned long flags;
>  
> -		if (i915_gem_object_is_shrinkable(obj)) {
> -			unsigned long flags;
> -
> -			spin_lock_irqsave(&i915->mm.obj_lock, flags);
> +		spin_lock_irqsave(&i915->mm.obj_lock, flags);
> +		if (!list_empty(&obj->mm.link)) {
> +			struct list_head *list;
>  
>  			if (obj->mm.madv != I915_MADV_WILLNEED)
>  				list = &i915->mm.purge_list;
> @@ -1022,8 +1021,8 @@ i915_gem_madvise_ioctl(struct drm_device *dev, void *data,
>  				list = &i915->mm.shrink_list;
>  			list_move_tail(&obj->mm.link, list);
>  
> -			spin_unlock_irqrestore(&i915->mm.obj_lock, flags);
>  		}
> +		spin_unlock_irqrestore(&i915->mm.obj_lock, flags);
>  	}
>  
>  	/* if the object is no longer attached, discard its backing storage */
> -- 
> 2.26.3

-- 
Ville Syrjälä
Intel

      reply	other threads:[~2021-05-14 13:20 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-05-13 12:07 [PATCH v2] drm/i915/gem: Pin the L-shape quirked object as unshrinkable Matthew Auld
2021-05-14 13:20 ` Ville Syrjälä [this message]

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=YJ55F8f4s3jSOGKY@intel.com \
    --to=ville.syrjala@linux.intel.com \
    --cc=chris@chris-wilson.co.uk \
    --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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).