From: Joonas Lahtinen <joonas.lahtinen@linux.intel.com>
To: Chris Wilson <chris@chris-wilson.co.uk>, intel-gfx@lists.freedesktop.org
Subject: Re: [PATCH 3/3] drm/i915: Prefer random replacement before eviction search
Date: Wed, 11 Jan 2017 09:47:41 +0200 [thread overview]
Message-ID: <1484120861.3011.14.camel@linux.intel.com> (raw)
In-Reply-To: <20170110215555.18705-3-chris@chris-wilson.co.uk>
On ti, 2017-01-10 at 21:55 +0000, Chris Wilson wrote:
> Performing an eviction search can be very, very slow especially for a
> range restricted replacement. For example, a workload like
> gem_concurrent_blit will populate the entire GTT and then cause aperture
> thrashing. Since the GTT is a mix of active and inactive tiny objects,
> we have to search through almost 400k objects before finding anything
> inside the mappable region, and as this search is required before every
> operation performance falls off a cliff.
>
> Instead of performing the full search, we do a trial replacement of the
> node at a random location fitting the specified restrictions. We lose
> the strict LRU property of the GTT in exchange for avoiding the slow
> search (several orders of runtime improvement for gem_concurrent_blit
> 4KiB-global-gtt, e.g. from 5000s to 20s). The loss of LRU replacement is
> (later) mitigated firstly by only doing replacement if we find no
> freespace and secondly by execbuf doing a PIN_NONBLOCK search first before
> it starts thrashing (i.e. the random replacement will only occur from the
> already inactive set of objects).
>
> Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
> Cc: Tvrtko Ursulin <tvrtko.ursulin@intel.com>
> Cc: Joonas Lahtinen <joonas.lahtinen@linux.intel.com>
<SNIP>
> +static u64 random_offset(u64 start, u64 end, u64 len, u64 align)
> +{
The usual GEM_BUG_ON dance to make sure the inputs make some sense. Or
are you relying on the upper level callers?
> + u64 range, addr;
> +
> + if (align == 0)
> + align = I915_GTT_MIN_ALIGNMENT;
> +
> + range = round_down(end - len, align) - round_up(start, align);
For example this may cause an odd result.
> @@ -3629,6 +3655,16 @@ int i915_gem_gtt_insert(struct i915_address_space *vm,
> if (err != -ENOSPC)
> return err;
>
> + /* No free space, pick a slot at random */
> + err = i915_gem_gtt_reserve(vm, node,
> + size,
> + random_offset(start, end, size, alignment),
I'd pull this to a line above just to make it more humane to read.
> + color,
> + flags);
> + if (err != -ENOSPC)
> + return err;
> +
> + /* Randomly selected placement is pinned, do a search */
> err = i915_gem_evict_something(vm, size, alignment, color,
> start, end, flags);
> if (err)
I'm bit unsure why it would make such a big difference, but if you've
been running the numbers. Code itself is all good, so this is;
Reviewed-by: Joonas Lahtinen <joonas.lahtinen@linux.intel.com>
Regards, Joonas
--
Joonas Lahtinen
Open Source Technology Center
Intel Corporation
_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx
next prev parent reply other threads:[~2017-01-11 7:47 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-01-10 21:55 [PATCH 1/3] drm/i915: Use the MRU stack search after evicting Chris Wilson
2017-01-10 21:55 ` [PATCH 2/3] drm/i915: Extract reserving space in the GTT to a helper Chris Wilson
2017-01-11 7:06 ` Joonas Lahtinen
2017-01-10 21:55 ` [PATCH 3/3] drm/i915: Prefer random replacement before eviction search Chris Wilson
2017-01-11 7:47 ` Joonas Lahtinen [this message]
2017-01-11 9:37 ` Chris Wilson
2017-01-11 10:02 ` [PATCH] " Chris Wilson
2017-01-11 10:28 ` [PATCH v3] " Chris Wilson
2017-01-10 22:23 ` ✓ Fi.CI.BAT: success for series starting with [1/3] drm/i915: Use the MRU stack search after evicting Patchwork
2017-01-11 10:53 ` ✗ Fi.CI.BAT: warning for series starting with [1/3] drm/i915: Use the MRU stack search after evicting (rev3) 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=1484120861.3011.14.camel@linux.intel.com \
--to=joonas.lahtinen@linux.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox