All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Christian König" <christian.koenig@amd.com>
To: Daniel Vetter <daniel@ffwll.ch>
Cc: Jack Zhang <Jack.Zhang1@amd.com>,
	DRI Development <dri-devel@lists.freedesktop.org>,
	Luben Tuikov <luben.tuikov@amd.com>,
	Alex Deucher <alexander.deucher@amd.com>,
	Daniel Vetter <daniel.vetter@intel.com>
Subject: Re: [PATCH 10/11] drm/scheduler: Don't store self-dependencies
Date: Thu, 24 Jun 2021 19:56:10 +0200	[thread overview]
Message-ID: <fe537d78-0737-f1b1-a740-66efa93e94a9@amd.com> (raw)
In-Reply-To: <CAKMK7uGmXiPUJEyC87bS5vTCtHTG7HFP=C-DQA0pQHB6mpB66A@mail.gmail.com>

Am 24.06.21 um 19:43 schrieb Daniel Vetter:
> On Thu, Jun 24, 2021 at 7:38 PM Christian König
> <christian.koenig@amd.com> wrote:
>> Am 24.06.21 um 19:29 schrieb Daniel Vetter:
>>> On Thu, Jun 24, 2021 at 07:03:10PM +0200, Christian König wrote:
>>>> Am 24.06.21 um 16:00 schrieb Daniel Vetter:
>>>>> This is essentially part of drm_sched_dependency_optimized(), which
>>>>> only amdgpu seems to make use of. Use it a bit more.
>>>>>
>>>>> Signed-off-by: Daniel Vetter <daniel.vetter@intel.com>
>>>>> Cc: "Christian König" <christian.koenig@amd.com>
>>>>> Cc: Daniel Vetter <daniel.vetter@ffwll.ch>
>>>>> Cc: Luben Tuikov <luben.tuikov@amd.com>
>>>>> Cc: Andrey Grodzovsky <andrey.grodzovsky@amd.com>
>>>>> Cc: Alex Deucher <alexander.deucher@amd.com>
>>>>> Cc: Jack Zhang <Jack.Zhang1@amd.com>
>>>>> ---
>>>>>     drivers/gpu/drm/scheduler/sched_main.c | 7 +++++++
>>>>>     1 file changed, 7 insertions(+)
>>>>>
>>>>> diff --git a/drivers/gpu/drm/scheduler/sched_main.c b/drivers/gpu/drm/scheduler/sched_main.c
>>>>> index 370c336d383f..c31d7cf7df74 100644
>>>>> --- a/drivers/gpu/drm/scheduler/sched_main.c
>>>>> +++ b/drivers/gpu/drm/scheduler/sched_main.c
>>>>> @@ -649,6 +649,13 @@ int drm_sched_job_await_fence(struct drm_sched_job *job,
>>>>>      if (!fence)
>>>>>              return 0;
>>>>> +   /* if it's a fence from us it's guaranteed to be earlier */
>>>>> +   if (fence->context == job->entity->fence_context ||
>>>>> +       fence->context == job->entity->fence_context + 1) {
>>>>> +           dma_fence_put(fence);
>>>>> +           return 0;
>>>>> +   }
>>>>> +
>>>> Well NAK. That would break Vulkan.
> I'm assuming your reply means the NAK is retracted and was just the
> usual "this doesn't perfectly fit for amdgpu" reflex?

Well rather "NAK, you haven't considered that special handling in amdgpu 
and if you really want to unify this you need that as well."

>
>>>> The problem is that Vulkan can insert dependencies between jobs which run on
>>>> the same queue.
>>>>
>>>> So we need to track those as well and if the previous job for the same
>>>> queue/scheduler is not yet finished a pipeline synchronization needs to be
>>>> inserted.
>>>>
>>>> That's one of the reasons we wasn't able to unify the dependency handling
>>>> yet.
>>> That sounds like an extremely amdgpu specific constraint?
>> Yeah, that's totally hardware specific.
>>
>> It's just that I don't know how else we could track that without having
>> the same separation as in amdgpu between implicit and explicit fences.
>> And as far as I understand it that's exactly what you want to avoid.
>>
>> As I said this turned out to be really awkward.
>>
>>> You're also the
>>> only one who keeps track of whether the previous job we've scheduled has
>>> finished already (I guess they can get pipelined and you don't flush by
>>> default), so you insert fences.
>> Yes, exactly that.
>>
>>> I guess we can add a await_fence_no_dedup or so for amdgpu, but I'm not
>>> sure why we have to inflict this design constraint on all other drivers?
>>> At least I'm not seeing anything in lima, panfrost, v3d or entaviv that
>>> would break with this, and i915 will also be perfectly fine.
>>>
>>> Also note: I'm not using this for amdgpu, exactly because there's a few
>>> funny things going on.
>> Yeah, exactly the reason why we never unified this.
> Yeah there's clear limits to this, because you also can't use the
> await_implicit helper, because you have to keep filtering for owner or
> the current amdgpu uapi goes horribly slow. I think the benefit would
> be just that we could share the datastructure and the book-keeping,
> but aside from that you'd need your own integration in amdgpu.

Yeah, but that is trivial. The _add_dependency() function (or however we 
want to call it) needs to be exported anyway for adding fences from 
syncfile and syncobj.

Or do you also want to unify the handling for those?

> One idea I just had was whether we could use the tag bits xarray has
> for the amdgpu purposed. Like we could do a
> drm_sched_job_await_fence_tagged, where you supply additional
> information (like the "this might be relevant for the vm_flush" and
> things like that). Afaiui xarray tags are very fast to enumerate on if
> you're looking for specific tags, but I might be wrong. Ideally this
> would avoid the need for the duplicated amdgpu_job->sched.

That could work.

Essentially we just need the information from the scheduler which is the 
last fence which was dependency optimized.

In other words when you push jobs like those to the same scheduler

J1
J2 -> depends on J1.
J3 -> depends on whatever, but not j2

The hardware needs to insert a flush between J2 and J1, but not between 
j3 and j2.

This makes roughly 19% performance difference for some OpenGL games and 
incorrect rendering for Vulkan if you mess it up either way or the other.

Regards,
Christian.


>
> Cheers, Daniel
>
>
>> Regards,
>> Christian.
>>
>>> Finally: You _really_ need explicit dependency handling for vulkan in your
>>> uapi, instead of the kernel second-guessing what userspace might be doing.
>>> That's really not how vulkan is designed to work :-)
>>> Cheers, Daniel
>>>
>>>
>>>> Christian.
>>>>
>>>>>      /* Deduplicate if we already depend on a fence from the same context.
>>>>>       * This lets the size of the array of deps scale with the number of
>>>>>       * engines involved, rather than the number of BOs.
>


  reply	other threads:[~2021-06-24 17:56 UTC|newest]

Thread overview: 57+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-06-24 14:00 [PATCH 00/11] drm/scheduler dependency tracking Daniel Vetter
2021-06-24 14:00 ` [PATCH 01/11] drm/sched: Split drm_sched_job_init Daniel Vetter
2021-06-24 14:00   ` Daniel Vetter
2021-06-24 14:32   ` Steven Price
2021-06-24 14:32     ` Steven Price
2021-06-24 17:29   ` Christian König
2021-06-24 17:29     ` Christian König
2021-06-24 17:37     ` Daniel Vetter
2021-06-24 17:37       ` Daniel Vetter
2021-06-24 17:39       ` Christian König
2021-06-24 17:39         ` Christian König
2021-06-24 18:22         ` Daniel Vetter
2021-06-24 18:22           ` Daniel Vetter
2021-06-24 20:45   ` [PATCH] " Daniel Vetter
2021-06-24 20:45     ` Daniel Vetter
2021-06-24 21:00     ` Emma Anholt
2021-06-24 21:00       ` Emma Anholt
2021-06-24 21:30       ` Daniel Vetter
2021-06-24 21:30         ` Daniel Vetter
2021-06-24 14:00 ` [PATCH 02/11] drm/sched: Add dependency tracking Daniel Vetter
2021-06-24 14:00   ` Daniel Vetter
2021-06-24 14:32   ` Steven Price
2021-06-24 14:32     ` Steven Price
2021-06-24 14:39   ` Lucas Stach
2021-06-24 14:39     ` Lucas Stach
2021-06-24 15:26     ` Daniel Vetter
2021-06-24 15:26       ` Daniel Vetter
2021-06-24 16:59     ` Christian König
2021-06-24 16:59       ` Christian König
2021-06-24 14:00 ` [PATCH 03/11] drm/sched: drop entity parameter from drm_sched_push_job Daniel Vetter
2021-06-24 14:00   ` Daniel Vetter
2021-06-24 14:32   ` Steven Price
2021-06-24 14:32     ` Steven Price
2021-06-24 14:00 ` [PATCH 04/11] drm/panfrost: use scheduler dependency tracking Daniel Vetter
2021-06-24 14:00   ` Daniel Vetter
2021-06-24 14:32   ` Steven Price
2021-06-24 14:32     ` Steven Price
2021-06-24 14:00 ` [PATCH 05/11] drm/lima: " Daniel Vetter
2021-06-24 14:00 ` [PATCH 06/11] drm/v3d: Move drm_sched_job_init to v3d_job_init Daniel Vetter
2021-06-24 16:59   ` Emma Anholt
2021-06-24 17:24     ` Daniel Vetter
2021-06-24 20:45   ` [PATCH] " Daniel Vetter
2021-06-24 20:49     ` Emma Anholt
2021-06-24 14:00 ` [PATCH 07/11] drm/v3d: Use scheduler dependency handling Daniel Vetter
2021-06-24 14:00 ` [PATCH 08/11] drm/etnaviv: " Daniel Vetter
2021-06-24 14:00   ` Daniel Vetter
2021-06-24 14:00 ` [PATCH 09/11] drm/gem: Delete gem array fencing helpers Daniel Vetter
2021-06-24 14:00   ` Daniel Vetter
2021-06-24 14:00 ` [PATCH 10/11] drm/scheduler: Don't store self-dependencies Daniel Vetter
2021-06-24 14:42   ` Lucas Stach
2021-06-24 17:03   ` Christian König
2021-06-24 17:29     ` Daniel Vetter
2021-06-24 17:38       ` Christian König
2021-06-24 17:43         ` Daniel Vetter
2021-06-24 17:56           ` Christian König [this message]
2021-06-24 18:21             ` Daniel Vetter
2021-06-24 14:00 ` [PATCH 11/11] drm/sched: Check locking in drm_sched_job_await_implicit Daniel Vetter

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=fe537d78-0737-f1b1-a740-66efa93e94a9@amd.com \
    --to=christian.koenig@amd.com \
    --cc=Jack.Zhang1@amd.com \
    --cc=alexander.deucher@amd.com \
    --cc=daniel.vetter@intel.com \
    --cc=daniel@ffwll.ch \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=luben.tuikov@amd.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.