summaryrefslogtreecommitdiffstats
path: root/tools/guest-diag/guest_pmap_all.py
diff options
context:
space:
mode:
authorArthur Hanson Rasmusson <arthur@vgpu.io>2026-09-24 10:48:08 -0400
committerArthur Hanson Rasmusson <arthur@vgpu.io>2026-09-24 10:48:08 -0400
commit13c07f7585c71bb75870d2a25475b4c9401a57fc (patch)
treea2a2f21c1952927d64b56e62948a2ef52d8a2f7c /tools/guest-diag/guest_pmap_all.py
parentcc2c2ab40af45e3a14e93b87e4988909303f8a95 (diff)
downloadopen-iov-13c07f7585c71bb75870d2a25475b4c9401a57fc.tar.gz
open-iov-13c07f7585c71bb75870d2a25475b4c9401a57fc.zip
kernel: enlarge the pin table and its probe window; tools: bridge client mappings into the service
The pin table became the primary VA->PA store once push-buffer regions and bridged client mappings started adding thousands of pages per boot; at 8192 slots with an 8-probe window, inserts were silently dropped and lookups missed at half load. 32768 slots and a 32-probe window keep the mapped set intact. tools/guest-diag/{guest_pmap_all.py,bridge_sems.sh} translate the CUDA client's /dev/nvidia* mappings through the guest's own pagemap and inject each present page into the service as a sysmem pin. With the client's semaphore pages pinned the service applies their releases into the page the client polls (verified: applied 67 -> 109, misses stop growing for those VAs), where before every write went to the vidmem shadow.
Diffstat (limited to 'tools/guest-diag/guest_pmap_all.py')
-rw-r--r--tools/guest-diag/guest_pmap_all.py38
1 files changed, 38 insertions, 0 deletions
diff --git a/tools/guest-diag/guest_pmap_all.py b/tools/guest-diag/guest_pmap_all.py
new file mode 100644
index 0000000..1a4df34
--- /dev/null
+++ b/tools/guest-diag/guest_pmap_all.py
@@ -0,0 +1,38 @@
+#!/usr/bin/env python3
+# guest-side helper: dump present pages of the target's /dev/nvidia* mappings
+# as "va,pa" lines (root in the guest), starting at or above va-min and
+# stopping after max-pairs lines so the guest agent's output stays small.
+# Usage: sudo python3 guest_pmap_all.py <pid> [va-min-hex] [max-pairs]
+import os
+import sys
+
+pid = int(sys.argv[1])
+va_min = int(sys.argv[2], 16) if len(sys.argv) > 2 else 0
+maxp = int(sys.argv[3]) if len(sys.argv) > 3 else 300
+
+regions = []
+with open('/proc/%d/maps' % pid) as f:
+ for line in f:
+ parts = line.split()
+ a, b = parts[0].split('-')
+ lo, hi = int(a, 16), int(b, 16)
+ path = parts[5] if len(parts) >= 6 else ''
+ if 'nvidia' in path:
+ regions.append((max(lo, va_min), hi))
+
+fd = os.open('/proc/%d/pagemap' % pid, os.O_RDONLY)
+n = 0
+try:
+ for lo, hi in regions:
+ for va in range(lo, hi, 0x1000):
+ os.lseek(fd, (va // 4096) * 8, 0)
+ e = int.from_bytes(os.read(fd, 8), 'little')
+ if not ((e >> 63) & 1):
+ continue
+ pfn = e & ((1 << 55) - 1)
+ print('0x%x,0x%x' % (va, (pfn << 12)))
+ n += 1
+ if n >= maxp:
+ raise SystemExit
+finally:
+ os.close(fd) \ No newline at end of file