From: sashiko-bot@kernel.org
To: "Tvrtko Ursulin" <tvrtko.ursulin@igalia.com>,
dri-devel@lists.freedesktop.org
Cc: amd-gfx@lists.freedesktop.org
Subject: Re: [RFC v2] drm/sched: Track sched fence scheduled and finished time directly
Date: Fri, 27 Nov 2026 11:45:45 +0000 [thread overview]
Message-ID: <sashiko-outbox-237273@kernel.org> (raw)
In-Reply-To: <20261127112818.79237-1-tvrtko.ursulin@igalia.com>
Thank you for your contribution! Sashiko AI review found 1 potential
issue to consider:
- [Medium] drm/sched: skipped start_ts update in
drm_sched_fence_advance_start_time()
--
commit 8d03d09146f11c7c74e02c09d184c1146771b9ad
Author: Tvrtko Ursulin <tvrtko.ursulin@igalia.com>
drm/sched: Track sched fence scheduled and finished time directly
This commit adds dedicated start_ts and finished_ts fields protected by
ts_lock to struct drm_sched_fence so that scheduled and finished
timestamps can be tracked and adjusted without modifying dma_fence
internals directly.
> diff --git a/drivers/gpu/drm/scheduler/sched_internal.h b/drivers/gpu/drm/scheduler/sched_internal.h
> index 32d3ddb820be6..b24bb1d7d4893 100644
> --- a/drivers/gpu/drm/scheduler/sched_internal.h
> +++ b/drivers/gpu/drm/scheduler/sched_internal.h
> @@ -67,6 +67,45 @@ void drm_sched_fence_scheduled(struct drm_sched_fence *fence,
> struct dma_fence *parent);
> void drm_sched_fence_finished(struct drm_sched_fence *fence, int result);
>
> +/**
> + * drm_sched_fence_advance_start_time - Advance scheduler fence scheduled timestamp
> + * @fence: scheduler fence
> + * @t: time to advance to
> + *
> + * Advances the scheduler fence scheduled time to @t if the fence has already
> + * been scheduled with an older timestamp.
> + */
> +static inline void
> +drm_sched_fence_advance_start_time(struct drm_sched_fence *fence, ktime_t t)
> +{
> + unsigned long flags;
> +
> + spin_lock_irqsave(&fence->ts_lock, flags);
> + if (fence->start_ts && !fence->finished_ts &&
> + ktime_after(t, fence->start_ts))
> + fence->start_ts = t;
> + spin_unlock_irqrestore(&fence->ts_lock, flags);
> +}
[Severity: Medium]
Does checking !fence->finished_ts here prevent start_ts from being
advanced when multiple pipelined jobs complete before work_free_job
runs?
drm_sched_job_done_cb() runs in interrupt context when the parent fence
signals and calls drm_sched_fence_finished(), setting finished_ts
immediately and queueing work_free_job. If a second job on pending_list
also completes before the worker calls drm_sched_get_finished_job() for
the first job, next->s_fence->finished_ts is already non-zero.
drm_sched_fence_advance_start_time() then leaves next->s_fence->start_ts
at its ring-submission timestamp, causing
drm_sched_entity_stats_job_add_gpu_time() and amdgpu_ctx_fence_time() to
overaccount GPU time across completed batches.
Should this check that fence->finished_ts is either zero or not before t
(e.g. !fence->finished_ts || !ktime_after(t, fence->finished_ts))
instead?
--
Sashiko AI review · https://sashiko.dev/#/patchset/20261127112818.79237-1-tvrtko.ursulin@igalia.com?part=1
next prev parent reply other threads:[~2026-11-27 11:45 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-26 15:42 [RFC] drm/sched: Track sched fence scheduled and finished time directly Tvrtko Ursulin
2026-11-26 15:59 ` Philipp Stanner
2026-11-26 16:57 ` Tvrtko Ursulin
2026-11-26 16:00 ` sashiko-bot
2026-11-26 17:06 ` Tvrtko Ursulin
2026-11-27 11:28 ` [RFC v2] " Tvrtko Ursulin
2026-11-27 11:45 ` sashiko-bot [this message]
2026-11-27 12:42 ` [RFC v3] " Tvrtko Ursulin
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=sashiko-outbox-237273@kernel.org \
--to=sashiko-bot@kernel.org \
--cc=amd-gfx@lists.freedesktop.org \
--cc=dri-devel@lists.freedesktop.org \
--cc=sashiko-reviews@lists.linux.dev \
--cc=tvrtko.ursulin@igalia.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