mbox series

[v3,0/2] drm/v3d: Expose GPU usage stats

Message ID 20230905213416.1290219-1-mcanal@igalia.com (mailing list archive)
Headers show
Series drm/v3d: Expose GPU usage stats | expand

Message

Maíra Canal Sept. 5, 2023, 9:06 p.m. UTC
This patchset exposes GPU usages stats both globally and per-file
descriptor.

The first patch exposes the accumulated amount of active time per client
through the fdinfo infrastructure. The amount of active time is exposed
for each V3D queue. Moreover, it exposes the number of jobs submitted to
each queue.

The second patch exposes the accumulated amount of active time for each
V3D queue, independent of the client. This data is exposed through the
sysfs interface.

With these patches, it is possible to calculate the GPU usage percentage
per queue globally and per-file descriptor.

* Example fdinfo output:

$ cat /proc/1140/fdinfo/4
pos:    0
flags:  02400002
mnt_id: 24
ino:    209
drm-driver:     v3d
drm-client-id:  44
drm-engine-bin:         1661076898 ns
v3d-jobs-bin:   19576 jobs
drm-engine-render:      31469427170 ns
v3d-jobs-render:        19575 jobs
drm-engine-tfu:         5002964 ns
v3d-jobs-tfu:   13 jobs
drm-engine-csd:         188038329691 ns
v3d-jobs-csd:   250393 jobs
drm-engine-cache_clean:         27736024038 ns
v3d-jobs-cache_clean:   250392 job

* Example gputop output:

DRM minor 128
 PID         bin               render               tfu                csd            cache_clean     NAME
1140 |▎                ||██▋               ||                 ||█████████████▍   ||█▋               | computecloth
1158 |▍                ||████████▉         ||                 ||                 ||                 | gears
1002 |▏                ||█▎                ||                 ||                 ||                 | chromium-browse

Best Regards,
- Maíra

---

v1 -> v2: https://lore.kernel.org/dri-devel/20230727142929.1275149-1-mcanal@igalia.com/T/

* Use sysfs to expose global GPU stats (Tvrtko Ursulin)

v2 -> v3: https://lore.kernel.org/dri-devel/20230807211849.49867-1-mcanal@igalia.com/T/

* Document the expected behavior in case of a GPU reset (Melissa Wen)
* Add a brief description about the sysfs outputs (Melissa Wen)
* Instead of having multiple sysfs files, use only one sysfs file,
  called gpu_stats, with all the information (Chema Casanova)
* Add the number of jobs submitted in the global GPU stats (Chema Casanova)
* Now, the number of jobs submitted is only incremented if the job was
  completed

Maíra Canal (2):
  drm/v3d: Implement show_fdinfo() callback for GPU usage stats
  drm/v3d: Expose the total GPU usage stats on sysfs

 drivers/gpu/drm/v3d/Makefile    |  3 +-
 drivers/gpu/drm/v3d/v3d_drv.c   | 45 ++++++++++++++++++++-
 drivers/gpu/drm/v3d/v3d_drv.h   | 31 +++++++++++++++
 drivers/gpu/drm/v3d/v3d_gem.c   |  7 +++-
 drivers/gpu/drm/v3d/v3d_irq.c   | 49 +++++++++++++++++++++++
 drivers/gpu/drm/v3d/v3d_sched.c | 33 ++++++++++++++++
 drivers/gpu/drm/v3d/v3d_sysfs.c | 69 +++++++++++++++++++++++++++++++++
 7 files changed, 234 insertions(+), 3 deletions(-)
 create mode 100644 drivers/gpu/drm/v3d/v3d_sysfs.c

--
2.41.0

Comments

Chema Casanova Oct. 24, 2023, 2:07 p.m. UTC | #1
I've just tested this series, and it is working perfectly. For the two 
patches of the series:

Acked-by: Jose Maria Casanova Crespo <jmcasanova@igalia.com>

Thanks Maíra for taking care of upstreaming this feature.

Chema

