1f08c3bdfSopenharmony_ci#!/bin/sh
2f08c3bdfSopenharmony_ci# SPDX-License-Identifier: GPL-2.0-or-later
3f08c3bdfSopenharmony_ci# Copyright (c) 2019-2022 Petr Vorel <pvorel@suse.cz>
4f08c3bdfSopenharmony_ci# Copyright (c) 2009 FUJITSU LIMITED
5f08c3bdfSopenharmony_ci# Author: Li Zefan <lizf@cn.fujitsu.com>
6f08c3bdfSopenharmony_ci
7f08c3bdfSopenharmony_ciTST_TESTFUNC=test
8f08c3bdfSopenharmony_ciTST_SETUP=do_setup
9f08c3bdfSopenharmony_ciTST_CLEANUP=do_cleanup
10f08c3bdfSopenharmony_ciTST_CNT=8
11f08c3bdfSopenharmony_ciTST_NEEDS_ROOT=1
12f08c3bdfSopenharmony_ciTST_NEEDS_TMPDIR=1
13f08c3bdfSopenharmony_ciTST_NEEDS_CMDS="awk dmesg find mountpoint rmdir"
14f08c3bdfSopenharmony_ci
15f08c3bdfSopenharmony_cido_setup()
16f08c3bdfSopenharmony_ci{
17f08c3bdfSopenharmony_ci	mkdir cgroup/
18f08c3bdfSopenharmony_ci
19f08c3bdfSopenharmony_ci	if [ ! -f /proc/cgroups ]; then
20f08c3bdfSopenharmony_ci		tst_brk TCONF ignored "Kernel does not support for control groups; skipping testcases";
21f08c3bdfSopenharmony_ci	fi
22f08c3bdfSopenharmony_ci
23f08c3bdfSopenharmony_ci	dmesg -c > /dev/null
24f08c3bdfSopenharmony_ci	NR_BUG=`dmesg | grep -c "kernel BUG"`
25f08c3bdfSopenharmony_ci	NR_NULL=`dmesg | grep -c "kernel NULL pointer dereference"`
26f08c3bdfSopenharmony_ci	NR_WARNING=`dmesg | grep -c "^WARNING"`
27f08c3bdfSopenharmony_ci	NR_LOCKDEP=`dmesg | grep -c "possible recursive locking detected"`
28f08c3bdfSopenharmony_ci}
29f08c3bdfSopenharmony_ci
30f08c3bdfSopenharmony_cido_cleanup()
31f08c3bdfSopenharmony_ci{
32f08c3bdfSopenharmony_ci	if mountpoint -q cgroup/; then
33f08c3bdfSopenharmony_ci		find cgroup/ -maxdepth 1 -depth -exec rmdir {} +
34f08c3bdfSopenharmony_ci		umount cgroup/
35f08c3bdfSopenharmony_ci		rmdir cgroup
36f08c3bdfSopenharmony_ci	fi
37f08c3bdfSopenharmony_ci}
38f08c3bdfSopenharmony_ci
39f08c3bdfSopenharmony_cicheck_kernel_bug()
40f08c3bdfSopenharmony_ci{
41f08c3bdfSopenharmony_ci	local id="$1"
42f08c3bdfSopenharmony_ci	local ok_msg="no kernel bug was found"
43f08c3bdfSopenharmony_ci	local new_bug=`dmesg | grep -c "kernel BUG"`
44f08c3bdfSopenharmony_ci	local new_null=`dmesg | grep -c "kernel NULL pointer dereference"`
45f08c3bdfSopenharmony_ci	local new_warning=`dmesg | grep -c "^WARNING"`
46f08c3bdfSopenharmony_ci	local new_lockdep=`dmesg | grep -c "possible recursive locking detected"`
47f08c3bdfSopenharmony_ci
48f08c3bdfSopenharmony_ci	[ "$id" ] && ok_msg="$ok_msg for test $i"
49f08c3bdfSopenharmony_ci
50f08c3bdfSopenharmony_ci	# no kernel bug is detected
51f08c3bdfSopenharmony_ci	if [ $new_bug -eq $NR_BUG -a $new_warning -eq $NR_WARNING -a \
52f08c3bdfSopenharmony_ci	     $new_null -eq $NR_NULL -a $new_lockdep -eq $NR_LOCKDEP ]; then
53f08c3bdfSopenharmony_ci		tst_res TPASS $ok_msg
54f08c3bdfSopenharmony_ci		return 0
55f08c3bdfSopenharmony_ci	fi
56f08c3bdfSopenharmony_ci
57f08c3bdfSopenharmony_ci	# some kernel bug is detected
58f08c3bdfSopenharmony_ci	if [ $new_bug -gt $NR_BUG ]; then
59f08c3bdfSopenharmony_ci		tst_res TFAIL "kernel BUG was detected!"
60f08c3bdfSopenharmony_ci	fi
61f08c3bdfSopenharmony_ci	if [ $new_warning -gt $NR_WARNING ]; then
62f08c3bdfSopenharmony_ci		tst_res TFAIL "kernel WARNING was detected!"
63f08c3bdfSopenharmony_ci	fi
64f08c3bdfSopenharmony_ci	if [ $new_null -gt $NR_NULL ]; then
65f08c3bdfSopenharmony_ci		tst_res TFAIL "kernel NULL pointer dereference!"
66f08c3bdfSopenharmony_ci	fi
67f08c3bdfSopenharmony_ci	if [ $new_lockdep -gt $NR_LOCKDEP ]; then
68f08c3bdfSopenharmony_ci		tst_res TFAIL "kernel lockdep warning was detected!"
69f08c3bdfSopenharmony_ci	fi
70f08c3bdfSopenharmony_ci
71f08c3bdfSopenharmony_ci	NR_BUG=$new_bug
72f08c3bdfSopenharmony_ci	NR_NULL=$new_null
73f08c3bdfSopenharmony_ci	NR_WARNING=$new_warning
74f08c3bdfSopenharmony_ci	NR_LOCKDEP=$new_lockdep
75f08c3bdfSopenharmony_ci
76f08c3bdfSopenharmony_ci	tst_res TWARN "BUG FOUND!"
77f08c3bdfSopenharmony_ci	dmesg
78f08c3bdfSopenharmony_ci	return 1
79f08c3bdfSopenharmony_ci}
80f08c3bdfSopenharmony_ci
81f08c3bdfSopenharmony_ci#---------------------------------------------------------------------------
82f08c3bdfSopenharmony_ci# Bug:    There was a race when keeping forking processes and at the same
83f08c3bdfSopenharmony_ci#         time cat /cgroup/tasks (should be the very first time to read
84f08c3bdfSopenharmony_ci#         /cgroup/tasks, otherwise this bug won't be triggered)
85f08c3bdfSopenharmony_ci# Kernel: 2.6.24, 2.6.25-rcX
86f08c3bdfSopenharmony_ci# Links:  http://lkml.org/lkml/2007/10/17/224
87f08c3bdfSopenharmony_ci#         http://lkml.org/lkml/2008/3/5/332
88f08c3bdfSopenharmony_ci#         http://lkml.org/lkml/2008/4/16/493
89f08c3bdfSopenharmony_ci# Fix:    commit 0e04388f0189fa1f6812a8e1cb6172136eada87e
90f08c3bdfSopenharmony_ci#---------------------------------------------------------------------------
91f08c3bdfSopenharmony_citest1()
92f08c3bdfSopenharmony_ci{
93f08c3bdfSopenharmony_ci	cgroup_regression_fork_processes &
94f08c3bdfSopenharmony_ci	sleep 1
95f08c3bdfSopenharmony_ci
96f08c3bdfSopenharmony_ci	mount -t cgroup -o none,name=foo cgroup cgroup/
97f08c3bdfSopenharmony_ci	if [ $? -ne 0 ]; then
98f08c3bdfSopenharmony_ci		tst_res TFAIL "failed to mount cgroup filesystem"
99f08c3bdfSopenharmony_ci		kill -TERM $!
100f08c3bdfSopenharmony_ci		return
101f08c3bdfSopenharmony_ci	fi
102f08c3bdfSopenharmony_ci	cat cgroup/tasks > /dev/null
103f08c3bdfSopenharmony_ci
104f08c3bdfSopenharmony_ci	kill -TERM $!
105f08c3bdfSopenharmony_ci	wait $! 2>/dev/null
106f08c3bdfSopenharmony_ci	umount cgroup/
107f08c3bdfSopenharmony_ci	check_kernel_bug
108f08c3bdfSopenharmony_ci}
109f08c3bdfSopenharmony_ci
110f08c3bdfSopenharmony_ci#---------------------------------------------------------------------------
111f08c3bdfSopenharmony_ci# Bug:    a cgroup's notify_on_release flag did not inherit from its parent.
112f08c3bdfSopenharmony_ci# Kernel: 2.6.24-rcX
113f08c3bdfSopenharmony_ci# Links:  http://lkml.org/lkml/2008/2/25/12
114f08c3bdfSopenharmony_ci# Fix:    commit bc231d2a048010d5e0b49ac7fddbfa822fc41109
115f08c3bdfSopenharmony_ci#---------------------------------------------------------------------------
116f08c3bdfSopenharmony_citest2()
117f08c3bdfSopenharmony_ci{
118f08c3bdfSopenharmony_ci	local val1
119f08c3bdfSopenharmony_ci	local val2
120f08c3bdfSopenharmony_ci
121f08c3bdfSopenharmony_ci	mount -t cgroup -o none,name=foo cgroup cgroup/
122f08c3bdfSopenharmony_ci	if [ $? -ne 0 ]; then
123f08c3bdfSopenharmony_ci		tst_res TFAIL "Failed to mount cgroup filesystem"
124f08c3bdfSopenharmony_ci		return
125f08c3bdfSopenharmony_ci	fi
126f08c3bdfSopenharmony_ci
127f08c3bdfSopenharmony_ci	echo 0 > cgroup/notify_on_release
128f08c3bdfSopenharmony_ci	mkdir cgroup/0
129f08c3bdfSopenharmony_ci	val1=`cat cgroup/0/notify_on_release`
130f08c3bdfSopenharmony_ci
131f08c3bdfSopenharmony_ci	echo 1 > cgroup/notify_on_release
132f08c3bdfSopenharmony_ci	mkdir cgroup/1
133f08c3bdfSopenharmony_ci	val2=`cat cgroup/1/notify_on_release`
134f08c3bdfSopenharmony_ci
135f08c3bdfSopenharmony_ci	if [ $val1 -ne 0 -o $val2 -ne 1 ]; then
136f08c3bdfSopenharmony_ci		tst_res TFAIL "wrong notify_on_release value"
137f08c3bdfSopenharmony_ci	else
138f08c3bdfSopenharmony_ci		tst_res TPASS "notify_on_release is inherited"
139f08c3bdfSopenharmony_ci	fi
140f08c3bdfSopenharmony_ci
141f08c3bdfSopenharmony_ci	rmdir cgroup/0 cgroup/1
142f08c3bdfSopenharmony_ci	tst_umount $PWD/cgroup
143f08c3bdfSopenharmony_ci}
144f08c3bdfSopenharmony_ci
145f08c3bdfSopenharmony_ci#---------------------------------------------------------------------------
146f08c3bdfSopenharmony_ci# Bug:    Accessing NULL cgrp->dentry when reading /proc/sched_debug
147f08c3bdfSopenharmony_ci# Kernel: 2.6.26-2.6.28
148f08c3bdfSopenharmony_ci# Links:  http://lkml.org/lkml/2008/10/30/44
149f08c3bdfSopenharmony_ci#         http://lkml.org/lkml/2008/12/12/107
150f08c3bdfSopenharmony_ci#         http://lkml.org/lkml/2008/12/16/481
151f08c3bdfSopenharmony_ci# Fix:    commit a47295e6bc42ad35f9c15ac66f598aa24debd4e2
152f08c3bdfSopenharmony_ci#---------------------------------------------------------------------------
153f08c3bdfSopenharmony_citest3()
154f08c3bdfSopenharmony_ci{
155f08c3bdfSopenharmony_ci	local cpu_subsys_path
156f08c3bdfSopenharmony_ci
157f08c3bdfSopenharmony_ci	if [ ! -e /proc/sched_debug ]; then
158f08c3bdfSopenharmony_ci		tst_res TCONF "CONFIG_SCHED_DEBUG is not enabled"
159f08c3bdfSopenharmony_ci		return
160f08c3bdfSopenharmony_ci	fi
161f08c3bdfSopenharmony_ci
162f08c3bdfSopenharmony_ci	if ! grep -q -w "cpu" /proc/cgroups; then
163f08c3bdfSopenharmony_ci		tst_res TCONF "CONFIG_CGROUP_SCHED is not enabled"
164f08c3bdfSopenharmony_ci		return
165f08c3bdfSopenharmony_ci	fi
166f08c3bdfSopenharmony_ci
167f08c3bdfSopenharmony_ci	cgroup_require "cpu"
168f08c3bdfSopenharmony_ci	cpu_subsys_path=$(cgroup_get_mountpoint "cpu")
169f08c3bdfSopenharmony_ci
170f08c3bdfSopenharmony_ci	cgroup_regression_3_1.sh $cpu_subsys_path &
171f08c3bdfSopenharmony_ci	pid1=$!
172f08c3bdfSopenharmony_ci	cgroup_regression_3_2.sh &
173f08c3bdfSopenharmony_ci	pid2=$!
174f08c3bdfSopenharmony_ci
175f08c3bdfSopenharmony_ci	sleep 30
176f08c3bdfSopenharmony_ci	kill -USR1 $pid1 $pid2
177f08c3bdfSopenharmony_ci	wait $pid1 2>/dev/null
178f08c3bdfSopenharmony_ci	wait $pid2 2>/dev/null
179f08c3bdfSopenharmony_ci
180f08c3bdfSopenharmony_ci	rmdir $cpu_subsys_path/0 2> /dev/null
181f08c3bdfSopenharmony_ci	cgroup_cleanup
182f08c3bdfSopenharmony_ci	check_kernel_bug
183f08c3bdfSopenharmony_ci}
184f08c3bdfSopenharmony_ci
185f08c3bdfSopenharmony_ci#---------------------------------------------------------------------------
186f08c3bdfSopenharmony_ci# Bug:    cgroup hierarchy lock's lockdep subclass may overflow
187f08c3bdfSopenharmony_ci# Kernel: 2.6.29-rcX
188f08c3bdfSopenharmony_ci# Link:   http://lkml.org/lkml/2009/2/4/67
189f08c3bdfSopenharmony_ci# Fix:
190f08c3bdfSopenharmony_ci#---------------------------------------------------------------------------
191f08c3bdfSopenharmony_citest4()
192f08c3bdfSopenharmony_ci{
193f08c3bdfSopenharmony_ci	local lines
194f08c3bdfSopenharmony_ci
195f08c3bdfSopenharmony_ci	if [ ! -e /proc/lockdep ]; then
196f08c3bdfSopenharmony_ci		tst_res TCONF "CONFIG_LOCKDEP is not enabled"
197f08c3bdfSopenharmony_ci		return
198f08c3bdfSopenharmony_ci	fi
199f08c3bdfSopenharmony_ci
200f08c3bdfSopenharmony_ci	# MAX_LOCKDEP_SUBCLASSES is 8, so number of subsys should be > 8
201f08c3bdfSopenharmony_ci	lines=`cat /proc/cgroups | wc -l`
202f08c3bdfSopenharmony_ci	if [ $lines -le 9 ]; then
203f08c3bdfSopenharmony_ci		tst_res TCONF "require more than 8 cgroup subsystems"
204f08c3bdfSopenharmony_ci		return
205f08c3bdfSopenharmony_ci	fi
206f08c3bdfSopenharmony_ci
207f08c3bdfSopenharmony_ci	mount -t cgroup -o none,name=foo cgroup cgroup/
208f08c3bdfSopenharmony_ci	mkdir cgroup/0
209f08c3bdfSopenharmony_ci	rmdir cgroup/0
210f08c3bdfSopenharmony_ci	tst_umount $PWD/cgroup
211f08c3bdfSopenharmony_ci
212f08c3bdfSopenharmony_ci	if dmesg | grep -q "MAX_LOCKDEP_SUBCLASSES too low"; then
213f08c3bdfSopenharmony_ci		tst_res TFAIL "lockdep BUG was found"
214f08c3bdfSopenharmony_ci		return
215f08c3bdfSopenharmony_ci	fi
216f08c3bdfSopenharmony_ci
217f08c3bdfSopenharmony_ci	tst_res TPASS "no lockdep BUG was found"
218f08c3bdfSopenharmony_ci}
219f08c3bdfSopenharmony_ci
220f08c3bdfSopenharmony_ci#---------------------------------------------------------------------------
221f08c3bdfSopenharmony_ci# Bug:    When running 2 concurrent mount/umount threads, kernel WARNING
222f08c3bdfSopenharmony_ci#         may be triggered, but it's VFS' issue but not cgroup.
223f08c3bdfSopenharmony_ci# Kernel: 2.6.24 - 2.6.29-rcX
224f08c3bdfSopenharmony_ci# Links:  http://lkml.org/lkml/2009/1/4/354
225f08c3bdfSopenharmony_ci# Fix:    commit 1a88b5364b535edaa321d70a566e358390ff0872
226f08c3bdfSopenharmony_ci#---------------------------------------------------------------------------
227f08c3bdfSopenharmony_citest5()
228f08c3bdfSopenharmony_ci{
229f08c3bdfSopenharmony_ci	cgroup_regression_5_1.sh &
230f08c3bdfSopenharmony_ci	local pid1=$!
231f08c3bdfSopenharmony_ci	cgroup_regression_5_2.sh &
232f08c3bdfSopenharmony_ci	local pid2=$!
233f08c3bdfSopenharmony_ci
234f08c3bdfSopenharmony_ci	sleep 30
235f08c3bdfSopenharmony_ci	kill -USR1 $pid1 $pid2
236f08c3bdfSopenharmony_ci	wait $pid1 2>/dev/null
237f08c3bdfSopenharmony_ci	wait $pid2 2>/dev/null
238f08c3bdfSopenharmony_ci
239f08c3bdfSopenharmony_ci	mount -t cgroup none cgroup 2> /dev/null
240f08c3bdfSopenharmony_ci	mkdir cgroup/0
241f08c3bdfSopenharmony_ci	rmdir cgroup/0
242f08c3bdfSopenharmony_ci	tst_umount $PWD/cgroup
243f08c3bdfSopenharmony_ci	check_kernel_bug
244f08c3bdfSopenharmony_ci}
245f08c3bdfSopenharmony_ci
246f08c3bdfSopenharmony_ci#---------------------------------------------------------------------------
247f08c3bdfSopenharmony_ci# Bug:    When running 2 concurrent mount/umount threads, lockdep warning
248f08c3bdfSopenharmony_ci#         may be triggered, it's a false positive, and it's VFS' issue but
249f08c3bdfSopenharmony_ci#         not cgroup.
250f08c3bdfSopenharmony_ci# Kernel: 2.6.24 - 2.6.29-rcX
251f08c3bdfSopenharmony_ci# Links:  http://lkml.org/lkml/2009/1/4/352
252f08c3bdfSopenharmony_ci# Fix:    commit ada723dcd681e2dffd7d73345cc8fda0eb0df9bd
253f08c3bdfSopenharmony_ci#---------------------------------------------------------------------------
254f08c3bdfSopenharmony_citest6()
255f08c3bdfSopenharmony_ci{
256f08c3bdfSopenharmony_ci	cgroup_regression_6_1.sh &
257f08c3bdfSopenharmony_ci	local pid1=$!
258f08c3bdfSopenharmony_ci	cgroup_regression_6_2.sh &
259f08c3bdfSopenharmony_ci	local pid2=$!
260f08c3bdfSopenharmony_ci
261f08c3bdfSopenharmony_ci	sleep 30
262f08c3bdfSopenharmony_ci	kill -USR1 $pid1 $pid2
263f08c3bdfSopenharmony_ci	wait $pid1 2>/dev/null
264f08c3bdfSopenharmony_ci	wait $pid2 2>/dev/null
265f08c3bdfSopenharmony_ci
266f08c3bdfSopenharmony_ci	umount cgroup/ 2> /dev/null
267f08c3bdfSopenharmony_ci	check_kernel_bug
268f08c3bdfSopenharmony_ci}
269f08c3bdfSopenharmony_ci
270f08c3bdfSopenharmony_ci#---------------------------------------------------------------------------
271f08c3bdfSopenharmony_ci# Bug:    There was a bug when remount cgroup fs with some dead subdirs in
272f08c3bdfSopenharmony_ci#         it (rmdir()ed but still has some refcnts on it). It caused memory
273f08c3bdfSopenharmony_ci#         leak, and may cause oops when cat /proc/sched_debug.
274f08c3bdfSopenharmony_ci# Kernel: 2.6.24 - 2.6.27, 2.6.28-rcX
275f08c3bdfSopenharmony_ci# Links:  http://lkml.org/lkml/2008/12/10/369
276f08c3bdfSopenharmony_ci# Fix:    commit 307257cf475aac25db30b669987f13d90c934e3a
277f08c3bdfSopenharmony_ci#---------------------------------------------------------------------------
278f08c3bdfSopenharmony_citest_7_1()
279f08c3bdfSopenharmony_ci{
280f08c3bdfSopenharmony_ci	local subsys=$1
281f08c3bdfSopenharmony_ci	local subsys_path
282f08c3bdfSopenharmony_ci	# we should be careful to select a $subsys_path which is related to
283f08c3bdfSopenharmony_ci	# cgroup only: if cgroup debugging is enabled a 'debug' $subsys
284f08c3bdfSopenharmony_ci	# could be passed here as params and this will lead to ambiguity and
285f08c3bdfSopenharmony_ci	# errors when grepping simply for 'debug' in /proc/mounts since we'll
286f08c3bdfSopenharmony_ci	# find also /sys/kernel/debug. Helper takes care of this.
287f08c3bdfSopenharmony_ci
288f08c3bdfSopenharmony_ci	cgroup_require "$subsys"
289f08c3bdfSopenharmony_ci	subsys_path=$(cgroup_get_mountpoint "$subsys")
290f08c3bdfSopenharmony_ci
291f08c3bdfSopenharmony_ci	mkdir $subsys_path/0
292f08c3bdfSopenharmony_ci	sleep 100 < $subsys_path/0 &	# add refcnt to this dir
293f08c3bdfSopenharmony_ci	rmdir $subsys_path/0
294f08c3bdfSopenharmony_ci
295f08c3bdfSopenharmony_ci	# remount with new subsystems added
296f08c3bdfSopenharmony_ci	# since 2.6.28, this remount will fail
297f08c3bdfSopenharmony_ci
298f08c3bdfSopenharmony_ci	if [ "$subsys_path" = "cgroup" ]; then
299f08c3bdfSopenharmony_ci		mount -t cgroup -o remount xxx cgroup/ 2> /dev/null
300f08c3bdfSopenharmony_ci		kill -TERM $!
301f08c3bdfSopenharmony_ci		wait $! 2>/dev/null
302f08c3bdfSopenharmony_ci		umount cgroup/
303f08c3bdfSopenharmony_ci	fi
304f08c3bdfSopenharmony_ci
305f08c3bdfSopenharmony_ci	cgroup_cleanup
306f08c3bdfSopenharmony_ci}
307f08c3bdfSopenharmony_ci
308f08c3bdfSopenharmony_citest_7_2()
309f08c3bdfSopenharmony_ci{
310f08c3bdfSopenharmony_ci	local subsys=$1
311f08c3bdfSopenharmony_ci
312f08c3bdfSopenharmony_ci	mount -t cgroup -o none,name=foo cgroup cgroup/
313f08c3bdfSopenharmony_ci	if [ $? -ne 0 ]; then
314f08c3bdfSopenharmony_ci		tst_res TFAIL "failed to mount cgroup"
315f08c3bdfSopenharmony_ci		return
316f08c3bdfSopenharmony_ci	fi
317f08c3bdfSopenharmony_ci
318f08c3bdfSopenharmony_ci	mkdir cgroup/0
319f08c3bdfSopenharmony_ci	sleep 100 < cgroup/0 &	# add refcnt to this dir
320f08c3bdfSopenharmony_ci	rmdir cgroup/0
321f08c3bdfSopenharmony_ci
322f08c3bdfSopenharmony_ci	# remount with some subsystems removed
323f08c3bdfSopenharmony_ci	# since 2.6.28, this remount will fail
324f08c3bdfSopenharmony_ci	mount -t cgroup -o remount,$subsys xxx cgroup/ 2> /dev/null
325f08c3bdfSopenharmony_ci	kill -TERM $!
326f08c3bdfSopenharmony_ci	wait $! 2>/dev/null
327f08c3bdfSopenharmony_ci	umount cgroup/
328f08c3bdfSopenharmony_ci
329f08c3bdfSopenharmony_ci	grep -q -w "cpu" /proc/cgroups
330f08c3bdfSopenharmony_ci	if [ $? -ne 0 -o ! -e /proc/sched_debug ]; then
331f08c3bdfSopenharmony_ci		tst_res TCONF "skip rest of testing due possible oops triggered by reading /proc/sched_debug"
332f08c3bdfSopenharmony_ci		return
333f08c3bdfSopenharmony_ci	fi
334f08c3bdfSopenharmony_ci
335f08c3bdfSopenharmony_ci	tmp=0
336f08c3bdfSopenharmony_ci	while [ $tmp -lt 50 ]; do
337f08c3bdfSopenharmony_ci		echo 3 > /proc/sys/vm/drop_caches
338f08c3bdfSopenharmony_ci		cat /proc/sched_debug > /dev/null
339f08c3bdfSopenharmony_ci		tmp=$((tmp+1))
340f08c3bdfSopenharmony_ci	done
341f08c3bdfSopenharmony_ci}
342f08c3bdfSopenharmony_ci
343f08c3bdfSopenharmony_citest7()
344f08c3bdfSopenharmony_ci{
345f08c3bdfSopenharmony_ci	local lines=`cat /proc/cgroups | wc -l`
346f08c3bdfSopenharmony_ci	local subsys
347f08c3bdfSopenharmony_ci	local i=1
348f08c3bdfSopenharmony_ci
349f08c3bdfSopenharmony_ci	if [ $lines -le 2 ]; then
350f08c3bdfSopenharmony_ci		tst_res TCONF "require at least 2 cgroup subsystems"
351f08c3bdfSopenharmony_ci		slt_result $SLT_Untested
352f08c3bdfSopenharmony_ci		return
353f08c3bdfSopenharmony_ci	fi
354f08c3bdfSopenharmony_ci
355f08c3bdfSopenharmony_ci	subsys=`tail -n 1 /proc/cgroups | awk '{ print $1 }'`
356f08c3bdfSopenharmony_ci
357f08c3bdfSopenharmony_ci	# remount to add new subsystems to the hierarchy
358f08c3bdfSopenharmony_ci	while [ $i -le 2 ]; do
359f08c3bdfSopenharmony_ci		test_7_$i $subsys || return
360f08c3bdfSopenharmony_ci		check_kernel_bug $i || return
361f08c3bdfSopenharmony_ci		i=$((i+1))
362f08c3bdfSopenharmony_ci	done
363f08c3bdfSopenharmony_ci}
364f08c3bdfSopenharmony_ci
365f08c3bdfSopenharmony_ci#---------------------------------------------------------------------------
366f08c3bdfSopenharmony_ci# Bug:    oops when get cgroupstat of a cgroup control file
367f08c3bdfSopenharmony_ci# Kernel: 2.6.24 - 2.6.27, 2.6.28-rcX
368f08c3bdfSopenharmony_ci# Links:  http://lkml.org/lkml/2008/11/19/53
369f08c3bdfSopenharmony_ci# Fix:    commit 33d283bef23132c48195eafc21449f8ba88fce6b
370f08c3bdfSopenharmony_ci#---------------------------------------------------------------------------
371f08c3bdfSopenharmony_citest8()
372f08c3bdfSopenharmony_ci{
373f08c3bdfSopenharmony_ci	mount -t cgroup -o none,name=foo cgroup cgroup/
374f08c3bdfSopenharmony_ci	if [ $? -ne 0 ]; then
375f08c3bdfSopenharmony_ci		tst_res TFAIL "failed to mount cgroup filesystem"
376f08c3bdfSopenharmony_ci		return
377f08c3bdfSopenharmony_ci	fi
378f08c3bdfSopenharmony_ci
379f08c3bdfSopenharmony_ci	if cgroup_regression_getdelays -C cgroup/tasks > /dev/null 2>&1; then
380f08c3bdfSopenharmony_ci		tst_res TFAIL "should have failed to get cgroupstat of tasks file"
381f08c3bdfSopenharmony_ci	fi
382f08c3bdfSopenharmony_ci
383f08c3bdfSopenharmony_ci	umount cgroup/
384f08c3bdfSopenharmony_ci	check_kernel_bug
385f08c3bdfSopenharmony_ci}
386f08c3bdfSopenharmony_ci
387f08c3bdfSopenharmony_ci. cgroup_lib.sh
388f08c3bdfSopenharmony_citst_run
389