Path: blob/master/tools/testing/selftests/cgroup/test_cpuset_v1_hp.sh
26285 views
#!/bin/bash1# SPDX-License-Identifier: GPL-2.02#3# Test the special cpuset v1 hotplug case where a cpuset become empty of4# CPUs will force migration of tasks out to an ancestor.5#67skip_test() {8echo "$1"9echo "Test SKIPPED"10exit 4 # ksft_skip11}1213[[ $(id -u) -eq 0 ]] || skip_test "Test must be run as root!"1415# Find cpuset v1 mount point16CPUSET=$(mount -t cgroup | grep cpuset | head -1 | awk -e '{print $3}')17[[ -n "$CPUSET" ]] || skip_test "cpuset v1 mount point not found!"1819#20# Create a test cpuset, put a CPU and a task there and offline that CPU21#22TDIR=test$$23[[ -d $CPUSET/$TDIR ]] || mkdir $CPUSET/$TDIR24echo 1 > $CPUSET/$TDIR/cpuset.cpus25echo 0 > $CPUSET/$TDIR/cpuset.mems26sleep 10&27TASK=$!28echo $TASK > $CPUSET/$TDIR/tasks29NEWCS=$(cat /proc/$TASK/cpuset)30[[ $NEWCS != "/$TDIR" ]] && {31echo "Unexpected cpuset $NEWCS, test FAILED!"32exit 133}3435echo 0 > /sys/devices/system/cpu/cpu1/online36sleep 0.537echo 1 > /sys/devices/system/cpu/cpu1/online38NEWCS=$(cat /proc/$TASK/cpuset)39rmdir $CPUSET/$TDIR40[[ $NEWCS != "/" ]] && {41echo "cpuset $NEWCS, test FAILED!"42exit 143}44echo "Test PASSED"45exit 0464748