summaryrefslogtreecommitdiffstats
path: root/tools/guest-diag/nmi_catch.sh
blob: af46a23432d465376ed28e1bca617b35cc68c174 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
#!/bin/sh
# SPDX-License-Identifier: BSD-3-Clause
# Copyright (c) 2026 Open-IOV contributors
# nmi_catch.sh [rounds] [sleep] - trigger sysrq-l NMI backtraces and append a
# compact summary of the nvidia frames seen in each round (guest side, root).
#
# The guest RM's expiring waits are kernel busy-polls (their internals are
# `notrace`, so ftrace/kprobes cannot see them). sysrq-l prints each CPU's
# current kernel stack, and this script keeps only the lines that carry an
# `[nvidia]` frame plus the owning `Comm:` line, so the wait/teardown stack
# survives even when the dmesg ring wraps.
#
# Run: sudo sh nmi_catch.sh 42 6 &        (42 rounds every 6 s)
# Read: /tmp/nmi2.log   (sorted unique Comm/nvidia-frame lines)
rm -f /tmp/nmi2.raw
i=0
R=${1:-40}
S=${2:-6}
echo 1 > /proc/sys/kernel/sysrq
while [ $i -lt "$R" ]; do
    echo l > /proc/sysrq-trigger
    sleep "$S"
    dmesg | grep -aB20 '\[nvidia\]' | grep -aE 'Comm: |\[nvidia\]' >> /tmp/nmi2.raw 2>/dev/null
    i=$((i+1))
done
sort -u /tmp/nmi2.raw > /tmp/nmi2.log 2>/dev/null
echo DONE >> /tmp/nmi2.log
wc -l /tmp/nmi2.log