Skip to content

Commit 2010776

Browse files
committed
tools/rcu: Add an extract-stall script
This commit adds a script that extracts RCU CPU stall warnings from console output. The user can optionally specify the number of lines preceding the stall to output, and also the number of lines of stall-warning text. Signed-off-by: Paul E. McKenney <[email protected]>
1 parent b380b10 commit 2010776

File tree

1 file changed

+34
-0
lines changed

1 file changed

+34
-0
lines changed

tools/rcu/extract-stall.sh

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
#!/bin/sh
2+
# SPDX-License-Identifier: GPL-2.0+
3+
#
4+
# Extract any RCU CPU stall warnings present in specified file.
5+
# Filter out clocksource lines. Note that preceding-lines excludes the
6+
# initial line of the stall warning but trailing-lines includes it.
7+
#
8+
# Usage: extract-stall.sh dmesg-file [ preceding-lines [ trailing-lines ] ]
9+
10+
echo $1
11+
preceding_lines="${2-3}"
12+
trailing_lines="${3-10}"
13+
14+
awk -v preceding_lines="$preceding_lines" -v trailing_lines="$trailing_lines" '
15+
suffix <= 0 {
16+
for (i = preceding_lines; i > 0; i--)
17+
last[i] = last[i - 1];
18+
last[0] = $0;
19+
}
20+
21+
suffix > 0 {
22+
print $0;
23+
suffix--;
24+
if (suffix <= 0)
25+
print "";
26+
}
27+
28+
suffix <= 0 && /detected stall/ {
29+
for (i = preceding_lines; i >= 0; i--)
30+
if (last[i] != "")
31+
print last[i];
32+
suffix = trailing_lines;
33+
}' < "$1" | tr -d '\015' | grep -v clocksource
34+

0 commit comments

Comments
 (0)