From: Tvrtko Ursulin <tvrtko.ursulin@linux.intel.com>
To: Chris Wilson <chris@chris-wilson.co.uk>,
Tvrtko Ursulin <tursulin@ursulin.net>,
Intel-gfx@lists.freedesktop.org,
Tvrtko Ursulin <tvrtko.ursulin@intel.com>
Subject: Re: [PATCH] drm/i915: Optimise VMA lookup slightly
Date: Tue, 13 Dec 2016 14:40:00 +0000 [thread overview]
Message-ID: <a0596f11-e323-e62b-6fdf-0546c2d42823@linux.intel.com> (raw)
In-Reply-To: <20161213134100.GQ20316@nuc-i3427.alporthouse.com>
On 13/12/2016 13:41, Chris Wilson wrote:
> On Tue, Dec 13, 2016 at 01:30:19PM +0000, Tvrtko Ursulin wrote:
>>
>> On 13/12/2016 12:41, Chris Wilson wrote:
>>> On Tue, Dec 13, 2016 at 12:22:18PM +0000, Tvrtko Ursulin wrote:
>>>> From: Tvrtko Ursulin <tvrtko.ursulin@intel.com>
>>>>
>>>> A few details to hopefully make a very hot function a tiny bit
>>>> more efficient:
>>>>
>>>> 1. Cast VM pointers before substraction to save the compiler
>>>> doing a smart one which includes multiplication.
>>>
>>> Indeed. Not pretty though.
>>>
>>> static always_inline __kernel_ptrdiff_t ptrdiff(const void *a, const void *b)
>>> {
>>> return a - b;
>>> }
>>>
>>> cmp = ptrdiff(vma->vm, vm);
>>> if (cmp)
>>> return cmp;
>>
>> Pffifle as you would say. :)
>>
>>>> 2. Use smaller type for comparison since we only care about
>>>> the sign.
>>>
>>> Should be a no-op since the compiler also should only care about the
>>> sign and not be moving the registers about, just the cc and we should be
>>> inlining... Is gcc not smart enough? :(
>>
>> I am pretty sure there was a significant difference in the size of
>> generated code so apparently it isn't.
>
> If you have two available, can you attach the asm?
http://paste.debian.net/901995/ if you can figure it out.
Dropped it from v2 though.
>>>> 3. Prefer the ppgtt lookup branch and inline it, allowing the
>>>> compiler to optimise out the second part of i915_vma_compare
>>>> and save one call indirection.
>>>
>>> This runs counter to a better optimisation that completely avoids
>>> calling obj_to_vma for ppgtt lookups (i.e. in execbuffer we go straight
>> >from handle to vma, skipping the handle to obj intermediate lookup).
>>>
>>> Primary caller for this function should be ggtt users, with single
>>> negative lookups before creating the ppgtt vma.
>>
>> Empirically ppgtt users call this much much more on any benchmarks
>> I've tried since with the change all I see is lookup_and_create in
>> the profiles and not obj_to_vma.
>
> Exactly, hence why we should tackle the root of the problem... Replace a
> slow idr lookup and rbtree walk with a direct lookup (hashtable) from
> the fpriv. Since it doesn't just affect full-ppgtt but the introduction
> of the second lookup regressed everyone,
> https://bugs.freedesktop.org/show_bug.cgi?id=87131 and the myriad of
> igt/benchmark/gem_exec_reloc benchmarks.
Dropped this from v2 as well, only kept ptrdiff.
Will have a look around for the things you mentioned here.
Regards,
Tvrtko
_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx
next prev parent reply other threads:[~2016-12-13 14:40 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-12-13 12:22 [PATCH] drm/i915: Optimise VMA lookup slightly Tvrtko Ursulin
2016-12-13 12:41 ` Chris Wilson
2016-12-13 13:30 ` Tvrtko Ursulin
2016-12-13 13:41 ` Chris Wilson
2016-12-13 14:37 ` [PATCH v2] " Tvrtko Ursulin
2016-12-13 14:47 ` Chris Wilson
2016-12-15 16:49 ` Tvrtko Ursulin
2016-12-15 17:08 ` Chris Wilson
2016-12-13 14:40 ` Tvrtko Ursulin [this message]
2016-12-13 12:45 ` ✓ Fi.CI.BAT: success for " Patchwork
2016-12-13 17:23 ` ✗ Fi.CI.BAT: warning for drm/i915: Optimise VMA lookup slightly (rev2) Patchwork
2016-12-15 13:33 ` Tvrtko Ursulin
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=a0596f11-e323-e62b-6fdf-0546c2d42823@linux.intel.com \
--to=tvrtko.ursulin@linux.intel.com \
--cc=Intel-gfx@lists.freedesktop.org \
--cc=chris@chris-wilson.co.uk \
--cc=tursulin@ursulin.net \
--cc=tvrtko.ursulin@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