Skip to content

RFC DRM standardized memory stats

Tvrtko Ursulin amd-gfx dri-devel 1 version In review

Get series with b4
b4 am [email protected]

Versions newest first

  1. v1 RFC Latest2 patches 4 repliesIn review

Patches in v1 No applies recorded yet

#Subject and filesSizeRepliesApplied
1/2drm: Allow drivers to report standardized memory statsdrivers/gpu/drm/drm_drv.c drivers/gpu/drm/drm_sysfs.c include/drm/drm_device.h +3 more+173 -02 replies
2/2drm/amdgpu: Wire up DRM memory stats reportingdrivers/gpu/drm/amd/amdgpu/amdgpu.h drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c drivers/gpu/drm/amd/amdgpu/amdgpu_fdinfo.c +2 more+75 -130 replies

Reviews trailers per patch

No Reviewed-by, Acked-by or Tested-by trailers for v1 yet.

Read the v1 thread

Cover letter [RFC 0/2] DRM standardized memory stats

Re-floating a simple idea (this time with more Cc) born from an user interest to be able to correctly size the swap space during OS installation, based on the size of the VRAM a discrete GPU might have. And to be able to do it in a vendor agnostic way.

Idea is to expose a standardized scheme in sysfs, under the DRM class card, and under a new 'memstat' directory. Such as, example from amdgpu:

/sys/class/drm/card1/memstat/

├── gtt
│   ├── total_mb
│   └── used_mb
└── vram
    ├── total_mb
    └── used_mb

Or with concrete numbers:

$ grep -Hr . /sys/class/drm/card1/memstat/
/sys/class/drm/card1/memstat/vram/total_mb:1024
/sys/class/drm/card1/memstat/vram/used_mb:445
/sys/class/drm/card1/memstat/gtt/total_mb:7394
/sys/class/drm/card1/memstat/gtt/used_mb:71

Drivers need to implement a simple DRM driver level callback which needs to report a stable list of interesting memory regions and their respective stats. The region names then become sub-directory names under the new 'memstat' directory, with each region exposing the total size and the current usage.

Similar data can already be queried if the dmem cgroup controller is enabled, also only for the participating drivers, by querying the root cgroup. But perhaps sysfs is easier, or perhaps it is too much code for too little benefit. I am curious to hear any opinions.

Cc Maíra Canal <[email protected]>
Cc Ludovico de Nittis <[email protected]>
Cc Alex Deucher <[email protected]>
Cc Christian König <[email protected]>
Cc Maarten Lankhorst <[email protected]>
Cc Maxime Ripard <[email protected]>
Cc Thomas Zimmermann <[email protected]>
Cc David Airlie <[email protected]>
Cc Simona Vetter <[email protected]>

Tvrtko Ursulin (2):
drm: Allow drivers to report standardized memory stats drm/amdgpu: Wire up DRM memory stats reporting

 drivers/gpu/drm/amd/amdgpu/amdgpu.h        |   6 +
 drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c    |   2 +-
 drivers/gpu/drm/amd/amdgpu/amdgpu_fdinfo.c |  40 +++++--
 drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c    |  37 +++++++
 drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.h    |   3 +
 drivers/gpu/drm/drm_drv.c                  |  10 ++
 drivers/gpu/drm/drm_sysfs.c                | 123 +++++++++++++++++++++
 include/drm/drm_device.h                   |  19 ++++
 include/drm/drm_drv.h                      |   8 ++
 include/drm/drm_file.h                     |   9 ++
 include/drm/drm_sysfs.h                    |   4 +
 11 files changed, 248 insertions(+), 13 deletions(-)
Signature · 1 line
2.55.0