From: Tvrtko Ursulin <tursulin@ursulin.net>
To: Sidong Yang <sidong.yang@furiosa.ai>,
Tomeu Vizoso <tomeu@tomeuvizoso.net>,
Oded Gabbay <ogabbay@kernel.org>,
Philipp Stanner <phasta@kernel.org>,
Danilo Krummrich <dakr@kernel.org>,
Matthew Brost <matthew.brost@intel.com>,
ckoenig.leichtzumerken@gmail.com
Cc: mcanal@igalia.com, Heiko Stuebner <heiko@sntech.de>,
Gyeyoung Baek <gye976@gmail.com>,
dri-devel@lists.freedesktop.org, linux-doc@vger.kernel.org,
linux-kernel@vger.kernel.org
Subject: Re: [PATCH v5 1/2] drm/sched: Add drm_sched_entity_get_runtime()
Date: Wed, 18 Nov 2026 16:34:09 +0000 [thread overview]
Message-ID: <598d80dc-1269-44ff-8852-b63b6ab57ea5@ursulin.net> (raw)
In-Reply-To: <20261112171144.3151554-2-sidong.yang@furiosa.ai>
On 12/11/2026 17:11, Sidong Yang wrote:
> The scheduler accumulates the time each entity's jobs spend on the
> hardware for the fair policy, but drivers cannot read it. Export it so
> drivers can report per-client engine time through fdinfo without
> keeping their own counter.
>
> The stats object is refcounted and held by the entity and its jobs, so
> unlike commit df622729ddbf ("drm/scheduler: track GPU active time per
> entity"), which was reverted, accounting a job does not touch the
> entity.
>
> Suggested-by: Tvrtko Ursulin <tursulin@ursulin.net>
> Signed-off-by: Sidong Yang <sidong.yang@furiosa.ai>
> ---
> drivers/gpu/drm/scheduler/sched_entity.c | 25 ++++++++++++++++++++++++
> include/drm/gpu_scheduler.h | 1 +
> 2 files changed, 26 insertions(+)
>
> diff --git a/drivers/gpu/drm/scheduler/sched_entity.c b/drivers/gpu/drm/scheduler/sched_entity.c
> index 03e68b4102d5..ac040f95876a 100644
> --- a/drivers/gpu/drm/scheduler/sched_entity.c
> +++ b/drivers/gpu/drm/scheduler/sched_entity.c
> @@ -238,6 +238,31 @@ int drm_sched_entity_error(struct drm_sched_entity *entity)
> }
> EXPORT_SYMBOL(drm_sched_entity_error);
>
> +/**
> + * drm_sched_entity_get_runtime - Get the time an entity's jobs have run
> + * @entity: scheduler entity
> + *
> + * Returns the time the jobs of @entity have spent on the hardware, measured
> + * from the scheduled to the finished fence of each job. A job is accounted
> + * when the scheduler frees it.
> + *
> + * The caller must ensure @entity has not been finalized.
> + *
> + * Return: Accumulated runtime in nanoseconds.
> + */
> +u64 drm_sched_entity_get_runtime(struct drm_sched_entity *entity)
> +{
> + struct drm_sched_entity_stats *stats = entity->stats;
> + ktime_t runtime;
> +
> + spin_lock(&stats->lock);
> + runtime = stats->runtime;
> + spin_unlock(&stats->lock);
> +
> + return ktime_to_ns(runtime);
> +}
> +EXPORT_SYMBOL(drm_sched_entity_get_runtime);
> +
> static void drm_sched_entity_kill_jobs_cb(struct dma_fence *f,
> struct dma_fence_cb *cb);
>
> diff --git a/include/drm/gpu_scheduler.h b/include/drm/gpu_scheduler.h
> index 3b0978fa8cf0..96a3401d4c88 100644
> --- a/include/drm/gpu_scheduler.h
> +++ b/include/drm/gpu_scheduler.h
> @@ -730,6 +730,7 @@ void drm_sched_entity_destroy(struct drm_sched_entity *entity);
> void drm_sched_entity_set_priority(struct drm_sched_entity *entity,
> enum drm_sched_priority priority);
> int drm_sched_entity_error(struct drm_sched_entity *entity);
> +u64 drm_sched_entity_get_runtime(struct drm_sched_entity *entity);
> void drm_sched_entity_modify_sched(struct drm_sched_entity *entity,
> struct drm_gpu_scheduler **sched_list,
> unsigned int num_sched_list);
LGTM.
Reviewed-by: Tvrtko Ursulin <tvrtko.ursulin@igalia.com>
Regards,
Tvrtko
next prev parent reply other threads:[~2026-11-18 16:34 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-12 17:11 [PATCH v5 0/2] accel/rocket: Report NPU usage through fdinfo Sidong Yang
2026-11-12 17:11 ` [PATCH v5 1/2] drm/sched: Add drm_sched_entity_get_runtime() Sidong Yang
2026-11-18 16:34 ` Tvrtko Ursulin [this message]
2026-11-18 17:13 ` Philipp Stanner
2026-11-18 17:39 ` Maíra Canal
2026-11-12 17:11 ` [PATCH v5 2/2] accel/rocket: Report NPU usage through fdinfo Sidong Yang
2026-11-18 16:42 ` 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=598d80dc-1269-44ff-8852-b63b6ab57ea5@ursulin.net \
--to=tursulin@ursulin.net \
--cc=ckoenig.leichtzumerken@gmail.com \
--cc=dakr@kernel.org \
--cc=dri-devel@lists.freedesktop.org \
--cc=gye976@gmail.com \
--cc=heiko@sntech.de \
--cc=linux-doc@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=matthew.brost@intel.com \
--cc=mcanal@igalia.com \
--cc=ogabbay@kernel.org \
--cc=phasta@kernel.org \
--cc=sidong.yang@furiosa.ai \
--cc=tomeu@tomeuvizoso.net \
/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®