[PATCH v2 4/8] [ANDROID]: Modify xe_exec_queue_update_run_ticks
Aakash Deep Sarkar
aakash.deep.sarkar at intel.com
Fri Aug 22 08:59:26 UTC 2025
For GPU work period event we need to record the run time of a
context on the GPU in nanosecs. In the present xe driver code,
we only record the run time in clock ticks and separately for
each engine class.
So, we are adding a uint64 variable |active_duration_ns| in
the xe file structure where we can record the cumulative
run time in ns of all the engines for this context. The
intent here is to add up the |active_duration_ns| in
all the xe files belonging to a given user id to derive
the run time for that user id.
Signed-off-by: Aakash Deep Sarkar <aakash.deep.sarkar at intel.com>
---
drivers/gpu/drm/xe/xe_device_types.h | 3 +++
drivers/gpu/drm/xe/xe_exec_queue.c | 7 +++++++
2 files changed, 10 insertions(+)
diff --git a/drivers/gpu/drm/xe/xe_device_types.h b/drivers/gpu/drm/xe/xe_device_types.h
index 01e8fa0d2f9f..c4f076a26291 100644
--- a/drivers/gpu/drm/xe/xe_device_types.h
+++ b/drivers/gpu/drm/xe/xe_device_types.h
@@ -656,6 +656,9 @@ struct xe_file {
/** @run_ticks: hw engine class run time in ticks for this drm client */
u64 run_ticks[XE_ENGINE_CLASS_MAX];
+ /** @active_duration_ns: total run time in ns for this xe file */
+ u64 active_duration_ns;
+
/** @client: drm client */
struct xe_drm_client *client;
diff --git a/drivers/gpu/drm/xe/xe_exec_queue.c b/drivers/gpu/drm/xe/xe_exec_queue.c
index 2d10a53f701d..2ee8a475f5ed 100644
--- a/drivers/gpu/drm/xe/xe_exec_queue.c
+++ b/drivers/gpu/drm/xe/xe_exec_queue.c
@@ -15,6 +15,7 @@
#include "xe_dep_scheduler.h"
#include "xe_device.h"
#include "xe_gt.h"
+#include "xe_gt_clock.h"
#include "xe_hw_engine_class_sysfs.h"
#include "xe_hw_engine_group.h"
#include "xe_hw_fence.h"
@@ -879,6 +880,8 @@ void xe_exec_queue_update_run_ticks(struct xe_exec_queue *q)
{
struct xe_device *xe = gt_to_xe(q->gt);
struct xe_lrc *lrc;
+ struct xe_gt *gt = q->gt;
+
u64 old_ts, new_ts;
int idx;
@@ -904,6 +907,10 @@ void xe_exec_queue_update_run_ticks(struct xe_exec_queue *q)
new_ts = xe_lrc_update_timestamp(lrc, &old_ts);
q->xef->run_ticks[q->class] += (new_ts - old_ts) * q->width;
+ // Accumulate the runtime in nanosec for this queue into the xe file.
+ q->xef->active_duration_ns +=
+ xe_gt_clock_interval_to_ns(gt, (new_ts - old_ts));
+
drm_dev_exit(idx);
}
--
2.49.0
More information about the Intel-xe
mailing list