public inbox for intel-gfx@lists.freedesktop.org
 help / color / mirror / Atom feed
From: Tvrtko Ursulin <tvrtko.ursulin@linux.intel.com>
To: Niranjana Vishwanathapura <niranjana.vishwanathapura@intel.com>
Cc: paulo.r.zanoni@intel.com, intel-gfx@lists.freedesktop.org,
	dri-devel@lists.freedesktop.org, thomas.hellstrom@intel.com,
	matthew.auld@intel.com, daniel.vetter@intel.com,
	christian.koenig@amd.com
Subject: Re: [Intel-gfx] [RFC v4 13/14] drm/i915/vm_bind: Skip vma_lookup for persistent vmas
Date: Tue, 27 Sep 2022 10:28:03 +0100	[thread overview]
Message-ID: <0c73bf54-e7ef-2c64-cf09-c7e69a0c93c1@linux.intel.com> (raw)
In-Reply-To: <20220926170950.GA16345@nvishwa1-DESK>


On 26/09/2022 18:09, Niranjana Vishwanathapura wrote:
> On Mon, Sep 26, 2022 at 05:26:12PM +0100, Tvrtko Ursulin wrote:
>>
>> On 24/09/2022 05:30, Niranjana Vishwanathapura wrote:
>>> On Fri, Sep 23, 2022 at 09:40:20AM +0100, Tvrtko Ursulin wrote:
>>>>
>>>> On 21/09/2022 08:09, Niranjana Vishwanathapura wrote:
>>>>> vma_lookup is tied to segment of the object instead of section
>>>>
>>>> Can be, but not only that. It would be more accurate to say it is 
>>>> based of gtt views.
>>>
>>> Yah, but new code is also based on gtt views, the only difference
>>> is that now there can be multiple mappings (at different VAs)
>>> to the same gtt_view of the object.
>>>
>>>>
>>>>> of VA space. Hence, it do not support aliasing (ie., multiple
>>>>> bindings to the same section of the object).
>>>>> Skip vma_lookup for persistent vmas as it supports aliasing.
>>>>
>>>> What's broken without this patch? If something is, should it go 
>>>> somewhere earlier in the series? If so should be mentioned in the 
>>>> commit message.
>>>>
>>>> Or is it just a performance optimisation to skip unused tracking? If 
>>>> so should also be mentioned in the commit message.
>>>>
>>>
>>> No, it is not a performance optimization.
>>> The vma_lookup is based on the fact that there can be only one mapping
>>> for a given gtt_view of the object.
>>> So, it was looking for gtt_view to find the mapping.
>>>
>>> But now, as I mentioned above, there can be multiple mappings for a
>>> given gtt_view of the object. Hence the vma_lookup method won't work
>>> here. Hence, it is being skipped for persistent vmas.
>>
>> Right, so in that case isn't this patch too late in the series? 
>> Granted you only allow _userspace_ to use vm bind in 14/14, but the 
>> kernel infrastructure is there and if there was a selftest it would be 
>> able to fail without this patch, no?
>>
> 
> Yes it is incorrect patch ordering. I am fixing it by moving this patch
> to early in the series and adding a new i915_vma_create_persistent()
> function and avoid touching i915_vma_instance() everywhere (as you
> suggested).
> 
> <snip>
> 
>>>>> --- a/drivers/gpu/drm/i915/i915_vma.c
>>>>> +++ b/drivers/gpu/drm/i915/i915_vma.c
>>>>> @@ -110,7 +110,8 @@ static void __i915_vma_retire(struct 
>>>>> i915_active *ref)
>>>>>  static struct i915_vma *
>>>>>  vma_create(struct drm_i915_gem_object *obj,
>>>>>         struct i915_address_space *vm,
>>>>> -       const struct i915_gtt_view *view)
>>>>> +       const struct i915_gtt_view *view,
>>>>> +       bool persistent)
>>>>>  {
>>>>>      struct i915_vma *pos = ERR_PTR(-E2BIG);
>>>>>      struct i915_vma *vma;
>>>>> @@ -197,6 +198,9 @@ vma_create(struct drm_i915_gem_object *obj,
>>>>>          __set_bit(I915_VMA_GGTT_BIT, __i915_vma_flags(vma));
>>>>>      }
>>>>> +    if (persistent)
>>>>> +        goto skip_rb_insert;
>>>>
>>>> Oh so you don't use the gtt_view's fully at all. I now have 
>>>> reservations whether that was the right approach. Since you are not 
>>>> using the existing rb tree tracking I mean..
>>>>
>>>> You know if a vma is persistent right? So you could have just added 
>>>> special case for persistent vmas to __i915_vma_get_pages and still 
>>>> call intel_partial_pages from there. Maybe union over struct 
>>>> i915_gtt_view in i915_vma for either the view or struct 
>>>> intel_partial_info for persistent ones.
>>>>
>>>
>>> We are using the gtt_view fully in this patch for persistent vmas.
>>
>> I guess yours and mine definition of fully are different. :)
>>
>>> But as mentioned above, now we have support multiple mappings
>>> for the same gtt_view of the object. For this, the current
>>> vma_lookup() falls short. So, we are skipping it.
>>
>> I get it - but then, having only now noticed how it will be used, I am 
>> less convinced touching the ggtt_view code was the right approach.
>>
>> What about what I proposed above? That you just add code to 
>> __i915_vma_get_pages, which in case of a persistent VMA would call 
>> intel_partial_pages from there.
>>
>> If that works I think it's cleaner and we'd just revert the ggtt_view 
>> to gtt_view rename.
>>
> 
> I don't think that is any cleaner. We need to store the partial view
> information somewhere for the persistent vmas as well. Why not use
> the existing gtt_view for that instead of a new data structure?
> In fact long back I had such an implementation and it was looking
> odd and was suggested to use the existing infrastructure (gtt_view).
> 
> Besides, I think the current i915_vma_lookup method is no longer valid.
> (Ever since we had softpinning, lookup should have be based on the VA
> and not the vma's view of the object).

As a side note I don't think soft pinning was a problem. That did not establish a partial VMA concept, nor had any interaction view ggtt_views. It was still one obj - one vma per vm relationship.

But okay, it is okay to do it like this. I think when you change to separate create/lookup entry points for persistent it will become much cleaner. I do acknowledge you have to "hide" them from normal lookup to avoid confusing the legacy code paths.

One more note - I think patch 6 should be before or together with patch 4. In general infrastructure to handle vm bind should all be in place before code starts using it.

Regards,

Tvrtko

  reply	other threads:[~2022-09-27  9:28 UTC|newest]

Thread overview: 42+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-09-21  7:09 [Intel-gfx] [RFC v4 00/14] drm/i915/vm_bind: Add VM_BIND functionality Niranjana Vishwanathapura
2022-09-21  7:09 ` [Intel-gfx] [RFC v4 01/14] drm/i915/vm_bind: Expose vm lookup function Niranjana Vishwanathapura
2022-09-21  7:09 ` [Intel-gfx] [RFC v4 02/14] drm/i915/vm_bind: Add __i915_sw_fence_await_reservation() Niranjana Vishwanathapura
2022-09-21  9:06   ` Tvrtko Ursulin
2022-09-21 17:47     ` Niranjana Vishwanathapura
2022-09-22  9:26   ` Jani Nikula
2022-09-21  7:09 ` [Intel-gfx] [RFC v4 03/14] drm/i915/vm_bind: Expose i915_gem_object_max_page_size() Niranjana Vishwanathapura
2022-09-21  9:13   ` Tvrtko Ursulin
2022-09-21 18:00     ` Niranjana Vishwanathapura
2022-09-22  8:09       ` Tvrtko Ursulin
2022-09-22 16:18         ` Matthew Auld
2022-09-22 16:46           ` Niranjana Vishwanathapura
2022-09-23  7:45           ` Tvrtko Ursulin
2022-09-21  7:09 ` [Intel-gfx] [RFC v4 04/14] drm/i915/vm_bind: Implement bind and unbind of object Niranjana Vishwanathapura
2022-09-22  9:29   ` Jani Nikula
2022-09-21  7:09 ` [Intel-gfx] [RFC v4 05/14] drm/i915/vm_bind: Support for VM private BOs Niranjana Vishwanathapura
2022-09-21  7:09 ` [Intel-gfx] [RFC v4 06/14] drm/i915/vm_bind: Handle persistent vmas Niranjana Vishwanathapura
2022-09-27  2:36   ` Zeng, Oak
2022-09-27  5:45     ` Niranjana Vishwanathapura
2022-09-21  7:09 ` [Intel-gfx] [RFC v4 07/14] drm/i915/vm_bind: Add out fence support Niranjana Vishwanathapura
2022-09-22  9:31   ` Jani Nikula
2022-09-21  7:09 ` [Intel-gfx] [RFC v4 08/14] drm/i915/vm_bind: Abstract out common execbuf functions Niranjana Vishwanathapura
2022-09-21 10:18   ` Tvrtko Ursulin
2022-09-21 18:17     ` Niranjana Vishwanathapura
2022-09-22  9:05       ` Tvrtko Ursulin
2022-09-22 14:12         ` Niranjana Vishwanathapura
2022-09-22  9:54   ` Jani Nikula
2022-09-24  4:22     ` Niranjana Vishwanathapura
2022-09-21  7:09 ` [Intel-gfx] [RFC v4 09/14] drm/i915/vm_bind: Implement I915_GEM_EXECBUFFER3 ioctl Niranjana Vishwanathapura
2022-09-21  7:09 ` [Intel-gfx] [RFC v4 10/14] drm/i915/vm_bind: Update i915_vma_verify_bind_complete() Niranjana Vishwanathapura
2022-09-21  7:09 ` [Intel-gfx] [RFC v4 11/14] drm/i915/vm_bind: Handle persistent vmas in execbuf3 Niranjana Vishwanathapura
2022-09-21  7:09 ` [Intel-gfx] [RFC v4 12/14] drm/i915/vm_bind: userptr dma-resv changes Niranjana Vishwanathapura
2022-09-21  7:09 ` [Intel-gfx] [RFC v4 13/14] drm/i915/vm_bind: Skip vma_lookup for persistent vmas Niranjana Vishwanathapura
2022-09-23  8:40   ` Tvrtko Ursulin
2022-09-24  4:30     ` Niranjana Vishwanathapura
2022-09-26 16:26       ` Tvrtko Ursulin
2022-09-26 17:09         ` Niranjana Vishwanathapura
2022-09-27  9:28           ` Tvrtko Ursulin [this message]
2022-09-27 15:37             ` Niranjana Vishwanathapura
2022-09-21  7:09 ` [Intel-gfx] [RFC v4 14/14] drm/i915/vm_bind: Add uapi for user to enable vm_bind_mode Niranjana Vishwanathapura
2022-09-21  8:33 ` [Intel-gfx] ✗ Fi.CI.CHECKPATCH: warning for drm/i915/vm_bind: Add VM_BIND functionality (rev3) Patchwork
2022-09-21  8:55 ` [Intel-gfx] ✗ Fi.CI.BAT: failure " 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=0c73bf54-e7ef-2c64-cf09-c7e69a0c93c1@linux.intel.com \
    --to=tvrtko.ursulin@linux.intel.com \
    --cc=christian.koenig@amd.com \
    --cc=daniel.vetter@intel.com \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=intel-gfx@lists.freedesktop.org \
    --cc=matthew.auld@intel.com \
    --cc=niranjana.vishwanathapura@intel.com \
    --cc=paulo.r.zanoni@intel.com \
    --cc=thomas.hellstrom@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