From: Tvrtko Ursulin <tvrtko.ursulin@linux.intel.com>
To: Chris Wilson <chris@chris-wilson.co.uk>, intel-gfx@lists.freedesktop.org
Subject: Re: [PATCH 6/6] drm/i915: Avoid allocating a vmap arena for a single page
Date: Wed, 6 Apr 2016 12:36:48 +0100 [thread overview]
Message-ID: <5704F4D0.8060005@linux.intel.com> (raw)
In-Reply-To: <20160406100529.GH18736@nuc-i3427.alporthouse.com>
On 06/04/16 11:05, Chris Wilson wrote:
> On Wed, Apr 06, 2016 at 10:49:36AM +0100, Tvrtko Ursulin wrote:
>>> diff --git a/drivers/gpu/drm/i915/i915_gem.c b/drivers/gpu/drm/i915/i915_gem.c
>>> index 985f067c1f0e..dc8e1b76c896 100644
>>> --- a/drivers/gpu/drm/i915/i915_gem.c
>>> +++ b/drivers/gpu/drm/i915/i915_gem.c
>>> @@ -2233,7 +2233,10 @@ i915_gem_object_put_pages(struct drm_i915_gem_object *obj)
>>> list_del(&obj->global_list);
>>>
>>> if (obj->vmapping) {
>>> - vunmap(obj->vmapping);
>>> + if (obj->base.size == PAGE_SIZE)
>>> + kunmap(kmap_to_page(obj->vmapping));
>>> + else
>>> + vunmap(obj->vmapping);
>>
>> Can't think of a reason why it would be better but there is also
>> is_vmalloc_addr(addr) as used by kvfree.
>
> For consistency with the shrinker (see below).
>
>>> obj->vmapping = NULL;
>>> }
>>>
>>> @@ -2416,15 +2419,22 @@ void *i915_gem_object_pin_vmap(struct drm_i915_gem_object *obj)
>>> i915_gem_object_pin_pages(obj);
>>>
>>> if (obj->vmapping == NULL) {
>>> - struct sg_page_iter sg_iter;
>>> struct page **pages;
>>> - int n;
>>>
>>> - n = obj->base.size >> PAGE_SHIFT;
>>> - pages = drm_malloc_gfp(n, sizeof(*pages), GFP_TEMPORARY);
>>> + pages = NULL;
>>> + if (obj->base.size == PAGE_SIZE)
>>> + obj->vmapping = kmap(sg_page(obj->pages->sgl));
>>> + else
>>> + pages = drm_malloc_gfp(obj->base.size >> PAGE_SHIFT,
>>> + sizeof(*pages),
>>> + GFP_TEMPORARY);
>>> if (pages != NULL) {
>>> + struct sg_page_iter sg_iter;
>>> + int n;
>>> +
>>> n = 0;
>>> - for_each_sg_page(obj->pages->sgl, &sg_iter, obj->pages->nents, 0)
>>> + for_each_sg_page(obj->pages->sgl, &sg_iter,
>>> + obj->pages->nents, 0)
>>> pages[n++] = sg_page_iter_page(&sg_iter);
>>>
>>> obj->vmapping = vmap(pages, n, 0, PAGE_KERNEL);
>>>
>>
>> Two problems I can spot are:
>>
>> 1. Callers of pin_vmap now don't know which kind of address they are
>> getting. Maybe call it pin_kvmap or something? Just mention in
>> kerneldoc could be enough.
>
> I think just mention, and we can rename this to i915_gem_object_pin_map().
> Hmm. I liked the pin in the name since it ties to to pin_pages (later
> I plan to change that to get_pages and get_vmap/get_map as the pin
> becomes implicit).
>
>> 2. Shrinker will try to kick out kmapped objects because they have
>> obj->vmapping set.
>
> Not caring that much since the vmap_purge is very heavy weight, but we
> can apply is_vmalloc_addr() to the shrinker.
>
> Ok, happy to call this obj->mapping and i915_gem_object_pin_map() ?
Sounds good. (Including the is_vmalloc_addr() smartening in the shrinker.)
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-04-06 11:36 UTC|newest]
Thread overview: 21+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-04-05 12:57 vmap consolidation Chris Wilson
2016-04-05 12:57 ` [PATCH 1/6] drm/i915/dmabuf: Tighten struct_mutex for unmap_dma_buf Chris Wilson
2016-04-06 8:57 ` Tvrtko Ursulin
2016-04-05 12:57 ` [PATCH 2/6] drm/i915: Consolidate common error handling in intel_pin_and_map_ringbuffer_obj Chris Wilson
2016-04-06 9:02 ` Tvrtko Ursulin
2016-04-05 12:57 ` [PATCH 3/6] drm/i915: Refactor duplicate object vmap functions Chris Wilson
2016-04-06 9:30 ` Tvrtko Ursulin
2016-04-06 9:58 ` Chris Wilson
2016-04-05 12:57 ` [PATCH 4/6] drm/i915/shrinker: Restrict vmap purge to objects with vmaps Chris Wilson
2016-04-05 12:57 ` [PATCH 5/6] drm,i915: Introduce drm_malloc_gfp() Chris Wilson
2016-04-05 13:05 ` Chris Wilson
2016-04-06 9:40 ` Tvrtko Ursulin
2016-04-06 9:47 ` Chris Wilson
2016-04-05 12:57 ` [PATCH 6/6] drm/i915: Avoid allocating a vmap arena for a single page Chris Wilson
2016-04-05 13:01 ` Chris Wilson
2016-04-05 13:14 ` Matthew Auld
2016-04-06 9:49 ` Tvrtko Ursulin
2016-04-06 10:05 ` Chris Wilson
2016-04-06 11:36 ` Tvrtko Ursulin [this message]
2016-04-06 13:52 ` Dave Gordon
2016-04-05 15:57 ` ✗ Fi.CI.BAT: failure for series starting with [1/6] drm/i915/dmabuf: Tighten struct_mutex for unmap_dma_buf 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=5704F4D0.8060005@linux.intel.com \
--to=tvrtko.ursulin@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