Skip to content

Commit

Permalink
selftest/cgroup: Fix test_cpuset_prs.sh problems reported by test robot
Browse files Browse the repository at this point in the history
The test robot reported two different problems when running the
test_cpuset_prs.sh test.

 # ./test_cpuset_prs.sh: line 106: echo: write error: Input/output error
 #  :
 # Effective cpus changed to 0-1,4-7 after test 4!

The write error is caused by writing to /dev/console. It looks like
some systems may not have /dev/console configured or in a writeable
state. Fix this by checking the existence of /dev/console before
attempting to write it.

After the completion of each test run, the script will check if the
cpuset state is reset back to the original state. That usually takes a
while to happen. The test script inserts some artificial delay to make
sure that the reset has completed. The current setting is about 80ms.
That may not be enough in some cases especially if the test system is
slow. Double it to 160ms to minimize the chance of this type of failure.

Reported-by: kernel test robot <[email protected]>
Closes: https://lore.kernel.org/oe-lkp/[email protected]
Signed-off-by: Waiman Long <[email protected]>
Signed-off-by: Tejun Heo <[email protected]>
  • Loading branch information
Waiman-Long authored and htejun committed Jun 19, 2024
1 parent ccac8e8 commit 43ee401
Showing 1 changed file with 14 additions and 6 deletions.
20 changes: 14 additions & 6 deletions tools/testing/selftests/cgroup/test_cpuset_prs.sh
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,14 @@ CPULIST=$(cat $CGROUP2/cpuset.cpus.effective)
NR_CPUS=$(lscpu | grep "^CPU(s):" | sed -e "s/.*:[[:space:]]*//")
[[ $NR_CPUS -lt 8 ]] && skip_test "Test needs at least 8 cpus available!"

# Check to see if /dev/console exists and is writable
if [[ -c /dev/console && -w /dev/console ]]
then
CONSOLE=/dev/console
else
CONSOLE=/dev/null
fi

# Set verbose flag and delay factor
PROG=$1
VERBOSE=0
Expand Down Expand Up @@ -103,8 +111,8 @@ console_msg()
{
MSG=$1
echo "$MSG"
echo "" > /dev/console
echo "$MSG" > /dev/console
echo "" > $CONSOLE
echo "$MSG" > $CONSOLE
pause 0.01
}

Expand Down Expand Up @@ -694,9 +702,9 @@ null_isolcpus_check()
[[ $VERBOSE -gt 0 ]] || return 0
# Retry a few times before printing error
RETRY=0
while [[ $RETRY -lt 5 ]]
while [[ $RETRY -lt 8 ]]
do
pause 0.01
pause 0.02
check_isolcpus "."
[[ $? -eq 0 ]] && return 0
((RETRY++))
Expand Down Expand Up @@ -726,7 +734,7 @@ run_state_test()

while [[ $I -lt $CNT ]]
do
echo "Running test $I ..." > /dev/console
echo "Running test $I ..." > $CONSOLE
[[ $VERBOSE -gt 1 ]] && {
echo ""
eval echo \${$TEST[$I]}
Expand Down Expand Up @@ -783,7 +791,7 @@ run_state_test()
while [[ $NEWLIST != $CPULIST && $RETRY -lt 8 ]]
do
# Wait a bit longer & recheck a few times
pause 0.01
pause 0.02
((RETRY++))
NEWLIST=$(cat cpuset.cpus.effective)
done
Expand Down

0 comments on commit 43ee401

Please sign in to comment.