在 2026/10/11 06:19, Waiman Long 写道:
> The test_cpuset_prs.sh test assumes that all the relevant CPUs being
> tested are online. If some of them are offline, some of the test cases
> may fail. So skip the test if the required CPUs are either offline or
> not present.
>
> Signed-off-by: Waiman Long <[email protected]>
> ---
> .../selftests/cgroup/test_cpuset_prs.sh | 20 +++++++++++++++++++
> 1 file changed, 20 insertions(+)
>
> diff --git a/tools/testing/selftests/cgroup/test_cpuset_prs.sh
> b/tools/testing/selftests/cgroup/test_cpuset_prs.sh
> index 3d392e8c66aa..f57971ebb90e 100755
> --- a/tools/testing/selftests/cgroup/test_cpuset_prs.sh
> +++ b/tools/testing/selftests/cgroup/test_cpuset_prs.sh
> @@ -118,6 +118,26 @@ TEST_ISOLCPUS=
> skip_test "Current isolated CPUs ($CURRENT_ISOLCPUS) don't
> match boot isolated CPUs!"
> }
>
> +#
> +# This test assumes that all the relevant CPUs being tested are online.
> +# If some of them are offline, some of the tests may fail. So we are going to
> +# skip running this test script if some of the required CPUs may be offline.
> +# The required CPUs include CPUs 0-7 and the first boot time isolated CPU if
> +# present. However the check below is not exhaustive and can be a false
> +# positive, but users should not run this test if some CPUs are offline.
> +#
> +ONLINE_CPUS=$(cat /sys/devices/system/cpu/online | sed -e "s/,.*//")
> +ONLINE_FIRST=$(echo $ONLINE_CPUS | sed -e "s/-.*//")
> +ONLINE_LAST=$(echo $ONLINE_CPUS | sed -e "s/.*-//")
> +if [[ -n "$FIRST_ISOLCPUS" ]]
> +then
> + LAST_REQUIRED_CPU=$FIRST_ISOLCPUS
> +else
> + LAST_REQUIRED_CPU=7
> +fi
> +[[ $ONLINE_FIRST != 0 || $ONLINE_LAST -lt $LAST_REQUIRED_CPU ]] &&
> + skip_test "Some of the required CPUs are offline or not present!"
> +
Could this check run before the setup that creates the test cgroup and
changes sched/verbose?
skip_test() exits directly, and the cleanup trap hasn't been installed
here. We have already created test; with -v, sched/verbose has also been
set to Y. This exit leaves the cgroup behind and bypasses restoring
verbose.
Thanks,
Guopeng
> cleanup()
> {
> online_cpus