blob: 773f93c7cbffc80bd235e37d0d7c5369809552dd (
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
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
|
#! /bin/bash
# SPDX-License-Identifier: GPL-2.0
# Copyright (c) 2021 Oracle, Inc. All Rights Reserved.
#
# FS QA Test No. 650
#
# Run an all-writes fsstress run with multiple threads while exercising CPU
# hotplugging to shake out bugs in the write path.
#
. ./common/preamble
_begin_fstest auto rw stress soak
# Override the default cleanup function.
_cleanup()
{
cd /
rm -f $tmp.*
$KILLALL_PROG -9 fsstress > /dev/null 2>&1
wait # for exercise_cpu_hotplug subprocess
for i in "$sysfs_cpu_dir/"cpu*/online; do
echo 1 > "$i" 2>/dev/null
done
test -n "$stress_dir" && rm -r -f "$stress_dir"
}
exercise_cpu_hotplug()
{
while [ -e $sentinel_file ]; do
local idx=$(( RANDOM % nr_hotplug_cpus ))
local cpu="${hotplug_cpus[idx]}"
local action=$(( RANDOM % 2 ))
echo "$action" > "$sysfs_cpu_dir/cpu$cpu/online" 2>/dev/null
sleep 0.5
done
}
_supported_fs generic
_require_test
_require_command "$KILLALL_PROG" "killall"
sysfs_cpu_dir="/sys/devices/system/cpu"
# Figure out which CPU(s) support hotplug.
nrcpus=$(getconf _NPROCESSORS_CONF)
hotplug_cpus=()
for ((i = 0; i < nrcpus; i++ )); do
test -e "$sysfs_cpu_dir/cpu$i/online" && hotplug_cpus+=("$i")
done
nr_hotplug_cpus="${#hotplug_cpus[@]}"
test "$nr_hotplug_cpus" -gt 0 || _notrun "CPU hotplugging not supported"
stress_dir="$TEST_DIR/$seq"
rm -r -f "$stress_dir"
mkdir -p "$stress_dir"
echo "Silence is golden."
sentinel_file=$tmp.hotplug
touch $sentinel_file
exercise_cpu_hotplug &
fsstress_args=(-w -d $stress_dir)
# Cap the number of fsstress threads at one per hotpluggable CPU if we exceed
# 1024 IO threads, per maintainer request.
nr_cpus=$((LOAD_FACTOR * nr_hotplug_cpus))
test "$nr_cpus" -gt 1024 && nr_cpus="$nr_hotplug_cpus"
fsstress_args+=(-p $nr_cpus)
if [ -n "$SOAK_DURATION" ]; then
test "$SOAK_DURATION" -lt 10 && SOAK_DURATION=10
fsstress_args+=(--duration="$((SOAK_DURATION / 10))")
fi
nr_ops=$((2500 * TIME_FACTOR))
fsstress_args+=(-n $nr_ops)
for ((i = 0; i < 10; i++)); do
$FSSTRESS_PROG $FSSTRESS_AVOID -w "${fsstress_args[@]}" >> $seqres.full
_test_cycle_mount
done
rm -f $sentinel_file
# success, all done
status=0
exit
|