intel / intel/xpumanager

xpu-smi: Incorrect process memory usage

Open
#145 3 comments 0 reactions 0 assignees View on GitHub
Dominant language
C++
Stars
194
Forks
34
PR merge metrics
No merged PRs in 30d

Description

Hi, the process 'GPU Memory Usage' values from `xpu-smi` seem to be much more than the card's total memory usage.

E.g. Firefox is reported to be using 7692 MiB, when the card's total is only 3642MiB.

```
+----------------------------------------------+----------------------------+------------------------+
| Intel XPU-SMI v2.0 Driver: 96E1802BAF7F7118043A89B Level Zero: 1.32.0 |
+----------------------------------------------+----------------------------+------------------------+
| GPU Name Persistence-M | Bus-Id Disp.A | Volatile Uncorr. ECC |
| Fan Temp Pwr:Usage/Cap | Memory-Usage | GPU-Util Compute M. |
+----------------------------------------------+----------------------------+------------------------+
| 0 Intel(R) Arc(TM) A770 Off | 0000:03:00.0 Off | Disabled |
| Graphics | | |
| N/A N/A 45W / 190W | 3642MiB / 16288MiB | N/A Default |
+----------------------------------------------+----------------------------+------------------------+

+-------+----------+--------+----------------------------------------------------+--------------------+
| Processes: |
| GPU PID Type Process Name GPU Memory Usage |
+-------+----------+--------+----------------------------------------------------+--------------------+
| 0 2345 C /usr/bin/ksecretd 23 MiB |
| 0 2675 C /usr/bin/Xwayland 29 MiB |
| 0 2800 C /usr/bin/ksmserver 13 MiB |
| 0 2802 C /usr/bin/kded6 23 MiB |
| 0 2857 C /usr/bin/plasmashell 1402 MiB |
| 0 2898 C /usr/bin/krdpserver 23 MiB |
| 0 2901 C /usr/bin/kaccess 13 MiB |
| 0 3206 C /usr/bin/kdeconnectd 23 MiB |
| 0 3362 C /usr/lib/x86_64-linux-gnu/libexec/DiscoverNotifier 23 MiB |
| 0 3377 C /usr/bin/kup-daemon 23 MiB |
| 0 3539 C /usr/lib/x86_64-linux-gnu/libexec/xdg-desktop-p... 23 MiB |
| 0 3545 C openrgb 23 MiB |
| 0 3643 C /app/lib/firefox/firefox 7692 MiB |
| 0 3785 C /app/discord/Discord 408 MiB |
| 0 3885 C /app/lib/firefox/firefox-bin -contentproc -pare... 45 MiB |
| 0 4089 C /usr/bin/plasma-browser-integration-host 23 MiB |
| 0 30005 C /usr/bin/kwalletd6 23 MiB |
| 0 49966 C /app/chromium/chrome --type=gpu-process --ozone... 1119 MiB |
| 0 61859 C /usr/lib/x86_64-linux-gnu/libexec/baloorunner 23 MiB |
| 0 176823 C /usr/bin/dolphin 23 MiB |
| 0 186527 C /app/share/zotero/zotero-bin 729 MiB |
| 0 196808 C /usr/bin/konsole 23 MiB |
| 0 265680 C qalculate-qt 23 MiB |
| 0 266813 C /usr/share/code/code --type=gpu-process --ozone... 1152 MiB |
+-------+----------+--------+----------------------------------------------------+--------------------+
```

While `nvtop` reports Firefox as using 1977MiB which seems much more reasonable.

---

I believe this is because `xpu-smi` adds all the values from the process fdinfo memory usage together, instead of only adding values with a unique `drm-client-id`.
```
stephen@Stephens-PC:~$ grep -E '^drm-client-id|^drm-total-vram0' /proc/3643/fdinfo/*
/proc/3643/fdinfo/170:drm-client-id: 294
/proc/3643/fdinfo/170:drm-total-vram0: 0
/proc/3643/fdinfo/176:drm-client-id: 296
/proc/3643/fdinfo/176:drm-total-vram0: 0
/proc/3643/fdinfo/179:drm-client-id: 305
/proc/3643/fdinfo/179:drm-total-vram0: 0
/proc/3643/fdinfo/184:drm-client-id: 297
/proc/3643/fdinfo/184:drm-total-vram0: 37036 KiB
/proc/3643/fdinfo/21:drm-client-id: 47
/proc/3643/fdinfo/21:drm-total-vram0: 1950572 KiB
/proc/3643/fdinfo/297:drm-client-id: 307
/proc/3643/fdinfo/297:drm-total-vram0: 0
/proc/3643/fdinfo/318:drm-client-id: 308
/proc/3643/fdinfo/318:drm-total-vram0: 37036 KiB
/proc/3643/fdinfo/50:drm-client-id: 47
/proc/3643/fdinfo/50:drm-total-vram0: 1950572 KiB
/proc/3643/fdinfo/51:drm-client-id: 47
/proc/3643/fdinfo/51:drm-total-vram0: 1950572 KiB
/proc/3643/fdinfo/52:drm-client-id: 47
/proc/3643/fdinfo/52:drm-total-vram0: 1950572 KiB
/proc/3643/fdinfo/53:drm-client-id: 51
/proc/3643/fdinfo/53:drm-total-vram0: 0
/proc/3643/fdinfo/54:drm-client-id: 51
/proc/3643/fdinfo/54:drm-total-vram0: 0
/proc/3643/fdinfo/55:drm-client-id: 51
/proc/3643/fdinfo/55:drm-total-vram0: 0
```

E.g. `(1950572×4+37036+37036)/1024 ≈ 7692MiB` matches `xpu-smi`, while the actual memory usage is `(1950572+37036+37036)/1024 ≈ 1977MiB` (matches `nvtop`).

---

I am running an A770 with the xe driver, on Debian testing (forky).

Thanks,
Steve

Contributor guide

Open the contributing guide

Research direction

Start at xpu-smi's process-memory reporting entry point and compare its accounting with the supplied `/proc/3643/fdinfo/*` records. Verify how repeated `drm-client-id` values are handled and reproduce the Firefox discrepancy; done means each client's memory is counted once and the reported total matches the unique-client calculation.

Written by the indexing model from the issue text.

Assessment

Tech stack
linux
Domain
cli, operating-systems
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Quiet
Clarity
Mostly clear
Newbie friendliness
58/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.