Skip to content

Commit 3f9319c

Browse files
Chen Ridonghtejun
authored andcommitted
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 <[email protected]> Acked-by: Waiman Long <[email protected]> Signed-off-by: Tejun Heo <[email protected]>
1 parent 1abab1b commit 3f9319c

File tree

2 files changed

+78
-0
lines changed

2 files changed

+78
-0
lines changed

MAINTAINERS

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5703,6 +5703,7 @@ F: kernel/cgroup/cpuset-v1.c
57035703
F: kernel/cgroup/cpuset.c
57045704
F: tools/testing/selftests/cgroup/test_cpuset.c
57055705
F: tools/testing/selftests/cgroup/test_cpuset_prs.sh
5706+
F: tools/testing/selftests/cgroup/test_cpuset_v1_base.sh
57065707

57075708
CONTROL GROUP - MEMORY RESOURCE CONTROLLER (MEMCG)
57085709
M: Johannes Weiner <[email protected]>
Lines changed: 77 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,77 @@
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

0 commit comments

Comments
 (0)