Commit Graph
4 Commits
Author SHA1 Message Date
Anees Iqbal 849f7250d9 kernel-holds-gpuvm.bt: probe only the DRM core, key probe counts by probe name, read arg0 before the loop
Three fixes the Asahi run needed, folded into the committed copy:

- The asahi driver's Rust functions (its GEM close callback and its gpuvm
  step_map/step_unmap callbacks) are not in available_filter_functions, so
  their kprobes failed to attach. They are gone, with their three table
  columns; the kernel stacks of the unlinks and puts show those callbacks.
- @n[func] keyed the map by a ksym in kprobe context while the other keys
  are strings; it is @n[probe] now.
- drm_gpuvm_fini read arg0 inside the for-loop over @vbvm, which bpftrace
  rejects; it copies arg0 to $vm first.

Verified: the Asahi session ran the same three fixes as a local copy
(round 3, 19 probes attached, tables and stacks printed). This file is that
copy with the dropped columns removed instead of held at zero; this exact
file has not run yet.
2026-11-11 07:58:49 -08:00
Anees Iqbal 10cd3579b6 kernel-holds-gpuvm.bt: count whether a dma-buf's second import is in the same DRM file as its first 2026-11-11 07:58:49 -08:00
Anees Iqbal ad36ede027 scripts/dma-buf-leak: a per-object trace of the GPU VM bookkeeping, and a properties-query knob in repro.c
kernel-holds-gpuvm.bt follows each GEM object imported from a dma-buf named
m2vleak* and counts its import order among its dma-buf's imports, its vm_bos
created, put, put deferred, moved to the deferred list and destroyed, its
VAs linked and unlinked, the driver's map and unmap steps, its GEM closes and
its reference count at the last handle close; it prints one table for the
objects released and one for those still alive at exit, the kernel stacks of
deferred puts, deferred cleanups and VA unlinks, and the probe's vm_bos still
alive at each VM's teardown.

repro.c -p: 1 queries vkGetMemoryFdPropertiesKHR on each dma-buf before the
import (as the spec requires); 0 skips it (a diagnostic, breaking
VUID-VkMemoryAllocateInfo-memoryTypeIndex-00648); 2 makes the query alone.
The kept dma-bufs on the measured driver each had two GEM imports, which the
query may account for.
2026-11-11 07:58:49 -08:00
Anees Iqbal aa7d8ca855 scripts/dma-buf-leak: a C reproducer of kept dma-buf imports, and a bpftrace script of which layer keeps them
repro.c: plain Vulkan (VK_EXT_external_memory_dma_buf) imports of named
udmabufs of a memfd, from several threads, each keeping a window of imports
alive; every round counts the kernel's bufinfo entries of its name left after
every import was freed. Options add GPU copies, a busy queue, device
addresses and a lock around imports and frees. It needs only a C compiler and
libvulkan.so.1 (it uses the Vulkan headers where present, else declares the
few types it calls).

kernel-holds.bt: follows the dma-bufs named m2vleak* through the generic
PRIME and dma-buf paths (attach, map, PRIME import, handle add and remove,
GEM handle release, unmap, detach, GEM release, PRIME destroy, udmabuf
release) and prints, for those still alive at exit, which steps they went
through, attachments left, the GEM object's references at its handle's
close, and PRIME cache handles left.
2026-11-11 07:58:49 -08:00