From: Daniel Vetter <daniel@ffwll.ch>
To: "Christian König" <christian.koenig@amd.com>
Cc: Matthew Brost <matthew.brost@intel.com>,
robdclark@chromium.org, thomas.hellstrom@linux.intel.com,
airlied@linux.ie, lina@asahilina.net,
dri-devel@lists.freedesktop.org, boris.brezillon@collabora.com,
intel-xe@lists.freedesktop.org, faith.ekstrand@collabora.com
Subject: Re: [RFC PATCH 00/10] Xe DRM scheduler and long running workload plans
Date: Thu, 6 Apr 2023 12:32:47 +0200 [thread overview]
Message-ID: <ZC6fz8IeOIabg10u@phenom.ffwll.local> (raw)
In-Reply-To: <cf04d0a6-3485-a1aa-8514-a0ecb4266f03@amd.com>
On Thu, Apr 06, 2023 at 12:14:36PM +0200, Christian König wrote:
> Am 06.04.23 um 08:37 schrieb Daniel Vetter:
> > On Thu, Apr 06, 2023 at 02:08:10AM +0000, Matthew Brost wrote:
> > > On Wed, Apr 05, 2023 at 12:12:27PM +0200, Daniel Vetter wrote:
> > > > On Wed, 5 Apr 2023 at 11:57, Christian König <christian.koenig@amd.com> wrote:
> > > > > Am 05.04.23 um 11:07 schrieb Daniel Vetter:
> > > > > > [SNIP]
> > > > > > > I would approach it from the complete other side. This component here is a
> > > > > > > tool to decide what job should run next.
> > > > > > >
> > > > > > > How that is then signaled and run should not be part of the scheduler, but
> > > > > > > another more higher level component.
> > > > > > >
> > > > > > > This way you also don't have a problem with not using DMA-fences as
> > > > > > > dependencies as well as constrains for running more jobs.
> > > > > > I think we're talking about two things here and mixing them up.
> > > > > >
> > > > > > For the dependencies I agree with you, and imo that higher level tool
> > > > > > should probably just be an on-demand submit thread in userspace for the
> > > > > > rare case where the kernel would need to sort out a dependency otherwise
> > > > > > (due to running out of ringspace in the per-ctx ringbuffer).
> > > > > >
> > > > > > The other thing is the message passing stuff, and this is what I was
> > > > > > talking about above. This has nothing to do with handling dependencies,
> > > > > > but with talking to the gpu fw. Here the intel design issue is that the fw
> > > > > > only provides a single queue, and it's in-order. Which means it
> > > > > > fundamentally has the stalling issue you describe as a point against a
> > > > > > message passing design. And fundamentally we need to be able to talk to
> > > > > > the fw in the scheduler ->run_job callback.
> > > > > >
> > > > > > The proposal here for the message passing part is that since it has the
> > > > > > stalling issue already anyway, and the scheduler needs to be involved
> > > > > > anyway, it makes sense to integrated this (as an optional thing, only for
> > > > > > drivers which have this kind of fw interface) into the scheduler.
> > > > > > Otherwise you just end up with two layers for no reason and more ping-pong
> > > > > > delay because the ->run_job needs to kick off the subordinate driver layer
> > > > > > first. Note that for this case the optional message passing support in the
> > > > > > drm/scheduler actually makes things better, because it allows you to cut
> > > > > > out one layer.
> > > > > >
> > > > > > Of course if a driver with better fw interface uses this message passing
> > > > > > support, then that's bad. Hence the big warning in the kerneldoc.
> > > > > Well what I wanted to say is that if you design the dependency handling
> > > > > / scheduler properly you don't need the message passing through it.
> > > > >
> > > > > For example if the GPU scheduler component uses a work item to do it's
> > > > > handling instead of a kthread you could also let the driver specify the
> > > > > work queue where this work item is executed on.
> > > > >
> > > > > When you design it like this the driver specifies the thread context of
> > > > > execution for it's job. In other words it can specify a single threaded
> > > > > firmware work queue as well.
> > > > >
> > > > > When you then have other messages which needs to be passed to the
> > > > > firmware you can also use the same single threaded workqueue for this.
> > > > >
> > > > > Drivers which have a different firmware interface would just use one of
> > > > > the system work queues instead.
> > > > >
> > > > > This approach basically decouples the GPU scheduler component from the
> > > > > message passing functionality.
> > > > Hm I guess we've been talking past each another big time, because
> > > > that's really what I thought was under discussions? Essentially the
> > > > current rfc, but implementing with some polish.
> > > >
> > > I think Daniel pretty much nailed it here (thanks), to recap:
> > >
> > > 1. I want the messages in the same worker so run_job / free_job /
> > > process_msg execution is mutual exclusive and also so during reset paths
> > > if the worker is stopped all the entry points can't be entered.
> > >
> > > If this is a NAK, then another worker is fine I guess. A lock between
> > > run_job / free_job + process_msg should solve the exclusion issue and the
> > > reset paths can also stop this new worker too. That being said I'd
> > > rather leave this as is but will not fight this point.
> > >
> > > 2. process_msg is just used to communicate with the firmware using the
> > > same queue as submission. Waiting for space in this queue is the only
> > > place this function can block (same as submission), well actually we
> > > have the concept a preempt time slice but that sleeps for 10 ms by
> > > default. Also preempt is only used in LR entities so I don't think it is
> > > relavent in this case either.
> > >
> > > 3. Agree this is in the dma-fence signaling path (if process_msg is in
> > > the submission worker) so we can't block indefinitely or an unreasonable
> > > period of time (i.e. we must obey dma-fence rules).
> > Just to hammer this in: Not just process_msg is in the dma_fence signaling
> > path, but the entire fw queue where everything is being funneled through,
> > including whatever the fw is doing to process these.
> >
> > Yes this is terrible and blew up a few times already :-/
> >
> > But also, probably something that the docs really need to hammer in, to
> > make sure people don't look at this and thinkg "hey this seems to be the
> > recommended way to do this on linux". We don't want hw people to build
> > more of these designs, they're an absolute pain to deal with with Linux'
> > dma_fence signalling and gpu job scheduling rules.
> >
> > It's just that if you're stuck with such fw, then integrating the flow
> > into drm/sched instead of having an extra layer of workers seems the
> > better of two pretty bad solutions.
>
> Yeah and if you have such fw limitations, make sure that you use something
> which is understood by lockdep to feed into it.
>
> In other words, either locks or work item/queue and not some message passing
> functionality through the scheduler.
>
> As far as I can see the approach with the work item/queue should fit your
> needs here.
dma_fence signalling annotations would also make the scheduler thread
suitable to catch issues with lockdep, just to make double-sure it can
catch issues.
-Daniel
>
> Christian.
>
> > -Daniel
> >
> > > 4. Agree the documentation for thw usage of the messaging interface
> > > needs to be clear.
> > >
> > > 5. Agree that my code could alway use polishing.
> > >
> > > Lets close on #1 then can I get on general Ack on this part of the RFC
> > > and apply the polish in the full review process?
> > >
> > > Matt
> > >
> > > > iow I agree with you (I think at least).
> > > > -Daniel
> > > > --
> > > > Daniel Vetter
> > > > Software Engineer, Intel Corporation
> > > > http://blog.ffwll.ch
>
--
Daniel Vetter
Software Engineer, Intel Corporation
http://blog.ffwll.ch
next prev parent reply other threads:[~2023-04-06 10:32 UTC|newest]
Thread overview: 86+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-04-04 0:22 [RFC PATCH 00/10] Xe DRM scheduler and long running workload plans Matthew Brost
2023-04-04 0:22 ` [RFC PATCH 01/10] drm/sched: Convert drm scheduler to use a work queue rather than kthread Matthew Brost
2023-06-09 6:58 ` Boris Brezillon
2023-07-31 0:56 ` Matthew Brost
2023-04-04 0:22 ` [RFC PATCH 02/10] drm/sched: Move schedule policy to scheduler / entity Matthew Brost
2023-04-05 17:37 ` Luben Tuikov
2023-04-05 18:29 ` Matthew Brost
2023-04-04 0:22 ` [RFC PATCH 03/10] drm/sched: Add DRM_SCHED_POLICY_SINGLE_ENTITY scheduling policy Matthew Brost
2023-04-04 0:22 ` [RFC PATCH 04/10] drm/sched: Add generic scheduler message interface Matthew Brost
2023-05-04 5:28 ` Luben Tuikov
2023-07-31 2:42 ` Matthew Brost
2023-04-04 0:22 ` [RFC PATCH 05/10] drm/sched: Start run wq before TDR in drm_sched_start Matthew Brost
2023-04-04 0:22 ` [RFC PATCH 06/10] drm/sched: Submit job before starting TDR Matthew Brost
2023-05-04 5:23 ` Luben Tuikov
2023-07-31 1:00 ` Matthew Brost
2023-07-31 7:26 ` Boris Brezillon
2023-08-31 19:48 ` Luben Tuikov
2023-04-04 0:22 ` [RFC PATCH 07/10] drm/sched: Add helper to set TDR timeout Matthew Brost
2023-05-04 5:28 ` Luben Tuikov
2023-07-31 1:09 ` Matthew Brost
2023-08-31 19:52 ` Luben Tuikov
2023-04-04 0:22 ` [RFC PATCH 08/10] dma-buf/dma-fence: Introduce long-running completion fences Matthew Brost
2023-04-04 9:09 ` Christian König
2023-04-04 12:54 ` Thomas Hellström
2023-04-04 13:10 ` Christian König
2023-04-04 18:14 ` Thomas Hellström (Intel)
2023-04-04 19:02 ` Matthew Brost
2023-04-04 19:25 ` Daniel Vetter
2023-04-04 19:48 ` Matthew Brost
2023-04-05 13:09 ` Daniel Vetter
2023-04-05 23:58 ` Matthew Brost
2023-04-06 6:32 ` Daniel Vetter
2023-04-06 16:58 ` Matthew Brost
2023-04-06 17:09 ` Daniel Vetter
2023-04-05 12:35 ` Thomas Hellström
2023-04-05 12:39 ` Christian König
2023-04-05 12:45 ` Daniel Vetter
2023-04-05 14:08 ` Christian König
2023-04-04 19:00 ` Daniel Vetter
2023-04-04 20:03 ` Matthew Brost
2023-04-04 20:11 ` Daniel Vetter
2023-04-04 20:19 ` Matthew Brost
2023-04-04 20:31 ` Daniel Vetter
2023-04-04 20:46 ` Matthew Brost
2023-04-04 0:22 ` [RFC PATCH 09/10] drm/sched: Support long-running sched entities Matthew Brost
2023-04-04 0:22 ` [RFC PATCH 10/10] drm/syncobj: Warn on long running dma-fences Matthew Brost
2023-04-04 1:07 ` [RFC PATCH 00/10] Xe DRM scheduler and long running workload plans Asahi Lina
2023-04-04 1:58 ` Matthew Brost
2023-04-08 7:05 ` Asahi Lina
2023-04-11 14:07 ` Daniel Vetter
2023-04-12 5:47 ` Asahi Lina
2023-04-12 8:18 ` Daniel Vetter
2023-04-17 0:03 ` Matthew Brost
2023-04-04 9:04 ` Christian König
2023-04-04 13:23 ` Matthew Brost
2023-04-04 9:13 ` Christian König
2023-04-04 13:37 ` Matthew Brost
2023-04-05 7:41 ` Christian König
2023-04-05 8:34 ` Daniel Vetter
2023-04-05 8:53 ` Christian König
2023-04-05 9:07 ` Daniel Vetter
2023-04-05 9:57 ` Christian König
2023-04-05 10:12 ` Daniel Vetter
2023-04-06 2:08 ` Matthew Brost
2023-04-06 6:37 ` Daniel Vetter
2023-04-06 10:14 ` Christian König
2023-04-06 10:32 ` Daniel Vetter [this message]
2023-04-04 9:43 ` Tvrtko Ursulin
2023-04-04 9:48 ` Christian König
2023-04-04 13:43 ` Matthew Brost
2023-04-04 13:52 ` Matthew Brost
2023-04-04 17:29 ` Tvrtko Ursulin
2023-04-04 19:07 ` Daniel Vetter
2023-04-04 18:02 ` Zeng, Oak
2023-04-04 18:08 ` Matthew Brost
2023-04-05 7:30 ` Christian König
2023-04-05 8:42 ` Daniel Vetter
2023-04-05 18:06 ` Zeng, Oak
2023-04-05 18:53 ` Matthew Brost
2023-04-06 10:04 ` Christian König
2023-04-07 0:20 ` Zeng, Oak
2023-04-11 9:02 ` Christian König
2023-04-11 14:13 ` Daniel Vetter
2023-04-17 6:47 ` Christian König
2023-04-17 8:39 ` Daniel Vetter
2023-04-18 15:10 ` Liviu Dudau
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=ZC6fz8IeOIabg10u@phenom.ffwll.local \
--to=daniel@ffwll.ch \
--cc=airlied@linux.ie \
--cc=boris.brezillon@collabora.com \
--cc=christian.koenig@amd.com \
--cc=dri-devel@lists.freedesktop.org \
--cc=faith.ekstrand@collabora.com \
--cc=intel-xe@lists.freedesktop.org \
--cc=lina@asahilina.net \
--cc=matthew.brost@intel.com \
--cc=robdclark@chromium.org \
--cc=thomas.hellstrom@linux.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