diff options
| author | Danilo M. <danix@danix.xyz> | 2026-10-04 18:52:40 +0200 |
|---|---|---|
| committer | Danilo M. <danix@danix.xyz> | 2026-10-04 18:52:40 +0200 |
| commit | 416fa4876018e5fbb9c3f537ea9c353d1d8b9982 (patch) | |
| tree | ba72117f5a7a8dda2cbe65614b410e6ba2bd4d09 /test/test_data.lua | |
| parent | 96ac1ee65da31055704e0a14cafacc33914d7e86 (diff) | |
| download | conky-theme-udt-416fa4876018e5fbb9c3f537ea9c353d1d8b9982.tar.gz conky-theme-udt-416fa4876018e5fbb9c3f537ea9c353d1d8b9982.zip | |
feat(gpu): show VRAM in use as a bar with a percentage
Sum drm-resident-vram0 from DRM fdinfo, the same per-client counters
gputop reads, counting each drm-client-id once since a client repeats
its totals on every fd it holds. One grep over /proc/*/fdinfo, about
10ms warm, sampled through new_gate every ~2s.
The 12 GiB total is hardcoded: xe exposes no VRAM capacity in sysfs.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Diffstat (limited to 'test/test_data.lua')
| -rw-r--r-- | test/test_data.lua | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/test/test_data.lua b/test/test_data.lua index 2d4d5c7..ec2b6ed 100644 --- a/test/test_data.lua +++ b/test/test_data.lua @@ -479,6 +479,26 @@ assert(up.upgrade == 3 and up.bump == 1 and up.current == 46 and up.missing == 1 'updates summary') assert(data.nvtable_parse('') == nil, 'updates: empty cache is nil') +-- drm_vram_parse: xe clients counted once across their fds, other drivers +-- skipped, units honoured. +local fdinfo = table.concat({ + '/proc/1/fdinfo/5:drm-driver:\txe', + '/proc/1/fdinfo/5:drm-client-id:\t7', + '/proc/1/fdinfo/5:drm-resident-vram0:\t1024 KiB', + '/proc/1/fdinfo/6:drm-driver:\txe', + '/proc/1/fdinfo/6:drm-client-id:\t7', + '/proc/1/fdinfo/6:drm-resident-vram0:\t1024 KiB', + '/proc/2/fdinfo/9:drm-driver:\txe', + '/proc/2/fdinfo/9:drm-client-id:\t8', + '/proc/2/fdinfo/9:drm-resident-vram0:\t2 MiB', + '/proc/3/fdinfo/4:drm-driver:\tamdgpu', + '/proc/3/fdinfo/4:drm-client-id:\t9', + '/proc/3/fdinfo/4:drm-resident-vram0:\t5 GiB', +}, '\n') +assert(data.drm_vram_parse(fdinfo) == 3 * 1024 ^ 2, + 'drm vram: got ' .. tostring(data.drm_vram_parse(fdinfo))) +assert(data.drm_vram_parse('') == nil, 'drm vram: no clients is nil') + -- new_gate: opens at most once per interval on the clock it is given. local gate = data.new_gate(1.9) assert(gate(100.0) == true, 'gate: first call opens') |