El 5/9/23 a las 23:06, Maíra Canal escribió:
> This patchset exposes GPU usages stats both globally and per-file
> descriptor.
>
> The first patch exposes the accumulated amount of active time per client
> through the fdinfo infrastructure. The amount of active time is exposed
> for each V3D queue. Moreover, it exposes the number of jobs submitted to
> each queue.
>
> The second patch exposes the accumulated amount of active time for each
> V3D queue, independent of the client. This data is exposed through the
> sysfs interface.
>
> With these patches, it is possible to calculate the GPU usage percentage
> per queue globally and per-file descriptor.
>
> * Example fdinfo output:
>
> $ cat /proc/1140/fdinfo/4
> pos:    0
> flags:  02400002
> mnt_id: 24
> ino:    209
> drm-driver:     v3d
> drm-client-id:  44
> drm-engine-bin:         1661076898 ns
> v3d-jobs-bin:   19576 jobs
> drm-engine-render:      31469427170 ns
> v3d-jobs-render:        19575 jobs
> drm-engine-tfu:         5002964 ns
> v3d-jobs-tfu:   13 jobs
> drm-engine-csd:         188038329691 ns
> v3d-jobs-csd:   250393 jobs
> drm-engine-cache_clean:         27736024038 ns
> v3d-jobs-cache_clean:   250392 job
>
> * Example gputop output:
>
> DRM minor 128
>   PID         bin               render               tfu                csd            cache_clean     NAME
> 1140 |▎                ||██▋               ||                 ||█████████████▍   ||█▋               | computecloth
> 1158 |▍                ||████████▉         ||                 ||                 ||                 | gears
> 1002 |▏                ||█▎                ||                 ||                 ||                 | chromium-browse
>
> Best Regards,
> - Maíra
>
> ---
>
> v1 -> v2:https://lore.kernel.org/dri-devel/20230727142929.1275149-1-mcanal@igalia.com/T/
>
> * Use sysfs to expose global GPU stats (Tvrtko Ursulin)
>
> v2 -> v3:https://lore.kernel.org/dri-devel/20230807211849.49867-1-mcanal@igalia.com/T/
>
> * Document the expected behavior in case of a GPU reset (Melissa Wen)
> * Add a brief description about the sysfs outputs (Melissa Wen)
> * Instead of having multiple sysfs files, use only one sysfs file,
>    called gpu_stats, with all the information (Chema Casanova)
> * Add the number of jobs submitted in the global GPU stats (Chema Casanova)
> * Now, the number of jobs submitted is only incremented if the job was
>    completed
>
> Maíra Canal (2):
>    drm/v3d: Implement show_fdinfo() callback for GPU usage stats
>    drm/v3d: Expose the total GPU usage stats on sysfs
>
>   drivers/gpu/drm/v3d/Makefile    |  3 +-
>   drivers/gpu/drm/v3d/v3d_drv.c   | 45 ++++++++++++++++++++-
>   drivers/gpu/drm/v3d/v3d_drv.h   | 31 +++++++++++++++
>   drivers/gpu/drm/v3d/v3d_gem.c   |  7 +++-
>   drivers/gpu/drm/v3d/v3d_irq.c   | 49 +++++++++++++++++++++++
>   drivers/gpu/drm/v3d/v3d_sched.c | 33 ++++++++++++++++
>   drivers/gpu/drm/v3d/v3d_sysfs.c | 69 +++++++++++++++++++++++++++++++++
>   7 files changed, 234 insertions(+), 3 deletions(-)
>   create mode 100644 drivers/gpu/drm/v3d/v3d_sysfs.c
>
> --
> 2.41.0
>
>
Maíra Canal Nov. 6, 2023, 1:31 p.m. UTC | #2
Hi,

I've just applied this patchset to drm-misc/drm-misc-next.

Thanks Melissa and Chema for reviewing it!

Best Regards,
- Maíra

On 9/5/23 18:06, Maíra Canal wrote:
> This patchset exposes GPU usages stats both globally and per-file
> descriptor.
> 
> The first patch exposes the accumulated amount of active time per client
> through the fdinfo infrastructure. The amount of active time is exposed
> for each V3D queue. Moreover, it exposes the number of jobs submitted to
> each queue.
> 
> The second patch exposes the accumulated amount of active time for each
> V3D queue, independent of the client. This data is exposed through the
> sysfs interface.
> 
> With these patches, it is possible to calculate the GPU usage percentage
> per queue globally and per-file descriptor.
> 
> * Example fdinfo output:
> 
> $ cat /proc/1140/fdinfo/4
> pos:    0
> flags:  02400002
> mnt_id: 24
> ino:    209
> drm-driver:     v3d
> drm-client-id:  44
> drm-engine-bin:         1661076898 ns
> v3d-jobs-bin:   19576 jobs
> drm-engine-render:      31469427170 ns
> v3d-jobs-render:        19575 jobs
> drm-engine-tfu:         5002964 ns
> v3d-jobs-tfu:   13 jobs
> drm-engine-csd:         188038329691 ns
> v3d-jobs-csd:   250393 jobs
> drm-engine-cache_clean:         27736024038 ns
> v3d-jobs-cache_clean:   250392 job
> 
> * Example gputop output:
> 
> DRM minor 128
>   PID         bin               render               tfu                csd            cache_clean     NAME
> 1140 |▎                ||██▋               ||                 ||█████████████▍   ||█▋               | computecloth
> 1158 |▍                ||████████▉         ||                 ||                 ||                 | gears
> 1002 |▏                ||█▎                ||                 ||                 ||                 | chromium-browse
> 
> Best Regards,
> - Maíra
> 
> ---
> 
> v1 -> v2: https://lore.kernel.org/dri-devel/20230727142929.1275149-1-mcanal@igalia.com/T/
> 
> * Use sysfs to expose global GPU stats (Tvrtko Ursulin)
> 
> v2 -> v3: https://lore.kernel.org/dri-devel/20230807211849.49867-1-mcanal@igalia.com/T/
> 
> * Document the expected behavior in case of a GPU reset (Melissa Wen)
> * Add a brief description about the sysfs outputs (Melissa Wen)
> * Instead of having multiple sysfs files, use only one sysfs file,
>    called gpu_stats, with all the information (Chema Casanova)
> * Add the number of jobs submitted in the global GPU stats (Chema Casanova)
> * Now, the number of jobs submitted is only incremented if the job was
>    completed
> 
> Maíra Canal (2):
>    drm/v3d: Implement show_fdinfo() callback for GPU usage stats
>    drm/v3d: Expose the total GPU usage stats on sysfs
> 
>   drivers/gpu/drm/v3d/Makefile    |  3 +-
>   drivers/gpu/drm/v3d/v3d_drv.c   | 45 ++++++++++++++++++++-
>   drivers/gpu/drm/v3d/v3d_drv.h   | 31 +++++++++++++++
>   drivers/gpu/drm/v3d/v3d_gem.c   |  7 +++-
>   drivers/gpu/drm/v3d/v3d_irq.c   | 49 +++++++++++++++++++++++
>   drivers/gpu/drm/v3d/v3d_sched.c | 33 ++++++++++++++++
>   drivers/gpu/drm/v3d/v3d_sysfs.c | 69 +++++++++++++++++++++++++++++++++
>   7 files changed, 234 insertions(+), 3 deletions(-)
>   create mode 100644 drivers/gpu/drm/v3d/v3d_sysfs.c
> 
> --
> 2.41.0
>