-
Notifications
You must be signed in to change notification settings - Fork 0
/
start_collection.sh
executable file
·128 lines (111 loc) · 2.98 KB
/
start_collection.sh
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
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
#!/usr/bin/env bash
# SPDX-License-Identifier: GPL-3.0+
# Copyright (c) 2024 John Meneghini <[email protected]> All rights reserved.
# this assumes collect_inflight-data.sh is in the same directory
DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
display_help() {
echo ""
echo " usage: $0 <\"iopolicy1,iopolicy2,...\"> <filename> <namespace> <count>"
echo ""
echo " <\"iopolicy1,iopolicy2,...\"> string iopolicy to use"
echo " <filename> filename prefix to use - passed to collect_inflight_data.sh"
echo " <namepace> nvme device name to test"
echo " <count> nvme device name to test"
echo ""
echo " Valid iopolicy input:"
echo " \"numa\""
echo " \"round-robin\""
echo " \"queue-depth\""
echo " \"latency\""
echo ""
echo " e.g.: $0 \"round-robin,queue-depth,numa\" ARRAY1 nvme12n2 600"
echo " e.g.: $0 \"round-robin,numa\" ARRAY2 nvme2n1 800"
echo ""
}
set_iopolicy() {
old_policy="$(cat /sys/class/nvme-subsystem/nvme-subsys${subsys_num}/iopolicy)"
echo "nvme-subsys${subsys_num}/iopolicy is ${old_policy}"
if [ "${old_policy}" != "$1" ]; then
echo "setting iopolicy for nvme-subsys${subsys_num} to $1 "
echo "$1" > /sys/class/nvme-subsystem/nvme-subsys${subsys_num}/iopolicy
sleep 5
fi
}
continue_step() {
echo ""
echo -n "Type any key to continue, e to exit: "
read line
case "$line" in
e|E) echo ""
exit 1
;;
*) echo ""
return 1
;;
esac
}
if [ $# -lt 4 -o $# -gt 4 ]; then
echo ""
echo "usage: $0 <\"iopolicy1,iopolicy2,...\"> <filename> <namespace> <count>"
echo " e.g.: $0 \"round-robin,queue-depth,numa\" ARRAY1 nvme12n2 800"
echo ""
exit 1
fi
inputlist="$1"
output="$2"
disk="$3"
count="$4"
if ! [ -b /dev/${disk} ]; then
echo "/dev/${disk} File does not exist!"
exit 1
fi
ctrl=$(echo "${disk}" | sed 's/n[0-9]*$//')
ns=$(echo "${disk}" | sed 's/^nvme[0-9]*//')
subsys_num=$(echo "${ctrl}" | sed 's/^nvme//')
j=1
IFS=',' read -ra ADDR <<< "${inputlist}"
for policy in "${ADDR[@]}"; do
(( j++))
case "$policy" in
"numa")
;;
"round-robin")
;;
"queue-depth")
;;
"latency")
;;
*)
echo "Error: \"$policy\" is invalid."
display_help >&2
exit 1
;;
esac
done
((jcount = j * count))
echo ""
set_iopolicy "${ADDR[0]}"
continue_step
sleep 1
echo ""
echo " Be sure to start fio in a separate shell with start_fio.sh"
echo ""
echo " \"start_fio.sh <disk> <test> <block_size> <runtime> <numjobs> <iodepth>\""
echo ""
echo " e.g: \"$DIR/start_fio.sh $disk randread 4k $jcount 40 64\""
echo ""
echo " Monitor progress with iostat"
echo ""
echo " \"iostat -x ID \$(cat /proc/diskstats | fgrep $ctrl | fgrep $ns | awk '{print \$3}' | sort -r) 4\""
continue_step
sleep 1
mkdir -p logs
for policy in "${ADDR[@]}"; do
dmesg -C
sleep 2
set_iopolicy "${policy}"
echo ""
$DIR/collect_inflight-data.sh ${output}-${policy} $disk $count
sleep 10
dmesg >> logs/${output}-${policy}-dmesg.log
done