ftrace/selftests: workaround cgroup RT scheduling issues

[ Upstream commit 57c4cfd4a2eef8f94052bd7c0fce0981f74fb213 ]

wakeup_rt.tc and wakeup.tc tests in tracers/ subdirectory
fail due to the chrt command returning:

 chrt: failed to set pid 0's policy: Operation not permitted.

To work around this, temporarily disable grout RT scheduling
during ftracetest execution.  Restore original value on
test run completion.  With these changes in place, both
tests consistently pass.

Fixes: c575dea2c1 ("selftests/ftrace: Add wakeup_rt tracer testcase")
Fixes: c1edd060b4 ("selftests/ftrace: Add wakeup tracer testcase")
Signed-off-by: Alan Maguire <alan.maguire@oracle.com>
Acked-by: Steven Rostedt (VMware) <rostedt@goodmis.org>
Signed-off-by: Shuah Khan <skhan@linuxfoundation.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
This commit is contained in:
Alan Maguire 2020-02-19 09:33:29 +00:00 committed by Greg Kroah-Hartman
parent dbd667a322
commit 23a0a0914a

View File

@ -29,8 +29,25 @@ err_ret=1
# kselftest skip code is 4
err_skip=4
# cgroup RT scheduling prevents chrt commands from succeeding, which
# induces failures in test wakeup tests. Disable for the duration of
# the tests.
readonly sched_rt_runtime=/proc/sys/kernel/sched_rt_runtime_us
sched_rt_runtime_orig=$(cat $sched_rt_runtime)
setup() {
echo -1 > $sched_rt_runtime
}
cleanup() {
echo $sched_rt_runtime_orig > $sched_rt_runtime
}
errexit() { # message
echo "Error: $1" 1>&2
cleanup
exit $err_ret
}
@ -39,6 +56,8 @@ if [ `id -u` -ne 0 ]; then
errexit "this must be run by root user"
fi
setup
# Utilities
absdir() { # file_path
(cd `dirname $1`; pwd)
@ -235,6 +254,7 @@ TOTAL_RESULT=0
INSTANCE=
CASENO=0
testcase() { # testfile
CASENO=$((CASENO+1))
desc=`grep "^#[ \t]*description:" $1 | cut -f2 -d:`
@ -406,5 +426,7 @@ prlog "# of unsupported: " `echo $UNSUPPORTED_CASES | wc -w`
prlog "# of xfailed: " `echo $XFAILED_CASES | wc -w`
prlog "# of undefined(test bug): " `echo $UNDEFINED_CASES | wc -w`
cleanup
# if no error, return 0
exit $TOTAL_RESULT