Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

cgroup/cpuset: add sefltest for cpuset v1

There is only hotplug test for cpuset v1, just add base read/write test
for cpuset v1.

Signed-off-by: Chen Ridong <chenridong@huawei.com>
Acked-by: Waiman Long <longman@redhat.com>
Signed-off-by: Tejun Heo <tj@kernel.org>

authored by

Chen Ridong and committed by
Tejun Heo
3f9319c6 1abab1ba

+78
+1
MAINTAINERS
··· 5703 5703 F: kernel/cgroup/cpuset.c 5704 5704 F: tools/testing/selftests/cgroup/test_cpuset.c 5705 5705 F: tools/testing/selftests/cgroup/test_cpuset_prs.sh 5706 + F: tools/testing/selftests/cgroup/test_cpuset_v1_base.sh 5706 5707 5707 5708 CONTROL GROUP - MEMORY RESOURCE CONTROLLER (MEMCG) 5708 5709 M: Johannes Weiner <hannes@cmpxchg.org>
+77
tools/testing/selftests/cgroup/test_cpuset_v1_base.sh
··· 1 + #!/bin/bash 2 + # SPDX-License-Identifier: GPL-2.0 3 + # 4 + # Basc test for cpuset v1 interfaces write/read 5 + # 6 + 7 + skip_test() { 8 + echo "$1" 9 + echo "Test SKIPPED" 10 + exit 4 # ksft_skip 11 + } 12 + 13 + write_test() { 14 + dir=$1 15 + interface=$2 16 + value=$3 17 + original=$(cat $dir/$interface) 18 + echo "testing $interface $value" 19 + echo $value > $dir/$interface 20 + new=$(cat $dir/$interface) 21 + [[ $value -ne $(cat $dir/$interface) ]] && { 22 + echo "$interface write $value failed: new:$new" 23 + exit 1 24 + } 25 + } 26 + 27 + [[ $(id -u) -eq 0 ]] || skip_test "Test must be run as root!" 28 + 29 + # Find cpuset v1 mount point 30 + CPUSET=$(mount -t cgroup | grep cpuset | head -1 | awk '{print $3}') 31 + [[ -n "$CPUSET" ]] || skip_test "cpuset v1 mount point not found!" 32 + 33 + # 34 + # Create a test cpuset, read write test 35 + # 36 + TDIR=test$$ 37 + [[ -d $CPUSET/$TDIR ]] || mkdir $CPUSET/$TDIR 38 + 39 + ITF_MATRIX=( 40 + #interface value expect root_only 41 + 'cpuset.cpus 0-1 0-1 0' 42 + 'cpuset.mem_exclusive 1 1 0' 43 + 'cpuset.mem_exclusive 0 0 0' 44 + 'cpuset.mem_hardwall 1 1 0' 45 + 'cpuset.mem_hardwall 0 0 0' 46 + 'cpuset.memory_migrate 1 1 0' 47 + 'cpuset.memory_migrate 0 0 0' 48 + 'cpuset.memory_spread_page 1 1 0' 49 + 'cpuset.memory_spread_page 0 0 0' 50 + 'cpuset.memory_spread_slab 1 1 0' 51 + 'cpuset.memory_spread_slab 0 0 0' 52 + 'cpuset.mems 0 0 0' 53 + 'cpuset.sched_load_balance 1 1 0' 54 + 'cpuset.sched_load_balance 0 0 0' 55 + 'cpuset.sched_relax_domain_level 2 2 0' 56 + 'cpuset.memory_pressure_enabled 1 1 1' 57 + 'cpuset.memory_pressure_enabled 0 0 1' 58 + ) 59 + 60 + run_test() 61 + { 62 + cnt="${ITF_MATRIX[@]}" 63 + for i in "${ITF_MATRIX[@]}" ; do 64 + args=($i) 65 + root_only=${args[3]} 66 + [[ $root_only -eq 1 ]] && { 67 + write_test "$CPUSET" "${args[0]}" "${args[1]}" "${args[2]}" 68 + continue 69 + } 70 + write_test "$CPUSET/$TDIR" "${args[0]}" "${args[1]}" "${args[2]}" 71 + done 72 + } 73 + 74 + run_test 75 + rmdir $CPUSET/$TDIR 76 + echo "Test PASSED" 77 + exit 0