dri-devel Archive on lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v2 1/3] drm/scheduler: track GPU active time per entity
@ 2022-09-16 15:12 Lucas Stach
  2022-09-16 15:12 ` [PATCH v2 2/3] drm/etnaviv: allocate unique ID per drm_file Lucas Stach
  2022-09-16 15:12 ` [PATCH v2 3/3] drm/etnaviv: export client GPU usage statistics via fdinfo Lucas Stach
  0 siblings, 2 replies; 7+ messages in thread
From: Lucas Stach @ 2022-09-16 15:12 UTC (permalink / raw)
  To: etnaviv, dri-devel; +Cc: patchwork-lst, kernel, Russell King

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.

Signed-off-by: Lucas Stach <l.stach@pengutronix.de>
Reviewed-by: Andrey Grodzovsky <andrey.grodzovsky@amd.com>
---
 drivers/gpu/drm/scheduler/sched_main.c | 6 ++++++
 include/drm/gpu_scheduler.h            | 7 +++++++
 2 files changed, 13 insertions(+)

diff --git a/drivers/gpu/drm/scheduler/sched_main.c b/drivers/gpu/drm/scheduler/sched_main.c
index 68317d3a7a27..5dbe826d498d 100644
--- a/drivers/gpu/drm/scheduler/sched_main.c
+++ b/drivers/gpu/drm/scheduler/sched_main.c
@@ -852,6 +852,12 @@ drm_sched_get_cleanup_job(struct drm_gpu_scheduler *sched)
 
 	spin_unlock(&sched->job_list_lock);
 
+	if (job) {
+		job->entity->elapsed_ns += ktime_to_ns(
+			ktime_sub(job->s_fence->finished.timestamp,
+				  job->s_fence->scheduled.timestamp));
+	}
+
 	return job;
 }
 
diff --git a/include/drm/gpu_scheduler.h b/include/drm/gpu_scheduler.h
index addb135eeea6..573bef640664 100644
--- a/include/drm/gpu_scheduler.h
+++ b/include/drm/gpu_scheduler.h
@@ -196,6 +196,13 @@ struct drm_sched_entity {
 	 * drm_sched_entity_fini().
 	 */
 	struct completion		entity_idle;
+	/**
+	 * @elapsed_ns
+	 *
+	 * Records the amount of time where jobs from this entity were active
+	 * on the GPU.
+	 */
+	uint64_t elapsed_ns;
 };
 
 /**
-- 
2.30.2


^ permalink raw reply related	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2022-11-16 14:47 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2022-09-16 15:12 [PATCH v2 1/3] drm/scheduler: track GPU active time per entity Lucas Stach
2022-09-16 15:12 ` [PATCH v2 2/3] drm/etnaviv: allocate unique ID per drm_file Lucas Stach
2022-11-16  9:16   ` Lucas Stach
2022-11-16 13:18   ` Philipp Zabel
2022-11-16 14:47     ` Tvrtko Ursulin
2022-09-16 15:12 ` [PATCH v2 3/3] drm/etnaviv: export client GPU usage statistics via fdinfo Lucas Stach
2022-11-16 13:40   ` Philipp Zabel

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox