From: Matthew Brost <matthew.brost@intel.com>
To: Philipp Stanner <pstanner@redhat.com>
Cc: <intel-xe@lists.freedesktop.org>,
<dri-devel@lists.freedesktop.org>, <linux-kernel@vger.kernel.org>,
<jiangshanlai@gmail.com>, <tj@kernel.org>,
<simona.vetter@ffwll.ch>, <christian.koenig@amd.com>,
<dakr@kernel.org>
Subject: Re: [RFC PATCH 3/3] drm/sched: Prevent adding dependencies to an armed job
Date: Mon, 27 Oct 2025 09:56:05 -0700 [thread overview]
Message-ID: <aP+kJeOEghD+sEsg@lstrano-desk.jf.intel.com> (raw)
In-Reply-To: <537bdebf2112a080ae92526ecfa41d63668d90a3.camel@redhat.com>
On Mon, Oct 27, 2025 at 12:13:58PM +0100, Philipp Stanner wrote:
> I've got a kernel.org addr by now by the way
>
> On Tue, 2025-10-21 at 14:39 -0700, Matthew Brost wrote:
> > According to the DMA scheduler documentation, once a job is armed, it
> > must be pushed. Drivers should avoid calling the failing code path that
> > attempts to add dependencies after a job has been armed.
> >
>
> Why is that a "failing code path"?
>
I noticed this after I sent - it should something like:
'avoid calling a possible failing code path, which allocates memory.'
I can make this a bit more clear.
> The issue with adding callbacks is that adding them to an already
> signaled fence is a bad idea. I'm not sure if it's illegal, though.
> dma_fence_add_cb() merely returns an error then, but the driver could
> in priniciple then execute its cb code itself.
>
> And even if we agree that this is a hard rule that must be followed,
> then drm_sched_job_arm() *might* not be the right place, because just
> because a job is armed doesn't mean that its fence is about to get
> signaled. drm_sched_entity_push_job() would be the critical place.
>
I think this break our rule once arm is called, push must be called as
adding dependencies can possibly fail. This rule is called out in your
documentation patch too. I've seen 2 driver posted in the past year add
dependencies after arming, so I figured lets catch this misuse in the
scheduler.
Matt
>
> > This change
> > enforces that rule.
> >
> > Cc: Christian König <christian.koenig@amd.com>
> > Cc: Danilo Krummrich <dakr@kernel.org>
> > Cc: Matthew Brost <matthew.brost@intel.com>
> > Cc: Philipp Stanner <phasta@kernel.org>
> > Cc: dri-devel@lists.freedesktop.org
> > Signed-off-by: Matthew Brost <matthew.brost@intel.com>
> > ---
> > drivers/gpu/drm/scheduler/sched_main.c | 7 ++++++-
> > 1 file changed, 6 insertions(+), 1 deletion(-)
> >
> > diff --git a/drivers/gpu/drm/scheduler/sched_main.c b/drivers/gpu/drm/scheduler/sched_main.c
> > index 676484dd3ea3..436cb2844161 100644
> > --- a/drivers/gpu/drm/scheduler/sched_main.c
> > +++ b/drivers/gpu/drm/scheduler/sched_main.c
> > @@ -873,7 +873,8 @@ EXPORT_SYMBOL(drm_sched_job_arm);
> > * @job: scheduler job to add the dependencies to
> > * @fence: the dma_fence to add to the list of dependencies.
> > *
> > - * Note that @fence is consumed in both the success and error cases.
> > + * Note that @fence is consumed in both the success and error cases. This
> > + * function cannot be called if the job is armed.
> > *
> > * Returns:
> > * 0 on success, or an error on failing to expand the array.
> > @@ -886,6 +887,10 @@ int drm_sched_job_add_dependency(struct drm_sched_job *job,
> > u32 id = 0;
> > int ret;
> >
> > + /* Do not allow additional dependencies when job is armed */
> > + if (WARN_ON_ONCE(job->sched))
>
> One would probably want an 'armed' boolean for that. At the very least
> one wants to document in the struct's docstring that job->sched has
> this semantic meaning. Otherwise it's only obvious for people who have
> been hacking on the scheduler for years.
>
>
> By the way I think that we use WARN_ON*() too much in DRM. It generates
> difficult to read, non-descriptive error messages compared to
> dev_warn() and similar helpers, and it's often a bit overkill. I would
> only use it when there is no other choice, such as in an interrupt-
> handler or widely used void func() where you cannot simply add a return
> code.
>
>
> P.
>
> > + return -EINVAL;
>
>
> > +
> > if (!fence)
> > return 0;
> >
>
next prev parent reply other threads:[~2025-10-27 16:56 UTC|newest]
Thread overview: 24+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-10-21 21:39 [RFC PATCH 0/3] Enforce DRM scheduler reclaim rules Matthew Brost
2025-10-21 21:39 ` [RFC PATCH 1/3] workqueue: Add an interface to taint workqueue lockdep with reclaim Matthew Brost
2025-10-21 21:56 ` Tejun Heo
2025-10-21 22:04 ` Matthew Brost
2025-10-21 22:06 ` Matthew Brost
2025-10-21 23:25 ` Tejun Heo
2025-10-22 1:16 ` Matthew Brost
2025-10-21 23:28 ` Tejun Heo
2025-10-22 1:22 ` Matthew Brost
2025-10-22 1:51 ` Tejun Heo
2025-10-27 21:58 ` Matthew Brost
2025-10-28 9:32 ` Christian König
2025-10-28 20:16 ` Matthew Brost
2025-10-29 9:48 ` Christian König
2025-10-29 15:06 ` Tejun Heo
2025-10-29 16:46 ` Matthew Brost
2025-10-29 18:16 ` Tejun Heo
2025-10-21 21:39 ` [RFC PATCH 2/3] drm/sched: Taint workqueues " Matthew Brost
2025-10-27 11:03 ` Philipp Stanner
2025-10-27 17:00 ` Matthew Brost
2025-10-21 21:39 ` [RFC PATCH 3/3] drm/sched: Prevent adding dependencies to an armed job Matthew Brost
2025-10-27 11:13 ` Philipp Stanner
2025-10-27 16:56 ` Matthew Brost [this message]
2025-10-28 9:27 ` Philipp Stanner
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=aP+kJeOEghD+sEsg@lstrano-desk.jf.intel.com \
--to=matthew.brost@intel.com \
--cc=christian.koenig@amd.com \
--cc=dakr@kernel.org \
--cc=dri-devel@lists.freedesktop.org \
--cc=intel-xe@lists.freedesktop.org \
--cc=jiangshanlai@gmail.com \
--cc=linux-kernel@vger.kernel.org \
--cc=pstanner@redhat.com \
--cc=simona.vetter@ffwll.ch \
--cc=tj@kernel.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
all inboxes | Powered by JetHome®