Re: [PATCH v5 1/2] drm/sched: Add drm_sched_entity_get_runtime()

From: Maíra Canal

Date: Wed Nov 18 2026 - 12:39:26 EST




On 18/11/26 14:13, Philipp Stanner wrote:
On Fri, 2026-11-13 at 02:11 +0900, 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.

In general looks good to me, no objections.

But a question below:


Suggested-by: Tvrtko Ursulin <tursulin@xxxxxxxxxxx>
Signed-off-by: Sidong Yang <sidong.yang@xxxxxxxxxx>


+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);

Why not return it as ktime_t?

ktime_t, I suppose, is the universal time unit in the kernel, and the
user can use one of the converters to turn it into whatever is desired.

With ns you would have to write the converters yourself.

Considering that the main use of this function by the drivers would be
fdinfo, I believe that ns makes more sense. Otherwise, all drivers would
need to convert to ns locally.

Maybe we could name it drm_sched_entity_get_runtime_ns()?

Best regards,
- Maíra


P.