Skip to content

Intel sysman backend: fdinfo and hwmon fallbacks for xe telemetry gaps - #69

Merged
benapetr merged 2 commits into
benapetr:masterfrom
zznty:intel-hybrid-fdinfo-temp-fallback
Sep 10, 2026
Merged

benapetr merged 2 commits into
benapetr:masterfrom
zznty:intel-hybrid-fdinfo-temp-fallback

Conversation

@zznty

@zznty zznty commented Sep 2, 2026

Copy link
Copy Markdown
Contributor

On the xe driver the Level Zero sysman backend only delivers VRAM, power and core clock for regular users:

  • zesDeviceEnumEngineGroups requires root (compute-runtime gates it behind geteuid() == 0, returning ZE_RESULT_ERROR_INSUFFICIENT_PERMISSIONS), so GPU utilization stays 0
  • temperature sensors are PMT-gated and return 0 sensors on most discrete xe systems, even as root

Changes (Intel Sysman backend only):

  • Engine activity: when sysman cannot enumerate engine groups, fall back to per-client DRM fdinfo counters — drm-cycles-*/drm-total-cycles-* on xe (utilization = delta busy / delta GPU clock), legacy drm-engine-* nanoseconds on i915. drm-engine-capacity-* lines are static metadata and are skipped.
  • Temperature: when sysman exposes no sensors, read the package sensor from hwmon tempN_input under the PCI device.
  • Fixed stale sysman structure type constants (pre-1.11 sequential values) that corrupted zes_freq_properties_t min/max.

Sysman remains the source for VRAM, core clock and power, which already work without root. Root behavior is unchanged (sysman engines take precedence).


Footnote: this PR was vibecoded (AI-assisted). Verified on an Intel Arc A770, xe driver, kernel 7.2.2 — utilization, per-engine graphs and temperature confirmed working as a non-root user.

zznty and others added 2 commits September 3, 2026 04:40
Review of 3ed30c1 (fdinfo/hwmon fallbacks for xe telemetry gaps) surfaced
several correctness bugs in the DRM fdinfo engine-activity fallback used
when sysman can't enumerate engine groups (non-root on xe):

- Render node, fd cache, and rescan counter were single per-backend
  fields shared across every GPU, so on multi-GPU systems the second
  device would scan the first device's render node and never match its
  own pdev, permanently reporting 0% utilization. State is now keyed
  per PCI BDF (FdInfoGpuState).
- Duplicate fds referencing the same DRM client (fork()/dup(), common
  for compositors) were summed without dedup, double-counting busy
  time. drm-client-id is now parsed and deduped per scan, matching the
  sibling GpuDrmBackend's seenClients approach.
- Only the render node was matched; card/control-node clients (direct
  KMS/GEM access) were invisible. Both nodes are now matched.
- drm-engine-capacity-* was parsed and discarded, so multi-instance
  engine classes (e.g. xe vcs=2, ccs=4) were never normalized by
  instance count, over/under-reporting utilization.
- New clients discovered mid-run had their whole lifetime counter
  folded into the aggregate delta, producing a spurious 100% spike.
  Accounting moved to a per-client baseline (busy/cycles per
  clientKey/engineKey) so a client only contributes from its second
  observed sample onward.

Follow-up fixes to the above (caught by a second review pass):
- Capacity key parsing had an off-by-one (drm-engine-capacity- is 20
  chars, code read from offset 21), so capacity was stored under the
  wrong key and normalization silently never applied. All four fdinfo
  prefix offsets now derive from the QLatin1String literal's own
  length instead of a hardcoded number.
- A per-client counter that dipped (glitch, not a real reset) had its
  baseline overwritten with the lower reading; a later partial
  recovery would then be miscounted as fresh activity. The baseline
  now retains the previous high-water mark until the counter catches
  back up.
- xe's shared GT reference-clock baseline was only updated for engine
  keys that already had a client delta, so the first sample where a
  new engine class got its first delta compared against a zeroed
  baseline instead of the previous sample's reading, producing one
  extra bogus near-zero sample. Class metadata is now captured for
  every key seen this scan, including ones without a client baseline
  yet.

Verified: single-file and full qmake build both compile clean (0
errors, 0 warnings) against Qt 6.9.0; not yet exercised against real
xe/i915 hardware.
@benapetr

benapetr commented Sep 9, 2026

Copy link
Copy Markdown
Owner

yeah we can all use AI :D

I used my AI to fix bugs your AI made.

Now can you test it on your Intel card? I don't have any for that.

@zznty

zznty commented Sep 9, 2026

Copy link
Copy Markdown
Contributor Author

can confirm everything works for me.

also note that intel drivers show Shared memory stats as 0 / 0, for some reason they dont have such feature at all meaning on linux any allocation beyond vram capacity throws OOM, while on windows it spills into ram.
i'm not sure if the graph was intended to stay instead of being hidden, should i open issue for that?

@benapetr

Copy link
Copy Markdown
Owner

yeah, we should probably make it possible to hide that graph so it's not taking space

@benapetr
benapetr merged commit 5405149 into benapetr:master Sep 10, 2026
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants