diff options
Diffstat (limited to 'tools/guest-diag/watch_ctx.sh')
| -rw-r--r-- | tools/guest-diag/watch_ctx.sh | 49 |
1 files changed, 49 insertions, 0 deletions
diff --git a/tools/guest-diag/watch_ctx.sh b/tools/guest-diag/watch_ctx.sh new file mode 100644 index 0000000..0968571 --- /dev/null +++ b/tools/guest-diag/watch_ctx.sh @@ -0,0 +1,49 @@ +#!/bin/sh +# watch_ctx.sh - guest-side watcher: (re)start cdt, snapshot the ioctl stream +# (fd paths), attach gdb to the libcuda wait as soon as cuCtxCreate is reached +# and POKE the per-entry trackers (p+0x9410+0x10/0x18 = 1) to test whether that +# gate releases the wait. Runs under sudo; results land in /tmp/ctxdumps/. +mkdir -p /tmp/ctxdumps +rm -f /tmp/ctxdumps/* +nvidia-modprobe -c 0 +nvidia-modprobe -u +modprobe nvidia-uvm +rm -f /tmp/cdt.out +setsid /tmp/cdt > /tmp/cdt.out 2>&1 & +i=0 +while [ $i -lt 300 ]; do + grep -q 'cuCtxCreate' /tmp/cdt.out 2>/dev/null && break + sleep 0.3 + i=$((i+1)) +done +P=$(pidof cdt | tr ' ' '\n' | head -1) +ls -l /proc/$P/fd/ > /tmp/ctxdumps/fds.txt 2>&1 +if command -v strace >/dev/null 2>&1; then + timeout 8 strace -f -y -p "$P" -e trace=ioctl -o /tmp/ctxdumps/ioctl.txt 2>/dev/null +fi +n=0 +while [ $n -lt 80 ]; do + P=$(pidof cdt | tr ' ' '\n' | head -1) + [ -n "$P" ] || break + gdb -p "$P" -batch -x /tmp/dumpctx.py > "/tmp/ctxdumps/d$n.txt" 2>&1 + if grep -q DONE_SPIN "/tmp/ctxdumps/d$n.txt"; then + cp "/tmp/ctxdumps/d$n.txt" /tmp/ctxdumps/FOUND.txt + break + fi + n=$((n+1)) + sleep 0.5 +done +P=$(pidof cdt | tr ' ' '\n' | head -1) +if [ -f /tmp/ctxdumps/FOUND.txt ] && [ -n "$P" ]; then + CTX_POKE=1 gdb -p "$P" -batch -x /tmp/dumpctx.py > /tmp/ctxdumps/poke_run.txt 2>&1 + k=0 + while [ $k -lt 12 ]; do + echo "--- t=$((k*3))s $(tail -1 /tmp/cdt.out)" >> /tmp/ctxdumps/result.txt + k=$((k+1)) + sleep 3 + done + VAS=$(grep -oE 'type=1 p=0x[0-9a-f]+' /tmp/ctxdumps/FOUND.txt | sed 's/.*p=0x//' | while read -r p; do printf '0x%x ' $((0x$p + 0x9410)); done) + echo "PID=$P TRACKER_VAS $VAS" > /tmp/ctxdumps/probe.txt + python3 /tmp/pmap.py "$P" $VAS >> /tmp/ctxdumps/probe.txt 2>&1 +fi +echo WATCH_DONE >> /tmp/ctxdumps/WATCH.log |
