All of lore.kernel.org
 help / color / mirror / Atom feed
From: Matthew Auld <matthew.auld@intel.com>
To: Chris Wilson <chris@chris-wilson.co.uk>, intel-gfx@lists.freedesktop.org
Subject: Re: [PATCH] drm/i915/gtt: Avoid overflowing the WC stash
Date: Wed, 29 May 2019 16:31:32 +0100	[thread overview]
Message-ID: <f32f684a-5fc0-deb7-ddf3-89bc03a8d045@intel.com> (raw)
In-Reply-To: <20190529093407.31697-1-chris@chris-wilson.co.uk>

On 29/05/2019 10:34, Chris Wilson wrote:
> An interesting issue cropped with making the pagetables be allocated and
> freed concurrently (i.e. removing their grandeous struct_mutex guard)
> was that we would overflow the page stash. This happens when we have
> multiple allocators grabbing WC pages such that we fill the vm's local
> page stash and then when we free another page, the page stash is already
> full and we overflow.
> 
> The fix is quite simple to check for a full page stash before adding
> another. This results in us keeping a vm local page stash around for
> much longer which is both a blessing and a curse.
> 
> Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
> Cc: Matthew Auld <matthew.auld@intel.com>
> Cc: Joonas Lahtinen <joonas.lahtinen@linux.intel.com>
Reviewed-by: Matthew Auld <matthew.auld@intel.com>

> ---
>   drivers/gpu/drm/i915/i915_gem_gtt.c | 10 ++++++----
>   1 file changed, 6 insertions(+), 4 deletions(-)
> 
> diff --git a/drivers/gpu/drm/i915/i915_gem_gtt.c b/drivers/gpu/drm/i915/i915_gem_gtt.c
> index 7496cce0d798..2d7a968d4fd5 100644
> --- a/drivers/gpu/drm/i915/i915_gem_gtt.c
> +++ b/drivers/gpu/drm/i915/i915_gem_gtt.c
> @@ -341,11 +341,11 @@ static struct page *stash_pop_page(struct pagestash *stash)
>   
>   static void stash_push_pagevec(struct pagestash *stash, struct pagevec *pvec)
>   {
> -	int nr;
> +	unsigned int nr;
>   
>   	spin_lock_nested(&stash->lock, SINGLE_DEPTH_NESTING);
>   
> -	nr = min_t(int, pvec->nr, pagevec_space(&stash->pvec));
> +	nr = min_t(typeof(nr), pvec->nr, pagevec_space(&stash->pvec));
>   	memcpy(stash->pvec.pages + stash->pvec.nr,
>   	       pvec->pages + pvec->nr - nr,
>   	       sizeof(pvec->pages[0]) * nr);
> @@ -399,7 +399,8 @@ static struct page *vm_alloc_page(struct i915_address_space *vm, gfp_t gfp)
>   		page = stack.pages[--stack.nr];
>   
>   		/* Merge spare WC pages to the global stash */
> -		stash_push_pagevec(&vm->i915->mm.wc_stash, &stack);
> +		if (stack.nr)
> +			stash_push_pagevec(&vm->i915->mm.wc_stash, &stack);
>   
>   		/* Push any surplus WC pages onto the local VM stash */
>   		if (stack.nr)
> @@ -469,8 +470,9 @@ static void vm_free_page(struct i915_address_space *vm, struct page *page)
>   	 */
>   	might_sleep();
>   	spin_lock(&vm->free_pages.lock);
> -	if (!pagevec_add(&vm->free_pages.pvec, page))
> +	if (!pagevec_space(&vm->free_pages.pvec))
>   		vm_free_pages_release(vm, false);
> +	pagevec_add(&vm->free_pages.pvec, page);
>   	spin_unlock(&vm->free_pages.lock);
>   }
>   
> 
_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

  parent reply	other threads:[~2019-05-29 15:31 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-05-29  9:34 [PATCH] drm/i915/gtt: Avoid overflowing the WC stash Chris Wilson
2019-05-29 15:16 ` ✗ Fi.CI.SPARSE: warning for " Patchwork
2019-05-29 15:31 ` Matthew Auld [this message]
2019-05-29 15:37 ` ✓ Fi.CI.BAT: success " Patchwork
2019-05-30  3:02 ` ✓ Fi.CI.IGT: " Patchwork
2019-05-31  8:37 ` ✓ Fi.CI.BAT: " Patchwork
2019-05-31 18:08 ` ✓ Fi.CI.IGT: " Patchwork

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=f32f684a-5fc0-deb7-ddf3-89bc03a8d045@intel.com \
    --to=matthew.auld@intel.com \
    --cc=chris@chris-wilson.co.uk \
    --cc=intel-gfx@lists.freedesktop.org \
    /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.