Those testcases can reproduce bugs we found in cgroups, and is useful
to track future regressions.
Note: this test may crash the system with older kernels, so it is
disabled for kernels older than 2.6.29
Another note: getdelays.c is linux-2.6/Documentation/accounting/getdelays.c
How to run this test:
# runltp -f controllers
Result:
cgroup_regression_test 1 PASS : no kernel bug was found
cgroup_regression_test 2 PASS : notify_on_release is inherited
cgroup_regression_test 3 PASS : no kernel bug was found
cgroup_regression_test 4 PASS : no lockdep BUG was found
cgroup_regression_test 5 PASS : no kernel bug was found
cgroup_regression_test 6 PASS : no kernel bug was found
cgroup_regression_test 7 PASS : no kernel bug was found
cgroup_regression_test 8 PASS : no kernel bug was found
cgroup_regression_test 9 PASS : no kernel warning was found
cgroup_regression_test 10 PASS : no kernel warning was found
Signed-off-by: Li Zefan <[email protected]>
---
runtest/controllers | 1
testcases/kernel/controllers/Makefile | 7
testcases/kernel/controllers/README | 4
testcases/kernel/controllers/cgroup/Makefile | 16
testcases/kernel/controllers/cgroup/README | 9
testcases/kernel/controllers/cgroup/cgroup_regression_test.sh | 529 ++++++++++
testcases/kernel/controllers/cgroup/fork_processes.c | 50
testcases/kernel/controllers/cgroup/getdelays.c | 505 +++++++++
testcases/kernel/controllers/cgroup/test_10_1.sh | 34
testcases/kernel/controllers/cgroup/test_10_2.sh | 32
testcases/kernel/controllers/cgroup/test_3_1.sh | 32
testcases/kernel/controllers/cgroup/test_3_2.sh | 31
testcases/kernel/controllers/cgroup/test_6_1.sh | 33
testcases/kernel/controllers/cgroup/test_6_2.c | 50
testcases/kernel/controllers/cgroup/test_9_1.sh | 34
testcases/kernel/controllers/cgroup/test_9_2.sh | 33
16 files changed, 1400 insertions(+)
diff -Nurp ltp-full-20090331.orig/testcases/kernel/controllers/Makefile
ltp-full-20090331/testcases/kernel/controllers/Makefile
--- ltp-full-20090331.orig/testcases/kernel/controllers/Makefile
2009-02-26 15:19:28.000000000 +0800
+++ ltp-full-20090331/testcases/kernel/controllers/Makefile 2009-04-16
14:32:20.000000000 +0800
@@ -1,8 +1,15 @@
+CHECK_CGROUP := $(shell test -f /proc/cgroups && echo 'cgroup')
CHECK_CPUCTL := $(shell grep -w cpu /proc/cgroups 2>/dev/null|cut -f1)
CHECK_MEMCTL := $(shell grep -w memory /proc/cgroups 2>/dev/null|cut -f1)
CHECK_BLOCKIOCTL := $(shell grep -w blockio /proc/cgroups 2>/dev/null|cut -f1)
CHECK_FREEZER := $(shell grep -w freezer /proc/cgroups 2>/dev/null| cut -f1)
+ifeq ($(CHECK_CGROUP),cgroup)
+SUBDIRS += cgroup
+else
+$(info "Kernel is not compiled with control cgroup support")
+endif
+
ifeq ($(CHECK_CPUCTL),cpu)
SUBDIRS += cpuctl
else
diff -Nurp ltp-full-20090331.orig/testcases/kernel/controllers/README
ltp-full-20090331/testcases/kernel/controllers/README
--- ltp-full-20090331.orig/testcases/kernel/controllers/README 2008-05-26
19:30:10.000000000 +0800
+++ ltp-full-20090331/testcases/kernel/controllers/README 2009-04-20
14:30:57.000000000 +0800
@@ -24,6 +24,10 @@ README
------
This file.
+cgroup
+------
+Directory containing the cgroup regression testcases.
+
cpuctl
------
Directory containing the cpu controller testcases. A similar directory will be
created for
diff -Nurp ltp-full-20090331.orig/testcases/kernel/controllers/cgroup/Makefile
ltp-full-20090331/testcases/kernel/controllers/cgroup/Makefile
--- ltp-full-20090331.orig/testcases/kernel/controllers/cgroup/Makefile
1970-01-01 08:00:00.000000000 +0800
+++ ltp-full-20090331/testcases/kernel/controllers/cgroup/Makefile
2009-04-16 14:34:38.000000000 +0800
@@ -0,0 +1,16 @@
+CFLAGS += -Wall
+CPPFLAGS += -I../../../../include -I../libcontrollers
+LDLIBS += -L../../../../lib/ -lltp
+
+SRCS = $(wildcard *.c)
+
+TARGETS = $(patsubst %.c,%,$(SRCS))
+
+all: $(TARGETS)
+
+clean:
+ rm -f $(TARGETS) *.o
+
+install:
+ @set -e; for i in $(TARGETS) *.sh; do ln -f $$i ../../../bin/$$i ;
chmod +x $$i ; done
+
diff -Nurp ltp-full-20090331.orig/testcases/kernel/controllers/cgroup/README
ltp-full-20090331/testcases/kernel/controllers/cgroup/README
--- ltp-full-20090331.orig/testcases/kernel/controllers/cgroup/README
1970-01-01 08:00:00.000000000 +0800
+++ ltp-full-20090331/testcases/kernel/controllers/cgroup/README
2009-04-20 14:34:34.000000000 +0800
@@ -0,0 +1,9 @@
+TEST SUITE:
+
+The directory cgroup contains the tests related to control groups.
+Those testcases can reproduce bugs we found in cgroups.
+
+TESTS AIM:
+
+The aim of the tests is to track any future regressions.
+
diff -Nurp
ltp-full-20090331.orig/testcases/kernel/controllers/cgroup/cgroup_regression_test.sh
ltp-full-20090331/testcases/kernel/controllers/cgroup/cgroup_regression_test.sh
---
ltp-full-20090331.orig/testcases/kernel/controllers/cgroup/cgroup_regression_test.sh
1970-01-01 08:00:00.000000000 +0800
+++
ltp-full-20090331/testcases/kernel/controllers/cgroup/cgroup_regression_test.sh
2009-04-21 11:50:45.000000000 +0800
@@ -0,0 +1,529 @@
+#! /bin/bash
+
+################################################################################
+##
##
+## Copyright (c) 2009 FUJITSU LIMITED
##
+##
##
+## This program is free software; you can redistribute it and#or modify
##
+## it under the terms of the GNU General Public License as published by
##
+## the Free Software Foundation; either version 2 of the License, or
##
+## (at your option) any later version.
##
+##
##
+## This program is distributed in the hope that it will be useful, but
##
+## WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
##
+## or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
##
+## for more details.
##
+##
##
+## You should have received a copy of the GNU General Public License
##
+## along with this program; if not, write to the Free Software
##
+## Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
##
+##
##
+## Author: Li Zefan <[email protected]>
##
+##
##
+################################################################################
+
+cd $LTPROOT/testcases/bin
+
+export TCID="cgroup_regression_test"
+export TST_TOTAL=10
+export TST_COUNT=1
+
+if [ ! -f /proc/cgroups ]; then
+ echo "CONTROLLERS TESTCASES: WARNING"
+ echo "Kernel does not support for control groups";
+ echo "Skipping all controllers testcases....";
+ exit 0
+fi
+
+if [ "$USER" != root ]; then
+ tst_brkm TBROK ignored "Test must be run as root"
+ exit 0
+fi
+
+tst_kvercmp 2 6 29
+if [ $? -eq 0 ]; then
+ tst_brkm TBROK ignored "Test should be run with kernel 2.6.29 or newer"
+ exit 1
+fi
+
+nr_bug=`dmesg | grep -c "kernel BUG"`
+nr_null=`dmesg | grep -c "kernel NULL pointer dereference"`
+nr_warning=`dmesg | grep -c "^WARNING"`
+nr_lockdep=`dmesg | grep -c "possible recursive locking detected"`
+
+# check_kernel_bug - check if some kind of kernel bug happened
+check_kernel_bug()
+{
+ new_bug=`dmesg | grep -c "kernel BUG"`
+ new_null=`dmesg | grep -c "kernel NULL pointer dereference"`
+ new_warning=`dmesg | grep -c "^WARNING"`
+ new_lockdep=`dmesg | grep -c "possible recursive locking detected"`
+
+ # no kernel bug is detected
+ if [ $new_bug -eq $nr_bug -a $new_warning -eq $nr_warning -a \
+ $new_null -eq $nr_null -a $new_lockdep -eq $nr_lockdep ]; then
+ return 1
+ fi
+
+ # some kernel bug is detected
+ if [ $new_bug -gt $nr_bug ]; then
+ tst_resm TFAIL "kernel BUG was detected!"
+ fi
+ if [ $new_warning -gt $nr_warning ]; then
+ tst_resm TFAIL "kernel WARNING was detected!"
+ fi
+ if [ $new_null -gt $nr_null ]; then
+ tst_resm TFAIL "kernel NULL pointer dereference!"
+ fi
+ if [ $new_lockdep -gt $nr_lockdep ]; then
+ tst_resm TFAIL "kernel lockdep warning was detected!"
+ fi
+
+ nr_bug=$new_bug
+ nr_null=$new_null
+ nr_warning=$new_warning
+ nr_lockdep=$new_lockdep
+
+ failed=1
+ return 0
+}
+
+#---------------------------------------------------------------------------
+# Bug: There was a race when keeping forking processes and at the same
+# time cat /cgroup/tasks (should be the very first time to read
+# /cgroup/tasks, otherwise this bug won't be triggered)
+# Kernel: 2.6.24, 2.6.25-rcX
+# Links: http://lkml.org/lkml/2007/10/17/224
+# http://lkml.org/lkml/2008/3/5/332
+# http://lkml.org/lkml/2008/4/16/493
+# Fix: commit 0e04388f0189fa1f6812a8e1cb6172136eada87e
+#---------------------------------------------------------------------------
+test_1()
+{
+ ./fork_processes &
+ sleep 1
+
+ mount -t cgroup xxx cgroup/
+ if [ $? -ne 0 ]; then
+ tst_resm TFAIL "failed to mount cgroup filesystem"
+ failed=1
+ /bin/kill -SIGTERM $!
+ return
+ fi
+ cat cgroup/tasks > /dev/null
+
+ check_kernel_bug
+ if [ $? -eq 1 ]; then
+ tst_resm TPASS "no kernel bug was found"
+ fi
+
+ /bin/kill -SIGTERM $!
+ wait $!
+ umount cgroup/
+}
+
+#---------------------------------------------------------------------------
+# Bug: a cgroup's notify_on_release flag did not inherit from its parent.
+# Kernel: 2.6.24-rcX
+# Links: http://lkml.org/lkml/2008/2/25/12
+# Fix: commit bc231d2a048010d5e0b49ac7fddbfa822fc41109
+#---------------------------------------------------------------------------
+test_2()
+{
+ mount -t cgroup xxx cgroup/
+ if [ $? -ne 0 ]; then
+ tst_resm TFAIL "Failed to mount cgroup filesystem"
+ failed=1
+ return 1
+ fi
+
+ echo 0 > cgroup/notify_on_release
+ mkdir cgroup/0
+ val1=`cat cgroup/0/notify_on_release`
+
+ echo 1 > cgroup/notify_on_release
+ mkdir cgroup/1
+ val2=`cat cgroup/1/notify_on_release`
+
+ if [ $val1 -ne 0 -o $val2 -ne 1 ]; then
+ tst_resm TFAIL "wrong notify_on_release value"
+ failed=1
+ else
+ tst_resm TPASS "notify_on_release is inherited"
+ fi
+
+ rmdir cgroup/0 cgroup/1
+ umount cgroup/
+
+ return $failed
+}
+
+#---------------------------------------------------------------------------
+# Bug: Accessing NULL cgrp->dentry when reading /proc/sched_debug
+# Kernel: 2.6.26-2.6.28
+# Links: http://lkml.org/lkml/2008/10/30/44
+# http://lkml.org/lkml/2008/12/12/107
+# http://lkml.org/lkml/2008/12/16/481
+# Fix: commit a47295e6bc42ad35f9c15ac66f598aa24debd4e2
+#---------------------------------------------------------------------------
+test_3()
+{
+ if [ ! -e /proc/sched_debug ]; then
+ tst_resm TCONF "CONFIG_SCHED_DEBUG is not enabled"
+ return
+ fi
+
+ grep -q -w "cpu" /proc/cgroups
+ if [ $? -ne 0 ]; then
+ tst_resm TCONF "CONFIG_CGROUP_SCHED is not enabled"
+ return
+ fi
+
+ # Run the test for 30 secs
+ mount -t cgroup -o cpu xxx cgroup/
+ if [ $? -ne 0 ]; then
+ tst_resm TFAIL "Failed to mount cpu subsys"
+ failed=1
+ return
+ fi
+
+ ./test_3_1.sh &
+ pid1=$!
+ ./test_3_2.sh &
+ pid2=$!
+
+ sleep 30
+ /bin/kill -SIGUSR1 $pid1 $pid2
+ wait $pid1
+ wait $pid2
+
+ check_kernel_bug
+ if [ $? -eq 1 ]; then
+ tst_resm TPASS "no kernel bug was found"
+ fi
+
+ rmdir cgroup/* 2> /dev/null
+ umount cgroup/
+}
+
+#---------------------------------------------------------------------------
+# Bug: cgroup hierarchy lock's lockdep subclass may overflow
+# Kernel: 2.6.29-rcX
+# Link: http://lkml.org/lkml/2009/2/4/67
+# Fix:
+#---------------------------------------------------------------------------
+test_4()
+{
+ if [ ! -e /proc/lockdep ]; then
+ tst_resm TCONF "CONFIG_LOCKDEP is not enabled"
+ return
+ fi
+
+ # MAX_LOCKDEP_SUBCLASSES is 8, so number of subsys should be > 8
+ lines=`cat /proc/cgroups | wc -l`
+ if [ $lines -le 9 ]; then
+ tst_resm TCONF "require more than 8 cgroup subsystems"
+ return
+ fi
+
+ mount -t cgroup xxx cgroup/
+ mkdir cgroup/0
+ rmdir cgroup/0
+ umount cgroup/
+
+ dmesg | grep -q "MAX_LOCKDEP_SUBCLASSES too low"
+ if [ $? -eq 0 ]; then
+ tst_resm TFAIL "lockdep BUG was found"
+ failed=1
+ return
+ else
+ tst_resm TPASS "no lockdep BUG was found"
+ fi
+}
+
+#---------------------------------------------------------------------------
+# Bug: When mount cgroup fs and the fs was busy, root_count should not be
+# decremented in cgroup_kill_sb()
+# Kernel: 2.6.29-rcX
+# Links: https://openvz.org/pipermail/devel/2009-January/016345.html
+# http://lkml.org/lkml/2009/1/28/190
+# Fix: commit 839ec5452ebfd5905b9c69b20ceb640903a8ea1a
+#---------------------------------------------------------------------------
+test_5()
+{
+ lines=`cat /proc/cgroups | wc -l`
+ if [ $lines -le 2 ]; then
+ tst_resm TCONF "require at least 2 cgroup subsystems"
+ return
+ fi
+
+ subsys1=`tail -1 /proc/cgroups | awk '{ print $1 }'`
+ subsys2=`tail -2 /proc/cgroups | head -1 | awk '{ print $1 }'`
+
+ mount -t cgroup -o $subsys1,$subsys xxx cgroup/
+ if [ $? -ne 0 ]; then
+ tst_resm TFAIL "mount $subsys1 and $subsys2 failed"
+ failed=1
+ return
+ fi
+
+ # This 2nd mount should fail
+ mount -t cgroup -o $subsys1 xxx cgroup/ 2> /dev/null
+ if [ $? -eq 0 ]; then
+ tst_resm TFAIL "mount $subsys1 should fail"
+ umount cgroup/
+ failed=1
+ return
+ fi
+
+ mkdir cgroup/0
+ # Otherwise we can't attach task
+ if [ "$subsys1" == cpuset -o "$subsys2" == cpuset ]; then
+ echo 0 > cgroup/0/cpuset.cpus 2> /dev/null
+ echo 0 > cgroup/0/cpuset.mems 2> /dev/null
+ fi
+
+ sleep 100 &
+ echo $! > cgroup/0/tasks
+
+ check_kernel_bug
+ if [ $? -eq 1 ]; then
+ tst_resm TPASS "no kernel bug was found"
+ fi
+
+ # clean up
+ /bin/kill -SIGTERM $! > /dev/null
+ wait $!
+ rmdir cgroup/0
+ umount cgroup/
+}
+
+#---------------------------------------------------------------------------
+# Bug: There was a race between cgroup_clone and umount
+# Kernel: 2.6.24 - 2.6.28, 2.6.29-rcX
+# Links: http://lkml.org/lkml/2008/12/24/124
+# Fix: commit 7b574b7b0124ed344911f5d581e9bc2d83bbeb19
+#---------------------------------------------------------------------------
+test_6()
+{
+ grep -q -w "ns" /proc/cgroups
+ if [ $? -ne 0 ]; then
+ tst_resm TCONF "CONFIG_CGROUP_NS"
+ return
+ fi
+
+ # run the test for 30 secs
+ ./test_6_1.sh &
+ pid1=$!
+ ./test_6_2 &
+ pid2=$!
+
+ sleep 30
+ /bin/kill -SIGUSR1 $pid1
+ /bin/kill -SIGTERM $pid2
+ wait $pid1
+ wait $pid2
+
+ check_kernel_bug
+ if [ $? -eq 1 ]; then
+ tst_resm TPASS "no kernel bug was found"
+ fi
+
+ # clean up
+ mount -t cgroup -o ns xxx cgroup/ > /dev/null 2>&1
+ rmdir cgroup/[1-9] > /dev/null 2>&1
+ umount cgroup/
+}
+
+#---------------------------------------------------------------------------
+# Bug: There was a bug when remount cgroup fs with some dead subdirs in
+# it (rmdir()ed but still has some refcnts on it). It caused memory
+# leak, and may cause oops when cat /proc/sched_debug.
+# Kernel: 2.6.24 - 2.6.27, 2.6.28-rcX
+# Links: http://lkml.org/lkml/2008/12/10/369
+# Fix: commit 307257cf475aac25db30b669987f13d90c934e3a
+#---------------------------------------------------------------------------
+test_7_1()
+{
+ mount -t cgroup -o $subsys xxx cgroup/
+ if [ $? -ne 0 ]; then
+ tst_resm TFAIL "failed to mount $subsys"
+ failed=1
+ return
+ fi
+
+ mkdir cgroup/0
+ sleep 100 < cgroup/0 & # add refcnt to this dir
+ rmdir cgroup/0
+
+ # remount with new subsystems added
+ # since 2.6.28, this remount will fail
+ mount -t cgroup -o remount xxx cgroup/ 2> /dev/null
+ /bin/kill -SIGTERM $!
+ wait $!
+ umount cgroup/
+}
+
+test_7_2()
+{
+ mount -t cgroup xxx cgroup/
+ if [ $? -ne 0 ]; then
+ tst_resm TFAIL "failed to mount $subsys"
+ failed=1
+ return
+ fi
+
+ mkdir cgroup/0
+ sleep 100 < cgroup/0 & # add refcnt to this dir
+ rmdir cgroup/0
+
+ # remount with some subsystems removed
+ # since 2.6.28, this remount will fail
+ mount -t cgroup -o remount,$subsys xxx cgroup/ 2> /dev/null
+ /bin/kill -SIGTERM $!
+ wait $!
+ umount cgroup/
+
+ # due to the bug, reading /proc/sched_debug may lead to oops
+ grep -q -w "cpu" /proc/cgroups
+ if [ $? -ne 0 -o ! -e /proc/sched_debug ]; then
+ return
+ fi
+
+ for ((tmp = 0; tmp < 50; tmp++))
+ {
+ echo 3 > /proc/sys/vm/drop_caches
+ cat /proc/sched_debug > /dev/null
+ }
+}
+
+test_7()
+{
+ lines=`cat /proc/cgroups | wc -l`
+ if [ $lines -le 2 ]; then
+ tst_resm TCONF "require at least 2 cgroup subsystems"
+ slt_result $SLT_Untested
+ return
+ fi
+
+ subsys=`tail -1 /proc/cgroups | awk '{ print $1 }'`
+
+ # remount to add new subsystems to the hierarchy
+ for ((i = 1; i <= 2; i++))
+ {
+ test_7_$i
+ if [ $? -ne 0 ]; then
+ return
+ fi
+
+ check_kernel_bug
+ if [ $? -eq 0 ]; then
+ return
+ fi
+ }
+
+ tst_resm TPASS "no kernel bug was found"
+}
+
+#---------------------------------------------------------------------------
+# Bug: oops when get cgroupstat of a cgroup control file
+# Kernel: 2.6.24 - 2.6.27, 2.6.28-rcX
+# Links: http://lkml.org/lkml/2008/11/19/53
+# Fix: commit 33d283bef23132c48195eafc21449f8ba88fce6b
+#---------------------------------------------------------------------------
+test_8()
+{
+ mount -t cgroup xxx cgroup/
+ if [ $? -ne 0 ]; then
+ tst_resm TFAIL "failed to mount cgroup filesystem"
+ failed=1
+ return
+ fi
+
+ ./getdelays -C cgroup/tasks > /dev/null 2>&1
+ if [ $? -eq 0 ]; then
+ tst_resm TFAIL "should have failed to get cgroupstat of tasks
file"
+ umount cgroup/
+ failed=1
+ return
+ fi
+
+ check_kernel_bug
+ if [ $? -eq 1 ]; then
+ tst_resm TPASS "no kernel bug was found"
+ fi
+
+ umount cgroup/
+}
+
+#---------------------------------------------------------------------------
+# Bug: When running 2 concurrent mount/umount threads, lockdep warning
+# may be triggered, it's a false positive, and it's VFS' issue but
+# not cgroup.
+# Kernel: 2.6.24 - 2.6.29-rcX
+# Links: http://lkml.org/lkml/2009/1/4/352
+# Fix: commit ada723dcd681e2dffd7d73345cc8fda0eb0df9bd
+#---------------------------------------------------------------------------
+test_9()
+{
+ ./test_9_1.sh &
+ pid1=$!
+ ./test_9_2.sh &
+ pid2=$!
+
+ sleep 30
+ /bin/kill -SIGUSR1 $pid1 $pid2
+ wait $pid1
+ wait $pid2
+
+ umount cgroup/ 2> /dev/null
+
+ check_kernel_bug
+ if [ $? -eq 1 ]; then
+ tst_resm TPASS "no kernel warning was found"
+ fi
+}
+
+#---------------------------------------------------------------------------
+# Bug: When running 2 concurrent mount/umount threads, kernel WARNING
+# may be triggered, but it's VFS' issue but not cgroup.
+# Kernel: 2.6.24 - 2.6.29-rcX
+# Links: http://lkml.org/lkml/2009/1/4/354
+# Fix: commit 1a88b5364b535edaa321d70a566e358390ff0872
+#---------------------------------------------------------------------------
+test_10()
+{
+ ./test_10_1.sh &
+ pid1=$!
+ ./test_10_2.sh &
+ pid2=$!
+
+ sleep 30
+ /bin/kill -SIGUSR1 $pid1 $pid2
+ wait $pid1
+ wait $pid2
+
+ rmdir cgroup/0 2> /dev/null
+ umount cgroup/ 2> /dev/null
+
+ check_kernel_bug
+ if [ $? -eq 1 ]; then
+ tst_resm TPASS "no kernel warning was found"
+ fi
+}
+
+# main
+
+mkdir cgroup/
+
+for ((cur = 1; cur <= $TST_TOTAL; cur++))
+{
+ export TST_COUNT=$cur
+
+ test_$cur
+}
+
+rmdir cgroup/
+
+exit $failed
+
diff -Nurp
ltp-full-20090331.orig/testcases/kernel/controllers/cgroup/fork_processes.c
ltp-full-20090331/testcases/kernel/controllers/cgroup/fork_processes.c
--- ltp-full-20090331.orig/testcases/kernel/controllers/cgroup/fork_processes.c
1970-01-01 08:00:00.000000000 +0800
+++ ltp-full-20090331/testcases/kernel/controllers/cgroup/fork_processes.c
2009-04-21 11:30:19.000000000 +0800
@@ -0,0 +1,50 @@
+/******************************************************************************/
+/*
*/
+/* Copyright (c) 2009 FUJITSU LIMITED
*/
+/*
*/
+/* This program is free software; you can redistribute it and/or modify
*/
+/* it under the terms of the GNU General Public License as published by
*/
+/* the Free Software Foundation; either version 2 of the License, or
*/
+/* (at your option) any later version.
*/
+/*
*/
+/* This program is distributed in the hope that it will be useful,
*/
+/* but WITHOUT ANY WARRANTY; without even the implied warranty of
*/
+/* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See
*/
+/* the GNU General Public License for more details.
*/
+/*
*/
+/* You should have received a copy of the GNU General Public License
*/
+/* along with this program; if not, write to the Free Software
*/
+/* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
+/*
*/
+/* Author: Li Zefan <[email protected]>
*/
+/*
*/
+/******************************************************************************/
+
+#include <unistd.h>
+#include <stdlib.h>
+#include <sys/types.h>
+#include <sys/wait.h>
+
+int main(void)
+{
+ int i;
+ int pid;
+
+ while (1) {
+ for (i = 0; i < 200; i++) {
+ pid = fork();
+ if (pid == 0) {
+ return 0;
+ } else if (pid < 0) {
+ continue;
+ }
+ }
+
+ for (i = 0; i < 200; i++)
+ if (wait(NULL) < 0)
+ break;
+ }
+
+ return 0;
+}
+
diff -Nurp
ltp-full-20090331.orig/testcases/kernel/controllers/cgroup/getdelays.c
ltp-full-20090331/testcases/kernel/controllers/cgroup/getdelays.c
--- ltp-full-20090331.orig/testcases/kernel/controllers/cgroup/getdelays.c
1970-01-01 08:00:00.000000000 +0800
+++ ltp-full-20090331/testcases/kernel/controllers/cgroup/getdelays.c
2009-04-16 14:26:55.000000000 +0800
@@ -0,0 +1,505 @@
+/* getdelays.c
+ *
+ * Utility to get per-pid and per-tgid delay accounting statistics
+ * Also illustrates usage of the taskstats interface
+ *
+ * Copyright (C) Shailabh Nagar, IBM Corp. 2005
+ * Copyright (C) Balbir Singh, IBM Corp. 2006
+ * Copyright (c) Jay Lan, SGI. 2006
+ *
+ * Compile with
+ * gcc -I/usr/src/linux/include getdelays.c -o getdelays
+ */
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <errno.h>
+#include <unistd.h>
+#include <poll.h>
+#include <string.h>
+#include <fcntl.h>
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <sys/socket.h>
+#include <signal.h>
+
+#include <linux/genetlink.h>
+#include <linux/taskstats.h>
+#include <linux/cgroupstats.h>
+
+/*
+ * Generic macros for dealing with netlink sockets. Might be duplicated
+ * elsewhere. It is recommended that commercial grade applications use
+ * libnl or libnetlink and use the interfaces provided by the library
+ */
+#define GENLMSG_DATA(glh) ((void *)(NLMSG_DATA(glh) + GENL_HDRLEN))
+#define GENLMSG_PAYLOAD(glh) (NLMSG_PAYLOAD(glh, 0) - GENL_HDRLEN)
+#define NLA_DATA(na) ((void *)((char*)(na) + NLA_HDRLEN))
+#define NLA_PAYLOAD(len) (len - NLA_HDRLEN)
+
+#define err(code, fmt, arg...) \
+ do { \
+ fprintf(stderr, fmt, ##arg); \
+ exit(code); \
+ } while (0)
+
+int done;
+int rcvbufsz;
+char name[100];
+int dbg;
+int print_delays;
+int print_io_accounting;
+int print_task_context_switch_counts;
+__u64 stime, utime;
+
+#define PRINTF(fmt, arg...) { \
+ if (dbg) { \
+ printf(fmt, ##arg); \
+ } \
+ }
+
+/* Maximum size of response requested or message sent */
+#define MAX_MSG_SIZE 1024
+/* Maximum number of cpus expected to be specified in a cpumask */
+#define MAX_CPUS 32
+
+struct msgtemplate {
+ struct nlmsghdr n;
+ struct genlmsghdr g;
+ char buf[MAX_MSG_SIZE];
+};
+
+char cpumask[100+6*MAX_CPUS];
+
+static void usage(void)
+{
+ fprintf(stderr, "getdelays [-dilv] [-w logfile] [-r bufsize] "
+ "[-m cpumask] [-t tgid] [-p pid]\n");
+ fprintf(stderr, " -d: print delayacct stats\n");
+ fprintf(stderr, " -i: print IO accounting (works only with -p)\n");
+ fprintf(stderr, " -l: listen forever\n");
+ fprintf(stderr, " -v: debug on\n");
+ fprintf(stderr, " -C: container path\n");
+}
+
+/*
+ * Create a raw netlink socket and bind
+ */
+static int create_nl_socket(int protocol)
+{
+ int fd;
+ struct sockaddr_nl local;
+
+ fd = socket(AF_NETLINK, SOCK_RAW, protocol);
+ if (fd < 0)
+ return -1;
+
+ if (rcvbufsz)
+ if (setsockopt(fd, SOL_SOCKET, SO_RCVBUF,
+ &rcvbufsz, sizeof(rcvbufsz)) < 0) {
+ fprintf(stderr, "Unable to set socket rcv buf size "
+ "to %d\n",
+ rcvbufsz);
+ return -1;
+ }
+
+ memset(&local, 0, sizeof(local));
+ local.nl_family = AF_NETLINK;
+
+ if (bind(fd, (struct sockaddr *) &local, sizeof(local)) < 0)
+ goto error;
+
+ return fd;
+error:
+ close(fd);
+ return -1;
+}
+
+
+int send_cmd(int sd, __u16 nlmsg_type, __u32 nlmsg_pid,
+ __u8 genl_cmd, __u16 nla_type,
+ void *nla_data, int nla_len)
+{
+ struct nlattr *na;
+ struct sockaddr_nl nladdr;
+ int r, buflen;
+ char *buf;
+
+ struct msgtemplate msg;
+
+ msg.n.nlmsg_len = NLMSG_LENGTH(GENL_HDRLEN);
+ msg.n.nlmsg_type = nlmsg_type;
+ msg.n.nlmsg_flags = NLM_F_REQUEST;
+ msg.n.nlmsg_seq = 0;
+ msg.n.nlmsg_pid = nlmsg_pid;
+ msg.g.cmd = genl_cmd;
+ msg.g.version = 0x1;
+ na = (struct nlattr *) GENLMSG_DATA(&msg);
+ na->nla_type = nla_type;
+ na->nla_len = nla_len + 1 + NLA_HDRLEN;
+ memcpy(NLA_DATA(na), nla_data, nla_len);
+ msg.n.nlmsg_len += NLMSG_ALIGN(na->nla_len);
+
+ buf = (char *) &msg;
+ buflen = msg.n.nlmsg_len ;
+ memset(&nladdr, 0, sizeof(nladdr));
+ nladdr.nl_family = AF_NETLINK;
+ while ((r = sendto(sd, buf, buflen, 0, (struct sockaddr *) &nladdr,
+ sizeof(nladdr))) < buflen) {
+ if (r > 0) {
+ buf += r;
+ buflen -= r;
+ } else if (errno != EAGAIN)
+ return -1;
+ }
+ return 0;
+}
+
+
+/*
+ * Probe the controller in genetlink to find the family id
+ * for the TASKSTATS family
+ */
+int get_family_id(int sd)
+{
+ struct {
+ struct nlmsghdr n;
+ struct genlmsghdr g;
+ char buf[256];
+ } ans;
+
+ int id = 0, rc;
+ struct nlattr *na;
+ int rep_len;
+
+ strcpy(name, TASKSTATS_GENL_NAME);
+ rc = send_cmd(sd, GENL_ID_CTRL, getpid(), CTRL_CMD_GETFAMILY,
+ CTRL_ATTR_FAMILY_NAME, (void *)name,
+ strlen(TASKSTATS_GENL_NAME)+1);
+
+ rep_len = recv(sd, &ans, sizeof(ans), 0);
+ if (ans.n.nlmsg_type == NLMSG_ERROR ||
+ (rep_len < 0) || !NLMSG_OK((&ans.n), rep_len))
+ return 0;
+
+ na = (struct nlattr *) GENLMSG_DATA(&ans);
+ na = (struct nlattr *) ((char *) na + NLA_ALIGN(na->nla_len));
+ if (na->nla_type == CTRL_ATTR_FAMILY_ID) {
+ id = *(__u16 *) NLA_DATA(na);
+ }
+ return id;
+}
+
+void print_delayacct(struct taskstats *t)
+{
+ printf("\n\nCPU %15s%15s%15s%15s\n"
+ " %15llu%15llu%15llu%15llu\n"
+ "IO %15s%15s\n"
+ " %15llu%15llu\n"
+ "SWAP %15s%15s\n"
+ " %15llu%15llu\n"
+ "RECLAIM %12s%15s\n"
+ " %15llu%15llu\n",
+ "count", "real total", "virtual total", "delay total",
+ (unsigned long long)t->cpu_count,
+ (unsigned long long)t->cpu_run_real_total,
+ (unsigned long long)t->cpu_run_virtual_total,
+ (unsigned long long)t->cpu_delay_total,
+ "count", "delay total",
+ (unsigned long long)t->blkio_count,
+ (unsigned long long)t->blkio_delay_total,
+ "count", "delay total",
+ (unsigned long long)t->swapin_count,
+ (unsigned long long)t->swapin_delay_total,
+ "count", "delay total",
+ (unsigned long long)t->freepages_count,
+ (unsigned long long)t->freepages_delay_total);
+}
+
+void task_context_switch_counts(struct taskstats *t)
+{
+ printf("\n\nTask %15s%15s\n"
+ " %15llu%15llu\n",
+ "voluntary", "nonvoluntary",
+ (unsigned long long)t->nvcsw, (unsigned long long)t->nivcsw);
+}
+
+void print_cgroupstats(struct cgroupstats *c)
+{
+ printf("sleeping %llu, blocked %llu, running %llu, stopped %llu, "
+ "uninterruptible %llu\n", (unsigned long long)c->nr_sleeping,
+ (unsigned long long)c->nr_io_wait,
+ (unsigned long long)c->nr_running,
+ (unsigned long long)c->nr_stopped,
+ (unsigned long long)c->nr_uninterruptible);
+}
+
+
+void print_ioacct(struct taskstats *t)
+{
+ printf("%s: read=%llu, write=%llu, cancelled_write=%llu\n",
+ t->ac_comm,
+ (unsigned long long)t->read_bytes,
+ (unsigned long long)t->write_bytes,
+ (unsigned long long)t->cancelled_write_bytes);
+}
+
+int main(int argc, char *argv[])
+{
+ int c, rc, rep_len, aggr_len, len2, cmd_type;
+ __u16 id;
+ __u32 mypid;
+
+ struct nlattr *na;
+ int nl_sd = -1;
+ int len = 0;
+ pid_t tid = 0;
+ pid_t rtid = 0;
+
+ int fd = 0;
+ int count = 0;
+ int write_file = 0;
+ int maskset = 0;
+ char *logfile = NULL;
+ int loop = 0;
+ int containerset = 0;
+ char containerpath[1024];
+ int cfd = 0;
+
+ struct msgtemplate msg;
+
+ while (1) {
+ c = getopt(argc, argv, "qdiw:r:m:t:p:vlC:");
+ if (c < 0)
+ break;
+
+ switch (c) {
+ case 'd':
+ printf("print delayacct stats ON\n");
+ print_delays = 1;
+ break;
+ case 'i':
+ printf("printing IO accounting\n");
+ print_io_accounting = 1;
+ break;
+ case 'q':
+ printf("printing task/process context switch rates\n");
+ print_task_context_switch_counts = 1;
+ break;
+ case 'C':
+ containerset = 1;
+ strncpy(containerpath, optarg, strlen(optarg) + 1);
+ break;
+ case 'w':
+ logfile = strdup(optarg);
+ printf("write to file %s\n", logfile);
+ write_file = 1;
+ break;
+ case 'r':
+ rcvbufsz = atoi(optarg);
+ printf("receive buf size %d\n", rcvbufsz);
+ if (rcvbufsz < 0)
+ err(1, "Invalid rcv buf size\n");
+ break;
+ case 'm':
+ strncpy(cpumask, optarg, sizeof(cpumask));
+ maskset = 1;
+ printf("cpumask %s maskset %d\n", cpumask, maskset);
+ break;
+ case 't':
+ tid = atoi(optarg);
+ if (!tid)
+ err(1, "Invalid tgid\n");
+ cmd_type = TASKSTATS_CMD_ATTR_TGID;
+ break;
+ case 'p':
+ tid = atoi(optarg);
+ if (!tid)
+ err(1, "Invalid pid\n");
+ cmd_type = TASKSTATS_CMD_ATTR_PID;
+ break;
+ case 'v':
+ printf("debug on\n");
+ dbg = 1;
+ break;
+ case 'l':
+ printf("listen forever\n");
+ loop = 1;
+ break;
+ default:
+ usage();
+ exit(1);
+ }
+ }
+
+ if (write_file) {
+ fd = open(logfile, O_WRONLY | O_CREAT | O_TRUNC,
+ S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH);
+ if (fd == -1) {
+ perror("Cannot open output file\n");
+ exit(1);
+ }
+ }
+
+ if ((nl_sd = create_nl_socket(NETLINK_GENERIC)) < 0)
+ err(1, "error creating Netlink socket\n");
+
+
+ mypid = getpid();
+ id = get_family_id(nl_sd);
+ if (!id) {
+ fprintf(stderr, "Error getting family id, errno %d\n", errno);
+ exit(1);
+ }
+ PRINTF("family id %d\n", id);
+
+ if (maskset) {
+ rc = send_cmd(nl_sd, id, mypid, TASKSTATS_CMD_GET,
+ TASKSTATS_CMD_ATTR_REGISTER_CPUMASK,
+ &cpumask, strlen(cpumask) + 1);
+ PRINTF("Sent register cpumask, retval %d\n", rc);
+ if (rc < 0) {
+ fprintf(stderr, "error sending register cpumask\n");
+ exit(1);
+ }
+ }
+
+ if (tid && containerset) {
+ fprintf(stderr, "Select either -t or -C, not both\n");
+ exit(1);
+ }
+
+ if (tid) {
+ rc = send_cmd(nl_sd, id, mypid, TASKSTATS_CMD_GET,
+ cmd_type, &tid, sizeof(__u32));
+ PRINTF("Sent pid/tgid, retval %d\n", rc);
+ if (rc < 0) {
+ fprintf(stderr, "error sending tid/tgid cmd\n");
+ exit(1);
+ }
+ }
+
+ if (containerset) {
+ cfd = open(containerpath, O_RDONLY);
+ if (cfd < 0) {
+ perror("error opening container file");
+ exit(1);
+ }
+ rc = send_cmd(nl_sd, id, mypid, CGROUPSTATS_CMD_GET,
+ CGROUPSTATS_CMD_ATTR_FD, &cfd, sizeof(__u32));
+ if (rc < 0) {
+ perror("error sending cgroupstats command");
+ exit(1);
+ }
+ }
+ if (!maskset && !tid && !containerset) {
+ usage();
+ exit(1);
+ }
+
+ do {
+ int i;
+
+ rep_len = recv(nl_sd, &msg, sizeof(msg), 0);
+ PRINTF("received %d bytes\n", rep_len);
+
+ if (rep_len < 0) {
+ fprintf(stderr, "nonfatal reply error: errno %d\n",
+ errno);
+ exit(1);
+ }
+ if (msg.n.nlmsg_type == NLMSG_ERROR ||
+ !NLMSG_OK((&msg.n), rep_len)) {
+ struct nlmsgerr *err = NLMSG_DATA(&msg);
+ fprintf(stderr, "fatal reply error, errno %d\n",
+ err->error);
+ exit(1);
+ }
+
+ PRINTF("nlmsghdr size=%zu, nlmsg_len=%d, rep_len=%d\n",
+ sizeof(struct nlmsghdr), msg.n.nlmsg_len, rep_len);
+
+
+ rep_len = GENLMSG_PAYLOAD(&msg.n);
+
+ na = (struct nlattr *) GENLMSG_DATA(&msg);
+ len = 0;
+ i = 0;
+ while (len < rep_len) {
+ len += NLA_ALIGN(na->nla_len);
+ switch (na->nla_type) {
+ case TASKSTATS_TYPE_AGGR_TGID:
+ /* Fall through */
+ case TASKSTATS_TYPE_AGGR_PID:
+ aggr_len = NLA_PAYLOAD(na->nla_len);
+ len2 = 0;
+ /* For nested attributes, na follows */
+ na = (struct nlattr *) NLA_DATA(na);
+ done = 0;
+ while (len2 < aggr_len) {
+ switch (na->nla_type) {
+ case TASKSTATS_TYPE_PID:
+ rtid = *(int *) NLA_DATA(na);
+ if (print_delays)
+ printf("PID\t%d\n",
rtid);
+ break;
+ case TASKSTATS_TYPE_TGID:
+ rtid = *(int *) NLA_DATA(na);
+ if (print_delays)
+ printf("TGID\t%d\n",
rtid);
+ break;
+ case TASKSTATS_TYPE_STATS:
+ count++;
+ if (print_delays)
+ print_delayacct((struct
taskstats *) NLA_DATA(na));
+ if (print_io_accounting)
+ print_ioacct((struct
taskstats *) NLA_DATA(na));
+ if
(print_task_context_switch_counts)
+
task_context_switch_counts((struct taskstats *) NLA_DATA(na));
+ if (fd) {
+ if (write(fd,
NLA_DATA(na), na->nla_len) < 0) {
+ err(1,"write
error\n");
+ }
+ }
+ if (!loop)
+ goto done;
+ break;
+ default:
+ fprintf(stderr, "Unknown nested"
+ " nla_type %d\n",
+ na->nla_type);
+ break;
+ }
+ len2 += NLA_ALIGN(na->nla_len);
+ na = (struct nlattr *) ((char *) na +
len2);
+ }
+ break;
+
+ case CGROUPSTATS_TYPE_CGROUP_STATS:
+ print_cgroupstats(NLA_DATA(na));
+ break;
+ default:
+ fprintf(stderr, "Unknown nla_type %d\n",
+ na->nla_type);
+ exit(1);
+ }
+ na = (struct nlattr *) (GENLMSG_DATA(&msg) + len);
+ }
+ } while (loop);
+done:
+ if (maskset) {
+ rc = send_cmd(nl_sd, id, mypid, TASKSTATS_CMD_GET,
+ TASKSTATS_CMD_ATTR_DEREGISTER_CPUMASK,
+ &cpumask, strlen(cpumask) + 1);
+ printf("Sent deregister mask, retval %d\n", rc);
+ if (rc < 0)
+ err(rc, "error sending deregister cpumask\n");
+ }
+
+ close(nl_sd);
+ if (fd)
+ close(fd);
+ if (cfd)
+ close(cfd);
+ return 0;
+}
diff -Nurp
ltp-full-20090331.orig/testcases/kernel/controllers/cgroup/test_10_1.sh
ltp-full-20090331/testcases/kernel/controllers/cgroup/test_10_1.sh
--- ltp-full-20090331.orig/testcases/kernel/controllers/cgroup/test_10_1.sh
1970-01-01 08:00:00.000000000 +0800
+++ ltp-full-20090331/testcases/kernel/controllers/cgroup/test_10_1.sh
2009-04-21 09:12:08.000000000 +0800
@@ -0,0 +1,34 @@
+#! /bin/bash
+
+################################################################################
+##
##
+## Copyright (c) 2009 FUJITSU LIMITED
##
+##
##
+## This program is free software; you can redistribute it and#or modify
##
+## it under the terms of the GNU General Public License as published by
##
+## the Free Software Foundation; either version 2 of the License, or
##
+## (at your option) any later version.
##
+##
##
+## This program is distributed in the hope that it will be useful, but
##
+## WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
##
+## or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
##
+## for more details.
##
+##
##
+## You should have received a copy of the GNU General Public License
##
+## along with this program; if not, write to the Free Software
##
+## Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
##
+##
##
+## Author: Li Zefan <[email protected]>
##
+##
##
+################################################################################
+
+for ((; ;))
+{
+ mount -t cgroup xxx cgroup/ > /dev/null 2>&1
+ mkdir cgroup/0 > /dev/null 2>&1
+ rmdir cgroup/0 > /dev/null 2>&1
+ umount cgroup/ > /dev/null 2>&1
+
+ trap exit SIGUSR1
+}
+
diff -Nurp
ltp-full-20090331.orig/testcases/kernel/controllers/cgroup/test_10_2.sh
ltp-full-20090331/testcases/kernel/controllers/cgroup/test_10_2.sh
--- ltp-full-20090331.orig/testcases/kernel/controllers/cgroup/test_10_2.sh
1970-01-01 08:00:00.000000000 +0800
+++ ltp-full-20090331/testcases/kernel/controllers/cgroup/test_10_2.sh
2009-04-21 09:12:25.000000000 +0800
@@ -0,0 +1,32 @@
+#! /bin/bash
+
+################################################################################
+##
##
+## Copyright (c) 2009 FUJITSU LIMITED
##
+##
##
+## This program is free software; you can redistribute it and#or modify
##
+## it under the terms of the GNU General Public License as published by
##
+## the Free Software Foundation; either version 2 of the License, or
##
+## (at your option) any later version.
##
+##
##
+## This program is distributed in the hope that it will be useful, but
##
+## WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
##
+## or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
##
+## for more details.
##
+##
##
+## You should have received a copy of the GNU General Public License
##
+## along with this program; if not, write to the Free Software
##
+## Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
##
+##
##
+## Author: Li Zefan <[email protected]>
##
+##
##
+################################################################################
+
+for ((; ;))
+{
+ mount -t cgroup xxx cgroup/ > /dev/null 2>&1
+ umount cgroup/ > /dev/null 2>&1
+
+ trap exit SIGUSR1
+}
+
diff -Nurp
ltp-full-20090331.orig/testcases/kernel/controllers/cgroup/test_3_1.sh
ltp-full-20090331/testcases/kernel/controllers/cgroup/test_3_1.sh
--- ltp-full-20090331.orig/testcases/kernel/controllers/cgroup/test_3_1.sh
1970-01-01 08:00:00.000000000 +0800
+++ ltp-full-20090331/testcases/kernel/controllers/cgroup/test_3_1.sh
2009-04-21 09:12:39.000000000 +0800
@@ -0,0 +1,32 @@
+#! /bin/bash
+
+################################################################################
+##
##
+## Copyright (c) 2009 FUJITSU LIMITED
##
+##
##
+## This program is free software; you can redistribute it and#or modify
##
+## it under the terms of the GNU General Public License as published by
##
+## the Free Software Foundation; either version 2 of the License, or
##
+## (at your option) any later version.
##
+##
##
+## This program is distributed in the hope that it will be useful, but
##
+## WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
##
+## or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
##
+## for more details.
##
+##
##
+## You should have received a copy of the GNU General Public License
##
+## along with this program; if not, write to the Free Software
##
+## Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
##
+##
##
+## Author: Li Zefan <[email protected]>
##
+##
##
+################################################################################
+
+for ((; ;))
+{
+ mkdir cgroup/0
+ rmdir cgroup/0
+
+ trap exit SIGUSR1
+}
+
diff -Nurp
ltp-full-20090331.orig/testcases/kernel/controllers/cgroup/test_3_2.sh
ltp-full-20090331/testcases/kernel/controllers/cgroup/test_3_2.sh
--- ltp-full-20090331.orig/testcases/kernel/controllers/cgroup/test_3_2.sh
1970-01-01 08:00:00.000000000 +0800
+++ ltp-full-20090331/testcases/kernel/controllers/cgroup/test_3_2.sh
2009-04-21 09:12:49.000000000 +0800
@@ -0,0 +1,31 @@
+#! /bin/bash
+
+################################################################################
+##
##
+## Copyright (c) 2009 FUJITSU LIMITED
##
+##
##
+## This program is free software; you can redistribute it and#or modify
##
+## it under the terms of the GNU General Public License as published by
##
+## the Free Software Foundation; either version 2 of the License, or
##
+## (at your option) any later version.
##
+##
##
+## This program is distributed in the hope that it will be useful, but
##
+## WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
##
+## or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
##
+## for more details.
##
+##
##
+## You should have received a copy of the GNU General Public License
##
+## along with this program; if not, write to the Free Software
##
+## Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
##
+##
##
+## Author: Li Zefan <[email protected]>
##
+##
##
+################################################################################
+
+for ((; ;))
+{
+ cat /proc/sched_debug > /dev/null
+
+ trap exit SIGUSR1
+}
+
diff -Nurp
ltp-full-20090331.orig/testcases/kernel/controllers/cgroup/test_6_1.sh
ltp-full-20090331/testcases/kernel/controllers/cgroup/test_6_1.sh
--- ltp-full-20090331.orig/testcases/kernel/controllers/cgroup/test_6_1.sh
1970-01-01 08:00:00.000000000 +0800
+++ ltp-full-20090331/testcases/kernel/controllers/cgroup/test_6_1.sh
2009-04-21 09:13:04.000000000 +0800
@@ -0,0 +1,33 @@
+#! /bin/bash
+
+################################################################################
+##
##
+## Copyright (c) 2009 FUJITSU LIMITED
##
+##
##
+## This program is free software; you can redistribute it and#or modify
##
+## it under the terms of the GNU General Public License as published by
##
+## the Free Software Foundation; either version 2 of the License, or
##
+## (at your option) any later version.
##
+##
##
+## This program is distributed in the hope that it will be useful, but
##
+## WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
##
+## or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
##
+## for more details.
##
+##
##
+## You should have received a copy of the GNU General Public License
##
+## along with this program; if not, write to the Free Software
##
+## Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
##
+##
##
+## Author: Li Zefan <[email protected]>
##
+##
##
+################################################################################
+
+for ((; ;))
+{
+ mount -t cgroup -o ns xxx cgroup/ > /dev/null 2>&1
+ rmdir cgroup/[1-9]* > /dev/null 2>&1
+ umount cgroup/ > /dev/null 2>&1
+
+ trap exit SIGUSR1
+}
+
diff -Nurp
ltp-full-20090331.orig/testcases/kernel/controllers/cgroup/test_6_2.c
ltp-full-20090331/testcases/kernel/controllers/cgroup/test_6_2.c
--- ltp-full-20090331.orig/testcases/kernel/controllers/cgroup/test_6_2.c
1970-01-01 08:00:00.000000000 +0800
+++ ltp-full-20090331/testcases/kernel/controllers/cgroup/test_6_2.c
2009-04-21 11:30:35.000000000 +0800
@@ -0,0 +1,50 @@
+/******************************************************************************/
+/*
*/
+/* Copyright (c) 2009 FUJITSU LIMITED
*/
+/*
*/
+/* This program is free software; you can redistribute it and/or modify
*/
+/* it under the terms of the GNU General Public License as published by
*/
+/* the Free Software Foundation; either version 2 of the License, or
*/
+/* (at your option) any later version.
*/
+/*
*/
+/* This program is distributed in the hope that it will be useful,
*/
+/* but WITHOUT ANY WARRANTY; without even the implied warranty of
*/
+/* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See
*/
+/* the GNU General Public License for more details.
*/
+/*
*/
+/* You should have received a copy of the GNU General Public License
*/
+/* along with this program; if not, write to the Free Software
*/
+/* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
+/*
*/
+/* Author: Li Zefan <[email protected]>
*/
+/*
*/
+/******************************************************************************/
+
+#include <stdlib.h>
+#include <unistd.h>
+#include <sched.h>
+
+#define DEFAULT_USEC 30000
+
+int foo(void __attribute__((unused)) *arg)
+{
+ return 0;
+}
+
+char *stack[4096];
+
+int main(int argc, char **argv)
+{
+ int usec = DEFAULT_USEC;
+
+ if (argc == 2)
+ usec = atoi(argv[1]);
+
+ while (1) {
+ usleep(usec);
+ clone(foo, stack+4096, CLONE_NEWNS, NULL);
+ }
+
+ return 0;
+}
+
diff -Nurp
ltp-full-20090331.orig/testcases/kernel/controllers/cgroup/test_9_1.sh
ltp-full-20090331/testcases/kernel/controllers/cgroup/test_9_1.sh
--- ltp-full-20090331.orig/testcases/kernel/controllers/cgroup/test_9_1.sh
1970-01-01 08:00:00.000000000 +0800
+++ ltp-full-20090331/testcases/kernel/controllers/cgroup/test_9_1.sh
2009-04-21 09:13:22.000000000 +0800
@@ -0,0 +1,34 @@
+#! /bin/bash
+
+################################################################################
+##
##
+## Copyright (c) 2009 FUJITSU LIMITED
##
+##
##
+## This program is free software; you can redistribute it and#or modify
##
+## it under the terms of the GNU General Public License as published by
##
+## the Free Software Foundation; either version 2 of the License, or
##
+## (at your option) any later version.
##
+##
##
+## This program is distributed in the hope that it will be useful, but
##
+## WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
##
+## or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
##
+## for more details.
##
+##
##
+## You should have received a copy of the GNU General Public License
##
+## along with this program; if not, write to the Free Software
##
+## Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
##
+##
##
+## Author: Li Zefan <[email protected]>
##
+##
##
+################################################################################
+
+for ((; ;))
+{
+# mount -t cgroup -o debug xxx cgroup/ > /dev/null 2>&1
+ mount -t cgroup xxx cgroup/ > /dev/null 2>&1
+ cat cgroup/release_agent > /dev/null 2>&1
+ umount cgroup/ > /dev/null 2>&1
+
+ trap exit SIGUSR1
+}
+
diff -Nurp
ltp-full-20090331.orig/testcases/kernel/controllers/cgroup/test_9_2.sh
ltp-full-20090331/testcases/kernel/controllers/cgroup/test_9_2.sh
--- ltp-full-20090331.orig/testcases/kernel/controllers/cgroup/test_9_2.sh
1970-01-01 08:00:00.000000000 +0800
+++ ltp-full-20090331/testcases/kernel/controllers/cgroup/test_9_2.sh
2009-04-21 09:13:34.000000000 +0800
@@ -0,0 +1,33 @@
+#! /bin/bash
+
+################################################################################
+##
##
+## Copyright (c) 2009 FUJITSU LIMITED
##
+##
##
+## This program is free software; you can redistribute it and#or modify
##
+## it under the terms of the GNU General Public License as published by
##
+## the Free Software Foundation; either version 2 of the License, or
##
+## (at your option) any later version.
##
+##
##
+## This program is distributed in the hope that it will be useful, but
##
+## WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
##
+## or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
##
+## for more details.
##
+##
##
+## You should have received a copy of the GNU General Public License
##
+## along with this program; if not, write to the Free Software
##
+## Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
##
+##
##
+## Author: Li Zefan <[email protected]>
##
+##
##
+################################################################################
+
+for ((; ;))
+{
+# mount -t cgroup -o debug xxx cgroup/ > /dev/null 2>&1
+ mount -t cgroup xxx cgroup/ > /dev/null 2>&1
+ umount cgroup/ > /dev/null 2>&1
+
+ trap exit SIGUSR1
+}
+
diff -Nurp ltp-full-20090331.orig/runtest/controllers
ltp-full-20090331/runtest/controllers
--- ltp-full-20090331.orig/runtest/controllers 2008-02-28 22:06:13.000000000
+0800
+++ ltp-full-20090331/runtest/controllers 2009-04-20 14:24:26.000000000
+0800
@@ -1,2 +1,3 @@
#DESCRIPTION:Resource Management testing
+cgroup cgroup_regression_test.sh
controllers test_controllers.sh
------------------------------------------------------------------------------
Stay on top of everything new and different, both inside and
around Java (TM) technology - register by April 22, and save
$200 on the JavaOne (SM) conference, June 2-5, 2009, San Francisco.
300 plus technical and hands-on sessions. Register today.
Use priority code J9JMT32. http://p.sf.net/sfu/p
_______________________________________________
Ltp-list mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/ltp-list