From: Dave Gordon <david.s.gordon@intel.com>
To: intel-gfx@lists.freedesktop.org
Subject: [PATCH v4 3/3] drm/i915: optimise i915_gem_object_vmap_range() for small objects
Date: Mon, 22 Feb 2016 15:18:28 +0000 [thread overview]
Message-ID: <1456154308-9342-4-git-send-email-david.s.gordon@intel.com> (raw)
In-Reply-To: <1456154308-9342-1-git-send-email-david.s.gordon@intel.com>
Now that we use this function for ringbuffers and other "small" objects,
it's worth avoiding an extra kmalloc()/kfree() cycle if the page array
is small enough to put on the stack. Here we've chosen an arbitrary
cutoff of 32 (4k) pages, which is big enough for a ringbuffer (4 pages)
or a context image (currently up to 22 pages).
Signed-off-by: Dave Gordon <david.s.gordon@intel.com>
Cc: Tvrtko Ursulin <tvrtko.ursulin@intel.com>
Cc: Alex Dai <yu.dai@intel.com>
Cc: Chris Wilson <chris@chris-wilson.co.uk>
---
drivers/gpu/drm/i915/i915_gem.c | 18 +++++++++++++-----
1 file changed, 13 insertions(+), 5 deletions(-)
diff --git a/drivers/gpu/drm/i915/i915_gem.c b/drivers/gpu/drm/i915/i915_gem.c
index 14942cf..effb69b 100644
--- a/drivers/gpu/drm/i915/i915_gem.c
+++ b/drivers/gpu/drm/i915/i915_gem.c
@@ -2422,6 +2422,7 @@ void *i915_gem_object_vmap_range(struct drm_i915_gem_object *obj,
unsigned int npages)
{
struct sg_page_iter sg_iter;
+ struct page *mypages[32];
struct page **pages;
void *addr;
int i;
@@ -2431,10 +2432,16 @@ void *i915_gem_object_vmap_range(struct drm_i915_gem_object *obj,
return NULL;
}
- pages = drm_malloc_ab(npages, sizeof(*pages));
- if (pages == NULL) {
- DRM_DEBUG_DRIVER("Failed to get space for pages\n");
- return NULL;
+ if (npages <= ARRAY_SIZE(mypages))
+ pages = mypages;
+ else {
+ pages = kmalloc(npages*sizeof(*pages), GFP_TEMPORARY | __GFP_NOWARN);
+ if (pages == NULL)
+ pages = drm_malloc_ab(npages, sizeof(*pages));
+ if (pages == NULL) {
+ DRM_DEBUG_DRIVER("Failed to get space for pages\n");
+ return NULL;
+ }
}
i = 0;
@@ -2447,7 +2454,8 @@ void *i915_gem_object_vmap_range(struct drm_i915_gem_object *obj,
addr = vmap(pages, npages, 0, PAGE_KERNEL);
if (addr == NULL)
DRM_DEBUG_DRIVER("Failed to vmap pages\n");
- drm_free_large(pages);
+ if (pages != mypages)
+ drm_free_large(pages);
return addr;
}
--
1.9.1
_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx
next prev parent reply other threads:[~2016-02-22 15:19 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-02-22 15:18 [PATCH v4 0/3] Reorganise calls to vmap() GEM objects Dave Gordon
2016-02-22 15:18 ` [PATCH v4 1/3] drm/i915: add i915_gem_object_vmap_range() to map GEM object to virtual space Dave Gordon
2016-02-22 15:18 ` [PATCH v4 2/3] drm/i915: refactor duplicate object vmap functions (reworked) Dave Gordon
2016-02-22 16:06 ` Tvrtko Ursulin
2016-02-23 10:06 ` Chris Wilson
2016-02-23 10:31 ` Tvrtko Ursulin
2016-02-23 11:38 ` Chris Wilson
2016-02-23 11:52 ` Chris Wilson
2016-02-23 12:25 ` Tvrtko Ursulin
2016-02-23 12:56 ` Chris Wilson
2016-02-22 15:18 ` Dave Gordon [this message]
2016-02-23 10:16 ` [PATCH v4 3/3] drm/i915: optimise i915_gem_object_vmap_range() for small objects Chris Wilson
2016-02-23 8:37 ` ✗ Fi.CI.BAT: failure for Reorganise calls to vmap() GEM objects Patchwork
2016-02-23 10:59 ` 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=1456154308-9342-4-git-send-email-david.s.gordon@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;
as well as URLs for NNTP newsgroup(s).