GPU boxes on the Processes tab: busy, engines, temps, and who has the card open

Every DRM device with a real GPU driver gets a box under the cpu box, laid out
like it: the busy curve, a meter for the device and one per engine, temperature,
clock, power and fan where the card has them, and the processes holding it open
with their share. The process table gains a Gpu% column and sort.

Device busy is Intel's RC6 idle residency inverted (what intel_gpu_top shows,
and readable without root) or amdgpu's gpu_busy_percent. Per-process shares are
DRM fdinfo deltas, as nvtop reads them; other users' fdinfo needs root, so a
daemon running as a user keeps one root child (hamlab drm-clients) over a pipe
rather than paying a sudo a second. Everything is also a gpu.* sensor.

What cannot be measured is left out, not shown as zero: an Arc A380 on i915 6.12
has no temperature sensor, an integrated GPU wears the package temperature
marked *, and Asahi has neither a busy counter nor fdinfo yet.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
This commit is contained in:
Mitchell-Johnson
2026-10-02 18:18:02 -07:00
co-authored by Claude Fable 5.1
parent 0e82719070
commit db40220365
11 changed files with 981 additions and 19 deletions
+42
View File
@@ -131,6 +131,48 @@ func flatten(s Sample, want func(id string) bool) []sensors.Sensor {
f.add(p+".used_pct", x.Mount+" used", "usage", "%", ratio(x.Used, x.Size), s.fsT, pct, lbl...)
}
for _, g := range s.GPUs {
p := "gpu." + sensors.Seg(g.Name)
lbl := []string{"name", g.Name, "driver", g.Driver}
if g.Bus != "" {
lbl = append(lbl, "bus", g.Bus)
}
if g.Integrated {
lbl = append(lbl, "integrated", "1")
}
if g.UsageSrc != "" {
f.add(p+".usage", g.Name, "usage", "%", g.Usage, t, pct, lbl...)
}
for _, e := range []string{"render", "video", "copy", "video-enhance", "compute"} {
if v, ok := g.Engines[e]; ok {
f.add(p+"."+sensors.Seg(e), g.Name+" "+e, "usage", "%", v, t, pct, lbl...)
}
}
if g.Temp > 0 {
f.add(p+".temp", g.Name+" temperature", "temperature", "°C", g.Temp, t, none, append(lbl, "source", g.TempSrc)...)
}
if g.PowerW > 0 || g.PowerCapW > 0 {
b := none
if g.PowerCapW > 0 {
b = upTo(g.PowerCapW)
}
f.add(p+".power", g.Name+" power", "power", "W", g.PowerW, t, b, lbl...)
}
if g.FanRPM > 0 {
f.add(p+".fan", g.Name+" fan", "fan", "rpm", float64(g.FanRPM), t, none, lbl...)
}
if g.MaxMHz > 0 {
f.add(p+".freq", g.Name+" clock", "frequency", "MHz", g.MHz, t, upTo(g.MaxMHz), lbl...)
}
if g.MemTotal > 0 {
f.add(p+".mem_used", g.Name+" memory used", "bytes", "B", float64(g.MemUsed), t, upTo(float64(g.MemTotal)), lbl...)
f.add(p+".mem_total", g.Name+" memory", "bytes", "B", float64(g.MemTotal), t, none, lbl...)
} else if g.MemUsed > 0 {
f.add(p+".mem_used", g.Name+" memory used", "bytes", "B", float64(g.MemUsed), t, none, lbl...)
}
f.add(p+".clients", g.Name+" clients", "count", "", float64(len(g.Clients)), t, none, lbl...)
}
if u := s.UPS; u != nil {
ut := s.upsT
f.add("ups.battery", "UPS battery", "usage", "%", u.BatteryPct, ut, pct, "model", u.Model)