Skip to content

Commit df62272

Browse files
committed
drm/scheduler: track GPU active time per entity
Track the accumulated time that jobs from this entity were active on the GPU. This allows drivers using the scheduler to trivially implement the DRM fdinfo when the hardware doesn't provide more specific information than signalling job completion anyways. [Bagas: Append missing colon to @elapsed_ns] Signed-off-by: Bagas Sanjaya <[email protected]> Signed-off-by: Lucas Stach <[email protected]> Reviewed-by: Andrey Grodzovsky <[email protected]>
1 parent 6b05266 commit df62272

File tree

2 files changed

+13
-0
lines changed

2 files changed

+13
-0
lines changed

drivers/gpu/drm/scheduler/sched_main.c

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -895,6 +895,12 @@ drm_sched_get_cleanup_job(struct drm_gpu_scheduler *sched)
895895

896896
spin_unlock(&sched->job_list_lock);
897897

898+
if (job) {
899+
job->entity->elapsed_ns += ktime_to_ns(
900+
ktime_sub(job->s_fence->finished.timestamp,
901+
job->s_fence->scheduled.timestamp));
902+
}
903+
898904
return job;
899905
}
900906

include/drm/gpu_scheduler.h

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -228,6 +228,13 @@ struct drm_sched_entity {
228228
*/
229229
struct rb_node rb_tree_node;
230230

231+
/**
232+
* @elapsed_ns:
233+
*
234+
* Records the amount of time where jobs from this entity were active
235+
* on the GPU.
236+
*/
237+
uint64_t elapsed_ns;
231238
};
232239

233240
/**

0 commit comments

Comments
 (0)