Repository navigation
Conversation
e5e3853 to
1f8f375
Compare
There was a problem hiding this comment.
Pull request overview
This PR adds support for Intel GPUs using the Xe kernel driver, which is required for newer Intel hardware like Lunar Lake and Battlemage that don't use the legacy i915 driver.
Changes:
- Added minimal
xe_drm.hheader with UAPI definitions for interfacing with the Xe driver - Implemented Xe namespace with PMU-based GPU monitoring using perf events
- Added dynamic driver detection and PMU device discovery to support both i915 and Xe drivers
- Routes collection to appropriate code path based on detected driver type
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 14 comments.
| File | Description |
|---|---|
| src/linux/xe_drm.h | New header file containing minimal Xe DRM UAPI definitions (structs and ioctls) for device query and engine enumeration |
| src/linux/btop_collect.cpp | Added Xe namespace with PMU-based monitoring, dynamic driver detection, PMU device discovery, and routing logic to switch between i915 and Xe code paths |
Comments suppressed due to low confidence (1)
src/linux/btop_collect.cpp:2103
- Missing free() call for gpu_path on error path. If get_intel_device_id() returns null, the function returns false without freeing gpu_path that was allocated by find_intel_gpu_dir().
char *gpu_device_id = get_intel_device_id(gpu_path);
if (!gpu_device_id) {
Logger::debug("Failed to find Intel GPU device ID, Intel GPUs will not be detected");
return false;
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
178426b to
c4341c0
Compare
1b841c3 to
cc2af96
Compare
|
Thanks for the feedback! |
|
I was referring to the code style. Please continue using fmt, since this is preferred. But I was referring to things like changing the indentation of completely unrelated code. This makes for a larger diff and can sometimes get your PR rejected outright in some repositories. |
cc2af96 to
45aa98f
Compare
|
Works well on my both laptops, Tiger Lake-H and Raptor Lake-P iGPUs. No need for sudo access to read GPU stats. When it will be merged? |
|
Rebased this on current The branch now prefers I reran The main limitation still left is that unprivileged |
|
Thanks, @MrChuw The last Xe fdinfo change was skewing the percentage. I had added That part is removed, so the latest head should be back to the expected raw fdinfo-style value. If you get a chance, please try the latest commit again and let me know how it looks. |
| // Collect GPU cycles from all processes' fdinfo with client-id deduplication. | ||
| // Keep raw per-class totals so the resulting utilization matches the semantics | ||
| // used by existing DRM tools such as nvtop. | ||
| static FdinfoCycles collect_fdinfo_cycles(const string& pci_slot) { |
There was a problem hiding this comment.
Whats the performance impact of this? (How long does the collection cycle for GPU take when running btop with --debug when using the fdinfo method?)
There was a problem hiding this comment.
about 24-48 ms per scan on Lunar Lake, throttled to once per 500 ms on the collector thread
Added a --debug line (Xe: fdinfo scan ) to measure it on any device
|
Rebased and pushed. @aristocratos, @MrChuw, B580 % restored via Deferred to a follow-up PR: multi-engine class capacity normalization (Battlemage VCS=2 / DG2 CCS=4 partial-use underreport). |
0785ff3 to
76530c8
Compare
|
Force-pushed, rebased onto current main (resolves the merge conflict), squashed to one commit, and integrated with the new AMD Asysfs backend. New since last review:
Deferred: CCS / multi-engine capacity normalization; i915 still needs PMU permissions. |
|
I just now tested it on Arch Linux with my Intel Core Ultra 325 iGPU, and I don't see VRAM or power usage. On my desktop with an Arc B580, I see VRAM usage fine but it still doesn't show power. nvtop is able to see VRAM on both devices, and power on the B580 (still not on the Panther Lake iGPU, but that might not be btop's fault) |
Add a dedicated Xe collection path for Intel GPUs using the xe kernel driver (Lunar Lake, Battlemage, newer Arc Pro), which the legacy i915 path cannot detect. - Add namespace Gpu::Xe in src/linux/btop_collect.cpp with multi-GPU discovery and per-instance i915/xe routing - Add minimal src/linux/xe_drm.h with the Xe UAPI definitions btop needs - Utilization from fdinfo (drm-cycles-* / drm-total-cycles-*) with gtidle sysfs and Xe PMU perf-event fallbacks - GPU clock from Xe sysfs frequency nodes - Dedicated VRAM usage via DRM_IOCTL_XE_DEVICE_QUERY (skips SYSMEM-only devices so shared system memory is not reported as VRAM) - GPU power for discrete Arc via hwmon (power1_average/_input); integrated GPUs expose no GPU power sensor and report power as unsupported - Expose RC/MC split graphs (gpu-rc-totals / gpu-mc-totals, gt_utilization) without modifying src/linux/intel_gpu_top/ - Keep showing the GPU when the DRM render node can't be opened (e.g. the user is not in the 'render' group): VRAM is skipped but gtidle/fdinfo utilization and sysfs clock still work, instead of dropping the GPU - Scan /proc fdinfo without throwing on unreadable (other-user) processes and log per-scan duration at --debug level Does not touch the IGT-imported files, per maintainer feedback on aristocratos#1408. Squashed from 22 commits and rebased onto upstream/main; integrated with the new AMD APU/iGPU sysfs backend (Gpu::Asysfs) by offsetting Intel GPU slots past Asysfs::device_count. Closes aristocratos#1407
76530c8 to
ca52fdd
Compare
|
Rebased onto main.
A B580/B70 power report would help. |






Summary
Adds support for Intel GPUs on the Xe kernel driver (Lunar Lake, Battlemage, newer Arc / Arc Pro), which the i915 path can't detect.
Closes #1407
What Changed
Xecollection path insrc/linux/btop_collect.cpp, with multi-GPU discovery and per-device i915/xe routingsrc/linux/xe_drm.hwith the Xe UAPI definitions needed for the VRAM querysrc/linux/intel_gpu_top/is unchangedMetrics (Xe)
drm-cycles-*; gtidle sysfs when no client is visibletile0/gt*/freq0/cur_freqDRM_XE_DEVICE_QUERY_MEM_REGIONS, dedicated VRAM onlyenergy1_input(card) orenergy2_input(package), discrete cards onlyUtilization per engine class is
Δcycles / (Δtotal × drm-engine-capacity), and the GPU total is the busiest class, like intel_gpu_top. Counters are kept perdrm-client-id, so a client exiting doesn't affect the others. No smoothing.No root needed. Without access to the render node, VRAM is skipped and the rest still works. SR-IOV VFs have no gtidle, so they show VRAM only.
Performance
The fdinfo scan runs at most every 500 ms on the collector thread: ~25–40 ms per scan on Lunar Lake (Core Ultra 5 228V). Logged at
--debugasXe: fdinfo scan <ms>.Known limitations
Testing
make, CMake + ctest, CMake with-DBTOP_GPU=OFF