From: Dave Gordon <david.s.gordon@intel.com>
To: intel-gfx@lists.freedesktop.org
Subject: Re: [RFC 3/3] drm/i915: Micro-optimize i915_gem_obj_to_vma
Date: Tue, 26 Apr 2016 11:35:53 +0100 [thread overview]
Message-ID: <571F4489.80809@intel.com> (raw)
In-Reply-To: <1461240353-29576-3-git-send-email-tvrtko.ursulin@linux.intel.com>
On 21/04/16 13:05, Tvrtko Ursulin wrote:
> From: Tvrtko Ursulin <tvrtko.ursulin@intel.com>
>
> i915_gem_obj_to_vma is one of the most expensive functions in
> our profiles. Could avoiding some branching by replacing it
> with arithmetic be beneficial? Some benchmarks suggest it
> slightly might.
>
> Signed-off-by: Tvrtko Ursulin <tvrtko.ursulin@intel.com>
> ---
> drivers/gpu/drm/i915/i915_gem.c | 14 ++++++++++++--
> 1 file changed, 12 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/gpu/drm/i915/i915_gem.c b/drivers/gpu/drm/i915/i915_gem.c
> index 0549dea683e1..243bfb922eb3 100644
> --- a/drivers/gpu/drm/i915/i915_gem.c
> +++ b/drivers/gpu/drm/i915/i915_gem.c
> @@ -4642,11 +4642,21 @@ struct i915_vma *i915_gem_obj_to_vma(struct drm_i915_gem_object *obj,
> struct i915_address_space *vm)
> {
> struct i915_vma *vma;
> +
> + BUILD_BUG_ON(I915_GGTT_VIEW_NORMAL != 0);
> +
> list_for_each_entry(vma, &obj->vma_list, obj_link) {
> - if (vma->ggtt_view.type == I915_GGTT_VIEW_NORMAL &&
> - vma->vm == vm)
> + /*
> + * Below is just a branching avoiding way of saying:
> + * vma_ggtt_view.type == I915_GGTT_VIEW_NORMAL && vma->vm == vm,
> + * which relies on the fact I915_GGTT_VIEW_NORMAL has to be
> + * zero.
> + */
> + if (!((unsigned long)vma->ggtt_view.type |
> + ((unsigned long)vma->vm ^ (unsigned long)vm)))
> return vma;
> }
> +
> return NULL;
> }
Other alternatives might include splitting the vma_list, so that we have
one list for the most-frequently searched-for entries (GGTT view NORMAL)
and for everything else, so the above would just need a single test for
equality.
Or, slightly less effectively, add GGTT/NORMAL entries at the head of
the list and others at the tail (and search backwards if you *don't*
want a GGTT/NORMAL entry). That would still need the comparisons, but
would likely hit an early match.
.Dave.
_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx
next prev parent reply other threads:[~2016-04-26 10:35 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-04-21 12:05 [RFC 1/3] drm/i915: Use natural width type for VMA pin count Tvrtko Ursulin
2016-04-21 12:05 ` [RFC 2/3] drm/i915: Track aggregate per-object " Tvrtko Ursulin
2016-04-21 12:15 ` Chris Wilson
2016-04-21 12:53 ` Chris Wilson
2016-04-21 12:05 ` [RFC 3/3] drm/i915: Micro-optimize i915_gem_obj_to_vma Tvrtko Ursulin
2016-04-21 12:17 ` Chris Wilson
2016-04-26 10:35 ` Dave Gordon [this message]
2016-04-26 10:45 ` Chris Wilson
2016-04-21 12:16 ` [RFC 1/3] drm/i915: Use natural width type for VMA pin count Chris Wilson
2016-04-23 16:37 ` ✓ Fi.CI.BAT: success for series starting with [RFC,1/3] " 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=571F4489.80809@intel.com \
--to=david.s.gordon@intel.com \
--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