* [PATCH v5 0/2] accel/rocket: Report NPU usage through fdinfo
@ 2026-11-12 17:11 Sidong Yang
2026-11-12 17:11 ` [PATCH v5 1/2] drm/sched: Add drm_sched_entity_get_runtime() Sidong Yang
2026-11-12 17:11 ` [PATCH v5 2/2] accel/rocket: Report NPU usage through fdinfo Sidong Yang
0 siblings, 2 replies; 7+ messages in thread
From: Sidong Yang @ 2026-11-12 17:11 UTC (permalink / raw)
To: Tomeu Vizoso, Oded Gabbay, Philipp Stanner, Danilo Krummrich,
Matthew Brost, ckoenig.leichtzumerken
Cc: Tvrtko Ursulin, mcanal, Heiko Stuebner, Gyeyoung Baek, dri-devel,
linux-doc, linux-kernel, Sidong Yang
Report how much of the NPU each client uses through fdinfo. Patch 1
exports the runtime the scheduler already accounts per entity, and patch
2 uses it for rocket's drm-engine-npu key.
v5: Use the entity runtime from the new drm_sched_entity_get_runtime()
instead of a counter in rocket (Tvrtko Ursulin). Reviewed-by tags
are not carried as the accounting changed. Based on drm-misc-next.
v4: Single drm-engine-npu key with drm-engine-capacity-npu, and
documentation (Tomeu Vizoso).
v3: Add a rocket_engine_usage_create() helper (Gyeyoung Baek).
v2: Size the per-core counters by rdev->max_cores.
Link to v4: https://lore.kernel.org/all/20261103155338.1949294-1-sidong.yang@furiosa.ai/
Link to v3: https://lore.kernel.org/all/20261103104804.1887489-1-sidong.yang@furiosa.ai/
Link to v2: https://lore.kernel.org/all/20261101152723.1430312-1-sidong.yang@furiosa.ai/
Link to v1: https://lore.kernel.org/all/20261031083642.1076356-1-sidong.yang@furiosa.ai/
Sidong Yang (2):
drm/sched: Add drm_sched_entity_get_runtime()
accel/rocket: Report NPU usage through fdinfo
Documentation/accel/rocket/index.rst | 28 ++++++++++++++++++++++++
Documentation/gpu/drm-usage-stats.rst | 1 +
drivers/accel/rocket/rocket_drv.c | 21 +++++++++++++++++-
drivers/gpu/drm/scheduler/sched_entity.c | 25 +++++++++++++++++++++
include/drm/gpu_scheduler.h | 1 +
5 files changed, 75 insertions(+), 1 deletion(-)
base-commit: 7678b7f2d38b5575981b1a7c09139a4660b66826
--
2.53.0
^ permalink raw reply [flat|nested] 7+ messages in thread
* [PATCH v5 1/2] drm/sched: Add drm_sched_entity_get_runtime()
2026-11-12 17:11 [PATCH v5 0/2] accel/rocket: Report NPU usage through fdinfo Sidong Yang
@ 2026-11-12 17:11 ` Sidong Yang
2026-11-18 16:34 ` Tvrtko Ursulin
2026-11-18 17:13 ` Philipp Stanner
2026-11-12 17:11 ` [PATCH v5 2/2] accel/rocket: Report NPU usage through fdinfo Sidong Yang
1 sibling, 2 replies; 7+ messages in thread
From: Sidong Yang @ 2026-11-12 17:11 UTC (permalink / raw)
To: Tomeu Vizoso, Oded Gabbay, Philipp Stanner, Danilo Krummrich,
Matthew Brost, ckoenig.leichtzumerken
Cc: Tvrtko Ursulin, mcanal, Heiko Stuebner, Gyeyoung Baek, dri-devel,
linux-doc, linux-kernel, Sidong Yang
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);
--
2.53.0
^ permalink raw reply [flat|nested] 7+ messages in thread
* [PATCH v5 2/2] accel/rocket: Report NPU usage through fdinfo
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-12 17:11 ` Sidong Yang
2026-11-18 16:42 ` Tvrtko Ursulin
1 sibling, 1 reply; 7+ messages in thread
From: Sidong Yang @ 2026-11-12 17:11 UTC (permalink / raw)
To: Tomeu Vizoso, Oded Gabbay, Philipp Stanner, Danilo Krummrich,
Matthew Brost, ckoenig.leichtzumerken
Cc: Tvrtko Ursulin, mcanal, Heiko Stuebner, Gyeyoung Baek, dri-devel,
linux-doc, linux-kernel, Sidong Yang
There is no way to tell how much of the NPU a client uses. Implement the
DRM usage stats: report the runtime of the client's scheduler entity as
drm-engine-npu, along with drm_show_memory_stats() for the BOs.
The cores are identical, so they are reported as a single engine with
drm-engine-capacity-npu set to rdev->max_cores, the number of core
slots.
Document the keys in the rocket driver documentation.
Signed-off-by: Sidong Yang <sidong.yang@furiosa.ai>
---
Documentation/accel/rocket/index.rst | 28 +++++++++++++++++++++++++++
Documentation/gpu/drm-usage-stats.rst | 1 +
drivers/accel/rocket/rocket_drv.c | 21 +++++++++++++++++++-
3 files changed, 49 insertions(+), 1 deletion(-)
diff --git a/Documentation/accel/rocket/index.rst b/Documentation/accel/rocket/index.rst
index 70f97bccf100..8ae785b65a53 100644
--- a/Documentation/accel/rocket/index.rst
+++ b/Documentation/accel/rocket/index.rst
@@ -17,3 +17,31 @@ project.
Hardware currently supported:
* RK3588
+
+.. _rocket-usage-stats:
+
+Rocket DRM client usage stats implementation
+============================================
+
+The accel/rocket driver implements the DRM client usage stats specification as
+documented in :ref:`drm-client-usage-stats`.
+
+The NPU cores are reported as a single engine, npu, with a capacity equal to the
+number of cores. The time is summed over all cores and is accounted by the DRM
+GPU scheduler, from when a job is handed to a core until its fence signals.
+
+Example of the output showing the implemented key value pairs:
+
+::
+
+ pos: 0
+ flags: 02400002
+ mnt_id: 33
+ ino: 755
+ drm-driver: rocket
+ drm-client-id: 263
+ drm-engine-npu: 2384122043 ns
+ drm-engine-capacity-npu: 3
+ drm-total-memory: 24216 KiB
+ drm-shared-memory: 0
+ drm-active-memory: 3000 KiB
diff --git a/Documentation/gpu/drm-usage-stats.rst b/Documentation/gpu/drm-usage-stats.rst
index 70b7cfcc194f..288764730d23 100644
--- a/Documentation/gpu/drm-usage-stats.rst
+++ b/Documentation/gpu/drm-usage-stats.rst
@@ -218,3 +218,4 @@ Driver specific implementations
* :ref:`panthor-usage-stats`
* :ref:`xe-usage-stats`
* :ref:`amdxdna-usage-stats`
+* :ref:`rocket-usage-stats`
diff --git a/drivers/accel/rocket/rocket_drv.c b/drivers/accel/rocket/rocket_drv.c
index 5d7805c41dc3..351be60b1228 100644
--- a/drivers/accel/rocket/rocket_drv.c
+++ b/drivers/accel/rocket/rocket_drv.c
@@ -3,8 +3,10 @@
#include <drm/drm_accel.h>
#include <drm/drm_drv.h>
+#include <drm/drm_file.h>
#include <drm/drm_gem.h>
#include <drm/drm_ioctl.h>
+#include <drm/drm_print.h>
#include <drm/rocket_accel.h>
#include <linux/clk.h>
#include <linux/err.h>
@@ -139,7 +141,23 @@ static const struct drm_ioctl_desc rocket_drm_driver_ioctls[] = {
ROCKET_IOCTL(FINI_BO, fini_bo),
};
-DEFINE_DRM_ACCEL_FOPS(rocket_accel_driver_fops);
+static void rocket_show_fdinfo(struct drm_printer *p, struct drm_file *file)
+{
+ struct rocket_device *rdev = to_rocket_device(file->minor->dev);
+ struct rocket_file_priv *rocket_priv = file->driver_priv;
+
+ drm_printf(p, "drm-engine-npu:\t%llu ns\n",
+ drm_sched_entity_get_runtime(&rocket_priv->sched_entity));
+ drm_printf(p, "drm-engine-capacity-npu:\t%u\n", rdev->max_cores);
+
+ drm_show_memory_stats(p, file);
+}
+
+static const struct file_operations rocket_accel_driver_fops = {
+ .owner = THIS_MODULE,
+ DRM_ACCEL_FOPS,
+ .show_fdinfo = drm_show_fdinfo,
+};
/*
* Rocket driver version:
@@ -150,6 +168,7 @@ static const struct drm_driver rocket_drm_driver = {
.open = rocket_open,
.postclose = rocket_postclose,
.gem_create_object = rocket_gem_create_object,
+ .show_fdinfo = rocket_show_fdinfo,
.ioctls = rocket_drm_driver_ioctls,
.num_ioctls = ARRAY_SIZE(rocket_drm_driver_ioctls),
.fops = &rocket_accel_driver_fops,
--
2.53.0
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH v5 1/2] drm/sched: Add drm_sched_entity_get_runtime()
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
2026-11-18 17:13 ` Philipp Stanner
1 sibling, 0 replies; 7+ messages in thread
From: Tvrtko Ursulin @ 2026-11-18 16:34 UTC (permalink / raw)
To: Sidong Yang, Tomeu Vizoso, Oded Gabbay, Philipp Stanner,
Danilo Krummrich, Matthew Brost, ckoenig.leichtzumerken
Cc: mcanal, Heiko Stuebner, Gyeyoung Baek, dri-devel, linux-doc,
linux-kernel
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
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH v5 2/2] accel/rocket: Report NPU usage through fdinfo
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
0 siblings, 0 replies; 7+ messages in thread
From: Tvrtko Ursulin @ 2026-11-18 16:42 UTC (permalink / raw)
To: Sidong Yang, Tomeu Vizoso, Oded Gabbay, Philipp Stanner,
Danilo Krummrich, Matthew Brost, ckoenig.leichtzumerken
Cc: mcanal, Heiko Stuebner, Gyeyoung Baek, dri-devel, linux-doc,
linux-kernel
On 12/11/2026 17:11, Sidong Yang wrote:
> There is no way to tell how much of the NPU a client uses. Implement the
> DRM usage stats: report the runtime of the client's scheduler entity as
> drm-engine-npu, along with drm_show_memory_stats() for the BOs.
>
> The cores are identical, so they are reported as a single engine with
> drm-engine-capacity-npu set to rdev->max_cores, the number of core
> slots.
>
> Document the keys in the rocket driver documentation.
>
> Signed-off-by: Sidong Yang <sidong.yang@furiosa.ai>
> ---
> Documentation/accel/rocket/index.rst | 28 +++++++++++++++++++++++++++
> Documentation/gpu/drm-usage-stats.rst | 1 +
> drivers/accel/rocket/rocket_drv.c | 21 +++++++++++++++++++-
> 3 files changed, 49 insertions(+), 1 deletion(-)
>
> diff --git a/Documentation/accel/rocket/index.rst b/Documentation/accel/rocket/index.rst
> index 70f97bccf100..8ae785b65a53 100644
> --- a/Documentation/accel/rocket/index.rst
> +++ b/Documentation/accel/rocket/index.rst
> @@ -17,3 +17,31 @@ project.
> Hardware currently supported:
>
> * RK3588
> +
> +.. _rocket-usage-stats:
> +
> +Rocket DRM client usage stats implementation
> +============================================
> +
> +The accel/rocket driver implements the DRM client usage stats specification as
> +documented in :ref:`drm-client-usage-stats`.
> +
> +The NPU cores are reported as a single engine, npu, with a capacity equal to the
> +number of cores. The time is summed over all cores and is accounted by the DRM
> +GPU scheduler, from when a job is handed to a core until its fence signals.
> +
> +Example of the output showing the implemented key value pairs:
> +
> +::
> +
> + pos: 0
> + flags: 02400002
> + mnt_id: 33
> + ino: 755
> + drm-driver: rocket
> + drm-client-id: 263
> + drm-engine-npu: 2384122043 ns
> + drm-engine-capacity-npu: 3
> + drm-total-memory: 24216 KiB
> + drm-shared-memory: 0
> + drm-active-memory: 3000 KiB
> diff --git a/Documentation/gpu/drm-usage-stats.rst b/Documentation/gpu/drm-usage-stats.rst
> index 70b7cfcc194f..288764730d23 100644
> --- a/Documentation/gpu/drm-usage-stats.rst
> +++ b/Documentation/gpu/drm-usage-stats.rst
> @@ -218,3 +218,4 @@ Driver specific implementations
> * :ref:`panthor-usage-stats`
> * :ref:`xe-usage-stats`
> * :ref:`amdxdna-usage-stats`
> +* :ref:`rocket-usage-stats`
> diff --git a/drivers/accel/rocket/rocket_drv.c b/drivers/accel/rocket/rocket_drv.c
> index 5d7805c41dc3..351be60b1228 100644
> --- a/drivers/accel/rocket/rocket_drv.c
> +++ b/drivers/accel/rocket/rocket_drv.c
> @@ -3,8 +3,10 @@
>
> #include <drm/drm_accel.h>
> #include <drm/drm_drv.h>
> +#include <drm/drm_file.h>
> #include <drm/drm_gem.h>
> #include <drm/drm_ioctl.h>
> +#include <drm/drm_print.h>
> #include <drm/rocket_accel.h>
> #include <linux/clk.h>
> #include <linux/err.h>
> @@ -139,7 +141,23 @@ static const struct drm_ioctl_desc rocket_drm_driver_ioctls[] = {
> ROCKET_IOCTL(FINI_BO, fini_bo),
> };
>
> -DEFINE_DRM_ACCEL_FOPS(rocket_accel_driver_fops);
> +static void rocket_show_fdinfo(struct drm_printer *p, struct drm_file *file)
> +{
> + struct rocket_device *rdev = to_rocket_device(file->minor->dev);
> + struct rocket_file_priv *rocket_priv = file->driver_priv;
> +
> + drm_printf(p, "drm-engine-npu:\t%llu ns\n",
> + drm_sched_entity_get_runtime(&rocket_priv->sched_entity));
> + drm_printf(p, "drm-engine-capacity-npu:\t%u\n", rdev->max_cores);
> +
> + drm_show_memory_stats(p, file);
> +}
> +
> +static const struct file_operations rocket_accel_driver_fops = {
> + .owner = THIS_MODULE,
> + DRM_ACCEL_FOPS,
> + .show_fdinfo = drm_show_fdinfo,
> +};
>
> /*
> * Rocket driver version:
> @@ -150,6 +168,7 @@ static const struct drm_driver rocket_drm_driver = {
> .open = rocket_open,
> .postclose = rocket_postclose,
> .gem_create_object = rocket_gem_create_object,
> + .show_fdinfo = rocket_show_fdinfo,
> .ioctls = rocket_drm_driver_ioctls,
> .num_ioctls = ARRAY_SIZE(rocket_drm_driver_ioctls),
> .fops = &rocket_accel_driver_fops,
Not knowing rocket, so on a glance, it looks good to me.
For the adherence to DRM fdinfo spec at least, which looks completely fine:
Acked-by: Tvrtko Ursulin <tvrtko.ursulin@igalia.com>
Regards,
Tvrtko
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH v5 1/2] drm/sched: Add drm_sched_entity_get_runtime()
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
@ 2026-11-18 17:13 ` Philipp Stanner
2026-11-18 17:39 ` Maíra Canal
1 sibling, 1 reply; 7+ messages in thread
From: Philipp Stanner @ 2026-11-18 17:13 UTC (permalink / raw)
To: Sidong Yang, Tomeu Vizoso, Oded Gabbay, Philipp Stanner,
Danilo Krummrich, Matthew Brost, ckoenig.leichtzumerken
Cc: Tvrtko Ursulin, mcanal, Heiko Stuebner, Gyeyoung Baek, dri-devel,
linux-doc, linux-kernel
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@ursulin.net>
> Signed-off-by: Sidong Yang <sidong.yang@furiosa.ai>
> +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.
P.
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH v5 1/2] drm/sched: Add drm_sched_entity_get_runtime()
2026-11-18 17:13 ` Philipp Stanner
@ 2026-11-18 17:39 ` Maíra Canal
0 siblings, 0 replies; 7+ messages in thread
From: Maíra Canal @ 2026-11-18 17:39 UTC (permalink / raw)
To: phasta, Sidong Yang, Tomeu Vizoso, Oded Gabbay, Danilo Krummrich,
Matthew Brost, ckoenig.leichtzumerken
Cc: Tvrtko Ursulin, Heiko Stuebner, Gyeyoung Baek, dri-devel,
linux-doc, linux-kernel
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@ursulin.net>
>> Signed-off-by: Sidong Yang <sidong.yang@furiosa.ai>
>
>
>> +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.
^ permalink raw reply [flat|nested] 7+ messages in thread
end of thread, other threads:[~2026-11-18 17:39 UTC | newest]
Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
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
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
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®