Skip to content

A GPU task manager for Windows, Linux, and WSL: per-process VRAM, GPU activity, and LLM model/KV-cache insights (Windows AMD and NVIDIA).

Python

Show Intel GT clock and throttle, charge private iGPU memory

Martin Pluskal2492c32c04ff
diff --git a/README.md b/README.md
index e2f1083..256f5c4 100644
--- a/README.md
+++ b/README.md
@@ -245,16 +245,15 @@ covered by unit tests only and **not yet validated on AMD hardware**.
| | Source |
|---|---|
-| Device temperature, power, GT clock | `hwmon` and `gt/gt0` under `/sys/class/drm/card*`. Power is the rate of the cumulative energy counter between two refreshes, so it is `n/a` on the first |
+| Device temperature, power, GT clock, throttle | `hwmon` and `gt/gt0` under `/sys/class/drm/card*`. Power is the rate of the cumulative energy counter between two refreshes, so it is `n/a` on the first. The GT clock is the actual frequency (`rps_act_freq_mhz`, the requested one as fallback); throttle reasons come from `throttle_reason_*` |
| Device VRAM total | The size of the local-memory PCI window (`resource2`), an **estimate**: kernel-owned memory is missing from the sysfs view, resizable BAR rounds to a power of two, and a partial window can be smaller than the card, so the total can differ from the card's memory. A window under 1 GiB (an integrated GPU, or a discrete card without resizable BAR) shows `N/A` (`null` in JSON). Free memory is never shown for Intel |
-| Device VRAM used | The sum of its clients' resident local memory: i915 has no device-wide counter, so buffers shared between processes can be counted twice, and kernel-owned memory and processes gputaskman can't inspect are missing. The UI, `--once`, `--json` (`memory_note`) and `gputaskman diff` all say so. `n/a` when any client's local memory is unknown |
+| Device VRAM used | The sum of its clients' resident memory: i915 has no device-wide counter, so buffers shared between processes can be counted twice, and kernel-owned memory and processes gputaskman can't inspect are missing. Local memory on a discrete card, system memory on an integrated GPU. The UI, `--once`, `--json` (`memory_note`) and `gputaskman diff` all say so. `n/a` when any client's memory is unknown |
| Integrated or discrete | An iGPU has no `local0`, so a card with a local-memory window of 1 GiB or more is discrete, and so is any card whose fdinfo reports local memory, even when its window is smaller |
-| Per-process VRAM and SPILL | `drm-resident-local0` and `drm-resident-system0`, plus their `stolen-` regions (the firmware-reserved part of each), under the same private-client rules as AMD. `system0` is memory the GPU's buffers currently sit in, including buffers placed there on purpose, so SPILL here (like AMD's GTT) is where they are, not proof they were pushed out of VRAM. Both `drm-shared-local0` and `drm-shared-system0` must be present to charge a process, so an integrated GPU (no `local0`) shows `n/a` (`legacy`). A region value that can't be parsed makes that figure `n/a`, not a smaller number |
+| Per-process VRAM and SPILL | `drm-resident-local0` and `drm-resident-system0`, plus their `stolen-` regions (the firmware-reserved part of each), under the same private-client rules as AMD. On an integrated GPU there is no local memory: a provably private client's `system0` bytes are its GPU memory in the VRAM column, and SPILL stays `N/A` (system memory is its memory, not spill). On a discrete card `system0` is memory the GPU's buffers currently sit in, including buffers placed there on purpose, so SPILL there (like AMD's GTT) is where they are, not proof they were pushed out of VRAM. The shared gate needs only the regions the device has, so a discrete card with a missing `drm-shared-local0` still shows `n/a` (`legacy`), while an integrated client with shared buffers shows `n/a` (`shared_buffers`). A region value that can't be parsed makes that figure `n/a`, not a smaller number |
| Per-process engine load (3d, compute, copy, video) | `drm-engine-render`, `-compute`, `-copy`, `-video`, `-video-enhance` busy time, sampled twice. `n/a` where the driver reports none (before Gen 8). A class with several identical engines (`drm-engine-capacity-*`, such as video on an Arc) is not divided by its capacity, so one busy engine reads 100% |
Device GPU load, memory bandwidth, and the PCIe link are `n/a`: i915 has no device-wide busy counter, and its
-sysfs link fields can report the power-on default instead of the live link. The GT clock is read but not shown yet, and
-what is read (`rps_cur_freq_mhz`) is the frequency the driver last *requested*; the kernel's actual frequency is `rps_act_freq_mhz`.
+sysfs link fields can report the power-on default instead of the live link.
`xe` cards are detected, but its fdinfo uses other keys (`drm-cycles-*`, `drm-resident-vram0`/`-gtt`), so its
per-process rows show `n/a` until they are decoded on hardware.
@@ -264,6 +263,12 @@ per-process VRAM and engine load, and the TUI rendered both. The fdinfo formats
sources, are covered by unit tests. **Not validated on hardware:** `xe`, Arc cards without resizable BAR, and
multi-GPU systems other than that pair.
+Live check on an integrated GPU (ASUS Vivobook 14 X1404VA, Intel Core 3 100U Xe-LP, `i915`, kernel 7.3.1, Mesa 26.2.5):
+the card is found and named, the header shows the actual GT clock (`GT 300/1250 MHz`) with no throttle reasons active,
+and a headless `vkmark` run shows as a 3D/game Vulkan row at 82% GPU. Per-process memory stays `n/a`
+(`shared_buffers`): the compositor imports every window, so no client is provably private. The `gtt_resident_bytes`
+reference and the engine percentages are still measured.
+
**WSL** is different, because Windows owns the GPU. Linux cannot see how much VRAM its own
processes use: `nvidia-smi` lists no processes, NVML's per-process samples carry *Windows* PIDs
(never looked up in Linux's `/proc`), and Windows charges all Linux GPU memory to the VM worker
diff --git a/src/gputaskman/app.py b/src/gputaskman/app.py
index dcc2031..86157f9 100644
--- a/src/gputaskman/app.py
+++ b/src/gputaskman/app.py
@@ -93,11 +93,13 @@ first sample and for ROCm/HIP processes: their compute runs on `/dev/kfd` queues
process). VRAM and SPILL are charged to a process only when its DRM clients are provably private: one holder,
opened through a render node, and no shared buffers. Otherwise they show `n/a` and the bytes stay unattributed;
the inspector still shows the resident bytes it can reach (shared buffers included, so not added up). **Intel GPUs
-on Linux** (`i915`) take the same path: sysfs for the device, fdinfo for engine load and, on a discrete Arc, local-memory
-VRAM. An integrated GPU shows engine load only (VRAM `n/a`), `xe` cards are detected but their per-process fdinfo isn't
+on Linux** (`i915`) take the same path: sysfs for the device (actual GT clock, throttle reasons), fdinfo for engine load and, on a discrete Arc, local-memory
+VRAM. On an integrated GPU a provably private client's system memory is its GPU memory in the VRAM column (SPILL stays
+`N/A`: system memory is its memory there, not spill); shared clients show `n/a`, with the resident bytes still in the inspector.
+`xe` cards are detected but their per-process fdinfo isn't
decoded yet (rows show `n/a`). With no device-wide memory counter, an Intel card's VRAM used is a sum over the processes
-it can inspect (shared buffers can be counted twice; kernel-owned memory and uninspectable processes are missing), its total is
-the size of the card's local-memory PCI window (an estimate), and free memory is not shown. Only processes you can inspect are
+it can inspect (local memory on a discrete card, system memory on an integrated GPU; shared buffers can be counted twice; kernel-owned memory and uninspectable processes are missing), its total is
+the size of the card's local-memory PCI window (an estimate; unknown on an integrated GPU), and free memory is not shown. Only processes you can inspect are
listed, and the header says how many it couldn't; run with `sudo` to see other users'. Under **WSL**, Windows
charges all Linux GPU memory to the VM (`vmwp.exe`), so VRAM and load are device-wide only; rows
are Linux processes with `/dev/dxg` open and show `n/a` rather than a made-up share. When WSL
@@ -573,20 +575,23 @@ class GpuTaskManager(App):
rx = nv.pcie_rx_kbs / 1024 if nv.pcie_rx_kbs is not None else None
tx = nv.pcie_tx_kbs / 1024 if nv.pcie_tx_kbs is not None else None
pstate = f"P{nv.pstate}" if nv.pstate is not None else "P N/A"
+ is_amd = nv.source.startswith("AMD ")
+ is_intel = nv.source == "Intel sysfs"
m = Text()
- label = "AMD gfx" if nv.source.startswith("AMD ") else "GPU"
+ label = "AMD gfx" if is_amd else ("Intel GT" if is_intel else "GPU")
m.append(f"{label} {format_metric(nv.util_gpu, unit='%')}", style=f"bold {self.CHART_COLORS['GPU']}")
m.append(f" Mem activity {format_metric(nv.util_mem, unit='%')}", style=self.CHART_COLORS["Mem activity"])
m.append(f" PCIe↓{format_metric(rx, '.0f'):>5} ↑{format_metric(tx, '.0f'):>4} MB/s")
if nv.enc or nv.dec:
m.append(f" enc {format_metric(nv.enc, unit='%')} dec {format_metric(nv.dec, unit='%')}")
lines.append(m)
- clock_label = (f"gfx {format_metric(nv.gfx_clock)} MHz" if nv.source.startswith("AMD ") else
+ clock_label = (f"gfx {format_metric(nv.gfx_clock)} MHz" if is_amd else
+ f"GT {format_metric(nv.sm_clock)}/{format_metric(nv.sm_clock_max)} MHz" if is_intel else
f"SM {format_metric(nv.sm_clock)}/{format_metric(nv.sm_clock_max)} MHz")
power_kind = f" {nv.power_kind}" if nv.power_kind else ""
if self.monitoring:
- clock = nv.gfx_clock if nv.source.startswith("AMD ") else nv.sm_clock
- label = "gfx" if nv.source.startswith("AMD ") else "SM"
+ clock = nv.gfx_clock if is_amd else nv.sm_clock
+ label = "gfx" if is_amd else ("GT" if is_intel else "SM")
st = Text(f"{format_metric(nv.temp, unit='°C')} "
f"{format_metric(nv.power_w, '.0f')} W{power_kind} "
f"{label} {format_metric(clock)} MHz", style="grey70")
diff --git a/src/gputaskman/drm.py b/src/gputaskman/drm.py
index e1e03ec..298a266 100644
--- a/src/gputaskman/drm.py
+++ b/src/gputaskman/drm.py
@@ -157,6 +157,13 @@ def parse_fdinfo(text: str) -> dict | None:
# system0 includes buffers placed there on purpose, not only memory that spilled from local0.
# There is no separate CPU-only region. These are i915's names; xe calls them vram0/gtt/system, so
# its memory stays unknown until validated.
+ has_local = any("local0" in key for key in fields)
+ if fields["drm-driver"] == "i915" and not has_local:
+ # An integrated GPU has no local0 region at all, so there is no shared-local0 to require:
+ # the gate needs only the system0 region the device has. xe keeps the old gate (unknown keys).
+ required_shared = ("drm-shared-system0",)
+ else:
+ required_shared = ("drm-shared-local0", "drm-shared-system0")
return {
"driver": fields["drm-driver"],
"client_id": client_id,
@@ -164,7 +171,7 @@ def parse_fdinfo(text: str) -> dict | None:
# The shared-buffer gate needs every shared region present and parseable: any ambiguity keeps
# the gate closed (None) instead of risking shared buffers being charged as private.
"shared": (sum(shared_values) if shared_keys and None not in shared_values
- and all(k in fields for k in ("drm-shared-local0", "drm-shared-system0")) else None),
+ and all(k in fields for k in required_shared) else None),
"vram": intel_resident("drm-resident-local0", "drm-resident-stolen-local0"),
"gtt": intel_resident("drm-resident-system0", "drm-resident-stolen-system0"),
"cpu": None,
@@ -388,6 +395,29 @@ def _hwmon_clock(hwmon: str, label: str) -> int | None:
_PCIE_GEN = {2.5: 1, 5.0: 2, 8.0: 3, 16.0: 4, 32.0: 5, 64.0: 6}
+# Active i915/xe throttle reasons, in a fixed order: each throttle_reason_* sysfs node holds 1 while
+# that limit holds the GPU back, 0 otherwise. An unreadable or unparseable node is skipped (unknown,
+# not inactive), so a partial read never reports "no throttling".
+_INTEL_THROTTLE = (
+ ("throttle_reason_pl1", "PL1"),
+ ("throttle_reason_pl2", "PL2"),
+ ("throttle_reason_pl4", "PL4"),
+ ("throttle_reason_prochot", "PROCHOT"),
+ ("throttle_reason_ratl", "RATL"),
+ ("throttle_reason_thermal", "thermal"),
+ ("throttle_reason_vr_tdc", "VR-TDC"),
+ ("throttle_reason_vr_thermalert", "VR-therm"),
+)
+
+
+def _intel_throttle(gt: str) -> list[str]:
+ """Names of the limits currently throttling an Intel GPU; empty when none is (or none is readable).
+
+ _int already turns an unreadable or unparseable node into None, so those are skipped: unknown,
+ not inactive."""
+ return [label for node, label in _INTEL_THROTTLE if _int(os.path.join(gt, node))]
+
+
def read_device(card: DrmCard, index: int) -> DeviceTelemetry:
"""NVIDIA-shaped device metrics for one AMD or Intel card, read from sysfs."""
d = card.sysfs
@@ -432,12 +462,17 @@ def read_device(card: DrmCard, index: int) -> DeviceTelemetry:
if card.intel:
# The gt nodes hang off the DRM card itself (/sys/class/drm/cardN/gt/gt0), not the PCI device.
gt = os.path.join(os.path.dirname(d), "gt", "gt0")
+ act = _int(os.path.join(gt, "rps_act_freq_mhz"))
cur = _int(os.path.join(gt, "rps_cur_freq_mhz"))
+ # rps_act_freq_mhz is the actual frequency; rps_cur_freq_mhz is what the driver last requested
+ # (per the kernel's intel_gt_sysfs_pm.c). The actual one can read 0 while the GPU idles in RC6,
+ # which is a real reading, not a missing one; fall back to the requested one on kernels without it.
+ dev.sm_clock = act if act is not None else cur
if cur is not None:
- # rps_cur_freq_mhz is the frequency the driver last requested (rps_act_freq_mhz is the actual one,
- # per the kernel's intel_gt_sysfs_pm.c); hwmon has no sclk on Intel. Not displayed yet.
+ # hwmon has no sclk on Intel; keep the requested frequency too, for the JSON.
dev.gfx_clock = cur
dev.sm_clock_max = _int(os.path.join(gt, "rps_RP0_freq_mhz"))
+ dev.throttle = _intel_throttle(gt)
# sysfs current_link_* on i915/xe can report the power-on default instead of the live link
# (2.5 GT/s x1 shown while a measured DMA transfer ran at ~19 GB/s), so both stay unset:
# unknown beats a confidently wrong number.
@@ -577,19 +612,24 @@ class DrmCounters:
return out
def _stamp_intel_memory(self, clients: dict[tuple, list]) -> None:
- """Intel cards expose no device-wide memory sysfs: used local memory is the sum of the card's
- clients' resident local bytes, counted once per client even when several processes share it
+ """Intel cards expose no device-wide memory sysfs: used memory is the sum of the card's
+ clients' resident bytes, counted once per client even when several processes share it
(buffers shared between clients can double-count, and clients that can't be inspected are missing;
report.INTEL_MEMORY_NOTE says so). With no readable client the sum is None -- unknown, not 0."""
for card in self.cards:
if not card.intel:
continue
- used = [c[1]["vram"] for _key, c in clients.items() if c[1]["pdev"] == card.pdev]
- card.vram_used = sum(used) if used and None not in used else None
- if any(v is not None for v in used):
+ local = [c[1]["vram"] for _key, c in clients.items() if c[1]["pdev"] == card.pdev]
+ card.vram_used = sum(local) if local and None not in local else None
+ if any(v is not None for v in local):
# A client reports local memory, so the card has some: discrete, whatever its BAR window says
# (a card without resizable BAR has a small window and no known total).
card.integrated = False
+ elif card.integrated:
+ # No local memory on an integrated GPU: its memory is the system memory its clients sit in.
+ # Sum that instead, with the same double-count caveat (an over-estimate, never a device reading).
+ gtt = [c[1]["gtt"] for _key, c in clients.items() if c[1]["pdev"] == card.pdev]
+ card.vram_used = sum(gtt) if gtt and None not in gtt else None
def _start_time(self, pid: int) -> str | None:
"""Field 22 of /proc/<pid>/stat: tells a reused pid from the process cached under it."""
@@ -723,6 +763,7 @@ class DrmCounters:
def sample(self) -> tuple[dict[int, dict[int, ProcGpu]], dict[int, AdapterGpu]]:
by_pdev = {c.pdev: c.key for c in self.cards}
+ by_key = {c.key: c for c in self.cards}
unified = {c.pdev for c in self.cards if c.unified_video}
intel_pdevs = {c.pdev for c in self.cards if c.intel}
procs: dict[int, dict[int, ProcGpu]] = {c.key: {} for c in self.cards}
@@ -757,6 +798,12 @@ class DrmCounters:
infos = [c[1] for _k, c in held]
vram = [i["vram"] for i in infos]
gtt = [i["gtt"] for i in infos]
+ # An integrated Intel GPU has no local memory: system0 is its memory, not spill and not
+ # dedicated VRAM, so there is no shared (spill) counter for it. The bytes it holds are charged
+ # as the process's GPU memory in the VRAM column when provably private (below).
+ integrated_intel = by_key[key].intel and by_key[key].integrated
+ if integrated_intel:
+ proc.available.discard("shared")
# Every buffer this process can reach, shared ones included: a reference, never summed (rule 1).
complete = pid not in incomplete # otherwise any sum would be a partial total that looks whole
proc.resident_vram = float(sum(vram)) if complete and None not in vram else None
@@ -776,7 +823,8 @@ class DrmCounters:
reason = REASON_SHARED_BUFFERS
elif not all(c[2] for _k, c in held):
reason = REASON_PRIMARY
- elif proc.resident_vram is None or proc.resident_gtt is None:
+ elif proc.resident_gtt is None or (proc.resident_vram is None and not integrated_intel):
+ # No local memory on an integrated GPU, so only the system figure has to be known.
reason = REASON_LEGACY
elif self.partial:
reason = REASON_PARTIAL_SCAN
@@ -784,6 +832,8 @@ class DrmCounters:
if reason:
proc.attributed = False
proc.available -= {"dedicated", "shared"}
+ elif integrated_intel:
+ proc.dedicated = proc.resident_gtt
else:
proc.dedicated = proc.resident_vram
proc.shared = proc.resident_gtt
diff --git a/src/gputaskman/report.py b/src/gputaskman/report.py
index 5bb75ce..b2f67c1 100644
--- a/src/gputaskman/report.py
+++ b/src/gputaskman/report.py
@@ -89,11 +89,12 @@ def inferred_note(g) -> str:
METAL_NOTE = ("macOS: unified memory, so GPU memory is part of system RAM. Rows show each process's graphics "
"footprint; other users' processes (WindowServer, daemons) show GPU% only, since reading their "
"memory needs root.")
-INTEL_MEMORY_NOTE = ("Intel VRAM used is the sum of local memory resident in the processes gputaskman can inspect "
- "(the driver has no device-wide counter): buffers shared between processes can be counted "
- "twice, and kernel-owned memory and processes it can't inspect are missing. The total is the "
- "size of the card's local-memory PCI window, an estimate that can differ from its memory, so "
- "free memory is not shown.")
+INTEL_MEMORY_NOTE = ("Intel VRAM used is the sum of memory resident in the processes gputaskman can inspect "
+ "(the driver has no device-wide counter): local memory on a discrete card, system memory on "
+ "an integrated GPU. Buffers shared between processes can be counted twice, and kernel-owned "
+ "memory and processes it can't inspect are missing. The total is the size of the card's "
+ "local-memory PCI window, an estimate that can differ from its memory (0 on an integrated "
+ "GPU, whose total is unknown), so free memory is not shown.")
def intel_memory_note(s: Snapshot) -> str:
@@ -198,8 +199,10 @@ def to_text(s: Snapshot, limit: int = 30) -> str:
rx = nv.pcie_rx_kbs / 1024 if nv.pcie_rx_kbs is not None else None
tx = nv.pcie_tx_kbs / 1024 if nv.pcie_tx_kbs is not None else None
pstate = f"P{nv.pstate}" if nv.pstate is not None else "P N/A"
- label = "AMD gfx" if nv.source.startswith("AMD ") else "GPU"
+ is_intel = nv.source == "Intel sysfs"
+ label = "AMD gfx" if nv.source.startswith("AMD ") else ("Intel GT" if is_intel else "GPU")
clock = (f"gfx {format_metric(nv.gfx_clock)}" if nv.source.startswith("AMD ") else
+ f"GT {format_metric(nv.sm_clock)}" if is_intel else
f"SM {format_metric(nv.sm_clock)}")
power_kind = f" ({nv.power_kind})" if nv.power_kind else ""
out.append(f"{label} {format_metric(nv.util_gpu, unit='%')} mem-bandwidth {format_metric(nv.util_mem, unit='%')} "
diff --git a/tests/test_drm.py b/tests/test_drm.py
index 9086362..54dfab0 100644
--- a/tests/test_drm.py
+++ b/tests/test_drm.py
@@ -10,6 +10,7 @@ from gputaskman import drm
GiB = 1 << 30
MiB = 1 << 20
+KiB = 1 << 10
FDINFO = """pos:\t0
flags:\t02100002
@@ -101,6 +102,31 @@ drm-engine-video:\t300000000 ns
drm-engine-video-enhance:\t0 ns
"""
+# The Vivobook's vkmark client (Xe-LP iGPU, i915) under load: resident system memory, part of it
+# shared with the compositor, so the bytes are measurable but not attributable to the process.
+I915_IGPU_SHARED_FDINFO = """pos:\t0
+flags:\t02100002
+mnt_id:\t41
+ino:\t427
+drm-driver:\ti915
+drm-client-id:\t54
+drm-pdev:\t0000:00:02.0
+drm-total-system0:\t37476 KiB
+drm-shared-system0:\t8576 KiB
+drm-active-system0:\t0
+drm-resident-system0:\t37476 KiB
+drm-purgeable-system0:\t156 KiB
+drm-total-stolen-system0:\t0
+drm-shared-stolen-system0:\t0
+drm-active-stolen-system0:\t0
+drm-resident-stolen-system0:\t0
+drm-purgeable-stolen-system0:\t0
+drm-engine-render:\t8242337792 ns
+drm-engine-copy:\t0 ns
+drm-engine-video:\t0 ns
+drm-engine-video-enhance:\t0 ns
+"""
+
# i915 before Gen8 prints the memory stats but no drm-engine lines at all.
I915_GEN7_FDINFO = """drm-driver:\ti915
drm-pdev:\t0000:00:02.0
@@ -421,6 +447,57 @@ class ReadDeviceTests(unittest.TestCase):
self.assertIsNone(d.enc)
self.assertIsNone(d.dec)
+ def test_read_device_intel_clock_and_throttle(self):
+ with tempfile.TemporaryDirectory() as tmp:
+ card_sysfs = Path(tmp) / "card1"
+ dev = card_sysfs / "device"
+ dev.mkdir(parents=True)
+ gt = card_sysfs / "gt" / "gt0"
+ gt.mkdir(parents=True)
+ (gt / "rps_act_freq_mhz").write_text("300\n")
+ (gt / "rps_cur_freq_mhz").write_text("350\n")
+ (gt / "rps_RP0_freq_mhz").write_text("1250\n")
+ (gt / "throttle_reason_status").write_text("1\n")
+ (gt / "throttle_reason_pl1").write_text("1\n")
+ (gt / "throttle_reason_pl2").write_text("0\n")
+ (gt / "throttle_reason_thermal").write_text("0\n")
+
+ card = drm.DrmCard(key=32, pdev="0000:00:02.0", sysfs=str(dev), driver="i915",
+ vendor_id=0x8086, device_id=0xA7AD, name="Intel Intel Graphics",
+ vram_total=0, integrated=True, intel=True)
+ d = drm.read_device(card, 0)
+
+ self.assertEqual(d.sm_clock, 300) # the actual frequency, not the requested one
+ self.assertEqual(d.gfx_clock, 350)
+ self.assertEqual(d.sm_clock_max, 1250)
+ self.assertEqual(d.throttle, ["PL1"])
+ self.assertEqual(d.source, "Intel sysfs")
+
+ def test_read_device_intel_clock_falls_back_to_requested(self):
+ with tempfile.TemporaryDirectory() as tmp:
+ card_sysfs = Path(tmp) / "card1"
+ dev = card_sysfs / "device"
+ dev.mkdir(parents=True)
+ gt = card_sysfs / "gt" / "gt0"
+ gt.mkdir(parents=True)
+ (gt / "rps_cur_freq_mhz").write_text("300\n")
+ (gt / "rps_RP0_freq_mhz").write_text("1250\n")
+
+ card = drm.DrmCard(key=32, pdev="0000:00:02.0", sysfs=str(dev), driver="i915",
+ vendor_id=0x8086, device_id=0xA7AD, name="Intel Intel Graphics",
+ vram_total=0, integrated=True, intel=True)
+ d = drm.read_device(card, 0)
+
+ self.assertEqual(d.sm_clock, 300)
+ self.assertEqual(d.throttle, [])
+
+ def test_intel_throttle_skips_unreadable_nodes(self):
+ with tempfile.TemporaryDirectory() as tmp:
+ gt = Path(tmp)
+ (gt / "throttle_reason_pl2").write_text("1\n")
+ (gt / "throttle_reason_thermal").write_text("lots\n") # unparseable: unknown, not active
+ self.assertEqual(drm._intel_throttle(str(gt)), ["PL2"])
+
class DrmCountersTests(unittest.TestCase):
def test_drm_counters(self):
@@ -1059,9 +1136,24 @@ class IntelFdinfoTests(unittest.TestCase):
info = drm.parse_fdinfo(I915_IGPU_FDINFO)
self.assertIsNone(info["vram"]) # no local0 on an integrated GPU: unknown, not 0
self.assertEqual(info["gtt"], 60 * MiB) # system0 plus an empty stolen-system0
- self.assertIsNone(info["shared"]) # no drm-shared-local0, so the shared-buffer gate stays closed
+ self.assertEqual(info["shared"], 0) # no local0 to require: the gate needs only system0, empty here
self.assertEqual(set(info["engines"]), {"render", "copy", "video", "video-enhance"})
+ def test_i915_integrated_client_with_shared_buffers(self):
+ # The Vivobook's vkmark client under load: resident system memory, some of it shared
+ # (the compositor imports the window), so the bytes stay unattributed but measurable.
+ info = drm.parse_fdinfo(I915_IGPU_SHARED_FDINFO)
+ self.assertIsNone(info["vram"])
+ self.assertEqual(info["gtt"], 37476 * KiB)
+ self.assertEqual(info["shared"], 8576 * KiB)
+
+ def test_i915_discrete_client_missing_shared_local0_stays_legacy(self):
+ # A discrete card prints local0 regions, so a missing drm-shared-local0 is a kernel gap,
+ # not an integrated GPU: the gate stays closed.
+ text = "\n".join(line for line in I915_FDINFO.splitlines() if "drm-shared-local0" not in line)
+ self.assertIn("drm-resident-local0", text)
+ self.assertIsNone(drm.parse_fdinfo(text)["shared"])
+
def test_i915_without_engine_lines_has_unknown_load(self):
info = drm.parse_fdinfo(I915_GEN7_FDINFO)
self.assertIsNone(info["engines"]) # unknown, not an empty (zero) load
@@ -1214,7 +1306,8 @@ class IntelScanTests(unittest.TestCase):
self.assertIn("dedicated", g.available) # and that has no bearing on the memory
self.assertEqual(g.dedicated, 64 * MiB)
- def test_integrated_gpu_load_is_measured_while_its_vram_is_n_a(self):
+ def test_integrated_gpu_charges_private_system_memory(self):
+ # An integrated GPU has no local memory: a private client's system0 bytes are its GPU memory.
pdev = "0000:00:02.0"
with tempfile.TemporaryDirectory() as tmp:
proc = Path(tmp) / "proc"
@@ -1230,11 +1323,30 @@ class IntelScanTests(unittest.TestCase):
_write_fd(proc, 100, 5, I915_IGPU_FDINFO.replace("render:\t1200000000", "render:\t1700000000"))
procs, adapters = counters.sample()
g = procs[card.key][100]
- self.assertEqual(g.drm_reason, drm.REASON_LEGACY) # shared buffers can't be ruled out
- self.assertNotIn("dedicated", g.available)
+ self.assertEqual((g.drm_reason, g.dedicated), ("", 60 * MiB))
+ self.assertNotIn("shared", g.available) # system0 is memory here, not spill
self.assertIn("engine", g.available)
self.assertEqual(g.engines["3d"], 50.0)
- self.assertIsNone(adapters[card.key].dedicated)
+ self.assertEqual(adapters[card.key].dedicated, 60 * MiB) # the stamped device total
+
+ def test_integrated_gpu_with_shared_buffers_stays_unattributed(self):
+ # The shared case from the Vivobook: measurable and referenced, but charged to nobody.
+ pdev = "0000:00:02.0"
+ with tempfile.TemporaryDirectory() as tmp:
+ proc = Path(tmp) / "proc"
+ proc.mkdir()
+ card = drm.DrmCard(key=drm.pci_key(pdev), pdev=pdev, sysfs=str(Path(tmp) / "card0" / "device"),
+ driver="i915", vendor_id=0x8086, device_id=0xA782, name="Intel UHD Graphics",
+ vram_total=0, integrated=True, intel=True)
+ counters = drm.DrmCounters(found=[card], proc=str(proc), clock=Clock())
+ _write_fd(proc, 100, 5, I915_IGPU_SHARED_FDINFO)
+ procs, adapters = counters.sample()
+ g = procs[card.key][100]
+ self.assertEqual(g.drm_reason, drm.REASON_SHARED_BUFFERS)
+ self.assertNotIn("dedicated", g.available)
+ self.assertEqual(g.resident_gtt, 37476 * KiB) # still shown as a reference
+ # The stamped device total sums resident system memory (shared buffers can double-count it).
+ self.assertEqual(adapters[card.key].dedicated, 37476 * KiB)
def test_device_used_sums_each_client_once_and_is_unknown_when_incomplete(self):
with tempfile.TemporaryDirectory() as tmp: