Skip to content

Conversation

@stsdc
Copy link
Member

@stsdc stsdc commented Oct 31, 2025

Needs testing on hardware.

  • Intel (i915 driver)
  • Intel (Xe driver)
  • AMD Radeon
  • nVidia

@stsdc stsdc marked this pull request as draft October 31, 2025 22:31
@stsdc stsdc marked this pull request as ready for review November 2, 2025 16:59
@stsdc stsdc requested a review from a team November 2, 2025 16:59
@stsdc stsdc marked this pull request as draft November 2, 2025 17:04
@stsdc stsdc marked this pull request as ready for review November 16, 2025 00:10
@Tbusk
Copy link
Contributor

Tbusk commented Nov 19, 2025

This doesn't currently work on my AMD gpu. The reason is that drm-engine-render doesn't have any values on my system.

drm-engine-gfx however does yield results that are comparable to other apps like Resources.

So adding a fall-through case above drm-engine-render is working on my system.

I updated the percentage shown to one digit like the other app shows for testing.

image image image

@stsdc
Copy link
Member Author

stsdc commented Nov 20, 2025

May I ask you to propose a PR that works for you?

I'm wondering what would be the best solution to choose the right engine to read. We need to read driver name from GPU class and based on that do the right choice.

@Tbusk
Copy link
Contributor

Tbusk commented Nov 22, 2025

@stsdc I've been looking around, but the kernel docs are not the clearest on this.

Instead, its easier to simply read the output from various files in fdinfo on various setups.

Doing this, there only shows up two engines and that the driver is amdgpu, which afaik is the open-source driver version that is most used.

Here is info from a heavy gpu process:
sudo cat /proc/15768/fdinfo/6

pos:	0
flags:	02100002
mnt_id:	29
ino:	1197
drm-driver:	amdgpu
drm-client-id:	126
drm-pdev:	0000:03:00.0
pasid:	32793
drm-total-cpu:	0
drm-shared-cpu:	0
drm-resident-cpu:	0
drm-purgeable-cpu:	0
drm-total-gtt:	14716 KiB
drm-shared-gtt:	0
drm-resident-gtt:	14716 KiB
drm-purgeable-gtt:	0
drm-total-vram:	90340 KiB
drm-shared-vram:	2320 KiB
drm-resident-vram:	90340 KiB
drm-purgeable-vram:	25344 KiB
drm-total-gds:	0
drm-shared-gds:	0
drm-resident-gds:	0
drm-purgeable-gds:	0
drm-total-gws:	0
drm-shared-gws:	0
drm-resident-gws:	0
drm-purgeable-gws:	0
drm-total-oa:	0
drm-shared-oa:	0
drm-resident-oa:	0
drm-purgeable-oa:	0
drm-total-doorbell:	0
drm-shared-doorbell:	0
drm-resident-doorbell:	0
drm-purgeable-doorbell:	0
drm-memory-vram:	90340 KiB
drm-memory-gtt: 	14716 KiB
drm-memory-cpu: 	0 KiB
amd-evicted-vram:	0 KiB
amd-requested-vram:	90340 KiB
amd-requested-gtt:	14716 KiB
drm-engine-gfx:	420209306 ns
drm-engine-compute:	1370523 ns

The drm-engine-gfx is the only one that is incrementing over time.

https://github.com/torvalds/linux/blob/master/drivers/gpu/drm/amd/include/amd_shared.h

I'm assuming that engine is called the Graphics and Compute Engine.

There also appears to be a pro version of the driver, but I don't have that right now. I think I can get it by installing ROCm, but I'm not sure I'd need it for a while, and it is a bit of a hassle. Might be easier to rent a server briefly to get this gpu information.

@stsdc
Copy link
Member Author

stsdc commented Nov 22, 2025

@Tbusk also check what Resources does: https://github.com/nokyan/resources/blob/main/lib/process_data/src/gpu_usage.rs
Nokyan figured this out some time ago.
I just need your PR to make sure that it works for AMD. You can edit Intel specific part drm-engine-renderdrm-engine-gfx and whatever needed. It will make this code AMD specific. But when I'll introduce some sort of manager (or factory?) to create a Process object with the right method, we will have support for both Intel and AMD.

@Tbusk
Copy link
Contributor

Tbusk commented Nov 22, 2025

Just checked what my nvidia 3000 series laptop is running during a stress test (which works on the PR) towards both my onboard graphics and my nvidia card:

I have nvidia-driver-570 installed.

cat /proc/5115/fdinfo/17

pos:	0
flags:	02100002
mnt_id:	29
ino:	970
drm-driver:	i915
drm-client-id:	100
drm-pdev:	0000:00:02.0
drm-total-system0:	124508 KiB
drm-shared-system0:	20 MiB
drm-active-system0:	104632 KiB
drm-resident-system0:	124508 KiB
drm-purgeable-system0:	412 KiB
drm-total-stolen-system0:	0
drm-shared-stolen-system0:	0
drm-active-stolen-system0:	0
drm-resident-stolen-system0:	0
drm-purgeable-stolen-system0:	0
drm-engine-render:	70853540131 ns
drm-engine-copy:	0 ns
drm-engine-video:	0 ns
drm-engine-capacity-video:	2
drm-engine-video-enhance:	0 ns

Also the only addition needed to make it work on my amd machine is to add a fall-though case above your case in the switch in src/Managers/Process.vala @stsdc which is why it is working in my screenshots.

So

case "drm-engine-gfx":
case "drm-engine-render":

I can do a pr if you want.

@stsdc
Copy link
Member Author

stsdc commented Nov 22, 2025

I'll appreciate if you'll make a PR.
Also wondering if we should sum up drm-engine-gfx and drm-engine-compute, or any other engines? 🤔

@Tbusk
Copy link
Contributor

Tbusk commented Nov 22, 2025

I'll appreciate if you'll make a PR. Also wondering if we should sum up drm-engine-gfx and drm-engine-compute, or any other engines? 🤔

After looking at it a little, the value of drm-engine-compute does go up, but in increments much smaller than the other.

Example of a handful of minutes difference in a stress test:

drm-engine-gfx:	44629292665 ns
drm-engine-compute:	3848787 ns
drm-engine-gfx:	186754994879 ns
drm-engine-compute:	4071513 ns

@stsdc
Copy link
Member Author

stsdc commented Nov 26, 2025

@Tbusk please check if it works for you now

@Tbusk
Copy link
Contributor

Tbusk commented Nov 26, 2025

@Tbusk please check if it works for you now

@stsdc it is working for amd setup.

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.

3 participants