From: Tvrtko Ursulin <tursulin@ursulin.net>
To: Intel-gfx@lists.freedesktop.org
Subject: [PATCH v2] drm/i915: Optimise VMA lookup slightly
Date: Tue, 13 Dec 2016 14:37:27 +0000 [thread overview]
Message-ID: <1481639847-9214-1-git-send-email-tvrtko.ursulin@linux.intel.com> (raw)
In-Reply-To: <20161213134100.GQ20316@nuc-i3427.alporthouse.com>
From: Tvrtko Ursulin <tvrtko.ursulin@intel.com>
Cast VM pointers before substraction to save the compiler
doing a smart one which includes multiplication.
v2: Only keep the first optimisation and prettify it. (Chris Wilson)
Signed-off-by: Tvrtko Ursulin <tvrtko.ursulin@intel.com>
Cc: Chris Wilson <chris@chris-wilson.co.uk>
---
drivers/gpu/drm/i915/i915_vma.h | 12 ++++++++++--
1 file changed, 10 insertions(+), 2 deletions(-)
diff --git a/drivers/gpu/drm/i915/i915_vma.h b/drivers/gpu/drm/i915/i915_vma.h
index 21be74c61065..e3b2b3b1e056 100644
--- a/drivers/gpu/drm/i915/i915_vma.h
+++ b/drivers/gpu/drm/i915/i915_vma.h
@@ -178,15 +178,23 @@ static inline void i915_vma_put(struct i915_vma *vma)
i915_gem_object_put(vma->obj);
}
+static __always_inline ptrdiff_t ptrdiff(const void *a, const void *b)
+{
+ return a - b;
+}
+
static inline long
i915_vma_compare(struct i915_vma *vma,
struct i915_address_space *vm,
const struct i915_ggtt_view *view)
{
+ ptrdiff_t cmp;
+
GEM_BUG_ON(view && !i915_is_ggtt(vm));
- if (vma->vm != vm)
- return vma->vm - vm;
+ cmp = ptrdiff(vma->vm, vm);
+ if (cmp)
+ return cmp;
if (!view)
return vma->ggtt_view.type;
--
2.7.4
_______________________________________________
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:37 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 ` Tvrtko Ursulin [this message]
2016-12-13 14:47 ` [PATCH v2] " Chris Wilson
2016-12-15 16:49 ` Tvrtko Ursulin
2016-12-15 17:08 ` Chris Wilson
2016-12-13 14:40 ` [PATCH] " Tvrtko Ursulin
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=1481639847-9214-1-git-send-email-tvrtko.ursulin@linux.intel.com \
--to=tursulin@ursulin.net \
--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