CPU Accounting Controller test case for LTP.
Hi, I have developed a testcase for CPU Accounting Controller which is used to group tasks using cgroups and account the CPU usage of these groups of tasks.
Here I am posting the patch, please review the patch and let me know if it needs any changes, thanks.
/testcases/kernel/controllers/cpuacct/cpuacct_task.c +18 -0
@@ -0,0 +1,18 @@ +#include <stdio.h> + +int main (void ) +{ +FILE *fp; + +while (1 ) + { + + fp=fopen ("txt.x" ,"w" ); +fclose (fp); + + } + +return 0 ; +} + +
/testcases/kernel/controllers/cpuacct/cpuacct_testplan.txt +44 -0
44 lines not on this page · raw message
/testcases/kernel/controllers/cpuacct/Makefile +16 -0
@@ -0,0 +1,16 @@ +CFLAGS += -Wall +CPPFLAGS += -I../../../../include -I../libcontrollers +LDLIBS += -lm -L../../../../lib/ -L../libcontrollers -lcontrollers -lltp + +SRCS = $(wildcard *.c) + +TARGETS = $(patsubst %.c,%,$(SRCS)) + +all: $(TARGETS) + +clean: + rm -f $(TARGETS) *.o + +install: + @set -e; for i in $(TARGETS) run_cpuacct_test.sh myfunctions.sh; do ln -f $$i ../../../bin/$$i ; chmod +x $$i ; done +
/testcases/kernel/controllers/cpuacct/myfunctions.sh +114 -0
114 lines not on this page · raw message
/testcases/kernel/controllers/cpuacct/README +51 -0
51 lines not on this page · raw message
/testcases/kernel/controllers/cpuacct/run_cpuacct_test.sh +375 -0
375 lines not on this page · raw message
/testcases/kernel/controllers/Makefile +8 -0
@@ -7,6 +7,8 @@ CHECK_MEMCTL := $(shell grep -w memory / 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) CHECK_CPUSETCTL = $(shell grep -w cpuset /proc/cgroups 2>/dev/null|cut -f1) +CHECK_CPUACCTCTL := $(shell grep -w cpuacct /proc/cgroups 2>/dev/null|cut -f1) + endif ifdef CROSS_COMPILE
@@ -18,6 +20,7 @@ SUBDIRS += memctl SUBDIRS += io-throttle SUBDIRS += freezer SUBDIRS += cpuset +SUBDIRS += cpuacct else $(info "Kernel is not compiled with control cgroup support") endif
@@ -60,6 +63,11 @@ SUBDIRS += cpuset else $(info "Kernel is not compiled with cpuset resource controller support") endif +ifeq ($(CHECK_CPUACCTCTL),cpuacct) +SUBDIRS += cpuacct +else +$(info "Kernel is not compiled with cpuacct resource controller support") +endif endif # If at least one of the controllers is available then build libcontrollers.
/testcases/kernel/controllers/README +4 -0
@@ -51,6 +51,10 @@ libcontrollers -------------- This directory contains the library for cpucontroller testing. +cpuacct +----------- +Directory containing the cpu accounting controller testcases. + Makefile -------- The usual Makefile to conduct all the tests.
/testcases/kernel/controllers/test_controllers.sh +12 -0
@@ -43,6 +43,7 @@ then IOTHROTTLE_CONTROLLER=`grep -w blockio /proc/cgroups | cut -f1`; FREEZER=`grep -w freezer /proc/cgroups | cut -f1`; CPUSET_CONTROLLER=`grep -w cpuset /proc/cgroups | cut -f1` + CPUACCOUNT_CONTROLLER=`grep -w cpuacct /proc/cgroups | cut -f1` if [ "$CPU_CONTROLLER" = "cpu" ] then
@@ -115,10 +116,22 @@ then echo "Kernel does not support cpuset controller"; echo "Skipping all cpuset controller testcases...."; fi + + if [ "$CPUACCOUNT_CONTROLLER" = "cpuacct" ] + then + $LTPROOT/testcases/bin/run_cpuacct_test.sh 1; + $LTPROOT/testcases/bin/run_cpuacct_test.sh 2; + else + echo "Could not start cpu accounting controller test"; + echo "usage: run_cpuacct_test.sh $TEST_NUM "; + echo "Skipping the cpu accounting controller test..."; + else echo "CONTROLLERS TESTCASES: WARNING" echo "Kernel does not support for control groups"; echo "Skipping all controllers testcases...."; + fi
exit 0;
Thanks
Signature · 12 lines
Rajasekhar Duddu ([email protected]), Linux on System z - CSVT, IBM LTC, Bangalore. ------------------------------------------------------------------------------ Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day trial. Simplify your report design, integration and deployment - and focus on what you do best, core application coding. Discover what's new with Crystal Reports now. http://p.sf.net/sfu/bobj-july _______________________________________________ Ltp-list mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/ltp-list
Hi Raj,
Including few more people for review. My few nitpicks below.
Quoted 101 lines · Rajasekhar Duddu
Hi, I have developed a testcase for CPU Accounting Controller which is used to group tasks using cgroups and account the CPU usage of these groups of tasks.
Here I am posting the patch, please review the patch and let me know if it needs any changes, thanks.
diff -rupN
ltp-full-20090731//testcases/kernel/controllers/cpuacct/cpuacct_task.cltp-full-20090731.src//testcases/kernel/controllers/cpuacct/cpuacct_task.c/testcases/kernel/controllers/cpuacct/cpuacct_task.c +18
-0@@ -0,0 +1,18 @@ +#include <stdio.h> + +int main (void ) +{ +FILE *fp; + +while (1 ) + { + + fp=fopen ("txt.x" ,"w" ); +fclose (fp); + + } + +return 0 ; +} + +diff -rupN
ltp-full-20090731//testcases/kernel/controllers/cpuacct/cpuacct_testplan.txtltp-full-20090731.src//testcases/kernel/controllers/cpuacct/cpuacct_testplan.txt/testcases/kernel/controllers/cpuacct/cpuacct_testplan.txt +44
-0@@ -0,0 +1,44 @@ +The CPU Accounting controller testplan includes a complete set of +testcases that test the CPU Accounting controller in different scenarios. + + +TESTCASE DESCRIPTION: +==================== + +These tests will check if the cpu usage of the child cgroup is +getting reflected in the parent cgroup.Reports PASS if the cpu +usage is same for both the cgroups and FAIL if they differ. + +In these tests cpu usage of the tasks running in a group is read in +terms of 3 different stat values. + +'cpuacct.usage' gives the current cpu usage of the task running +in the group. +'cpuacct.usage_percpu' gives the cpu usage of each cpu. +'cpuacct.stat' gives the user and system cpu usage of the task running +in the group. + +Test01: STAT CHECK TEST +------------------------------- +This test is run by running a task in the child group and reading it's stat +values and comparing them with the parent group's stat values. + +Test02: STAT CHECK TEST +------------------------------- +This test is run by running num_online_cpus number of tasks in 2 child groups, +adding the stat values from the child groups and comparing them with the +parent's stat values. + +The values reported for user and system time in cpuacct.stat is not very +accurate and they can vary from the actual values by Threshold*num_online_cpus in the +worst case. +Where Threshold T = max(num_online_cpus^2, 32) + +In this test case, we allow for a max difference between actual and reported +values to be 2T. If the difference between parent's value and children's value +is greater than 2T, we mark the test as failed. + + +For any other information please refer to +Documentation/controllers/cpuacct.txt in kernel documentation. +diff -rupN ltp-full-20090731//testcases/kernel/controllers/cpuacct/Makefile ltp-full-20090731.src//testcases/kernel/controllers/cpuacct/Makefile
/testcases/kernel/controllers/cpuacct/Makefile +16
-0@@ -0,0 +1,16 @@ +CFLAGS += -Wall +CPPFLAGS += -I../../../../include -I../libcontrollers +LDLIBS += -lm -L../../../../lib/ -L../libcontrollers -lcontrollers -lltp + +SRCS = $(wildcard *.c) + +TARGETS = $(patsubst %.c,%,$(SRCS)) + +all: $(TARGETS) + +clean: + rm -f $(TARGETS) *.o + +install: + @set -e; for i in $(TARGETS) run_cpuacct_test.sh myfunctions.sh; do ln -f $$i ../../../bin/$$i ; chmod +x $$i ; done +diff -rupN
ltp-full-20090731//testcases/kernel/controllers/cpuacct/myfunctions.shltp-full-20090731.src//testcases/kernel/controllers/cpuacct/myfunctions.sh
/testcases/kernel/controllers/cpuacct/myfunctions.sh line 2
Quoted 2 lines
/testcases/kernel/controllers/cpuacct/myfunctions.sh +2
-0@@ -0,0 +1,114 @@ +#!/bin/bash +# usage ./myfunctions.sh
Can this be changed to some other name apart from myfunctions.sh ?
/testcases/kernel/controllers/cpuacct/myfunctions.sh line 5
Quoted 3 lines
/testcases/kernel/controllers/cpuacct/myfunctions.sh +3
-0+ +################################################################################# +# Copyright (c) International Business Machines Corp., 2008 #
Change to 2009 where we are now ;-)
And then check you patch against linux*/scripts/checkpatch.pl for any inconsistencies.
Regards--
Subrata
Quoted 625 lines
/testcases/kernel/controllers/cpuacct/myfunctions.sh +109
-0+# # +# 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 # +# # +################################################################################# +################################################################################ +# Name Of File: myfunctions.sh # +# # +# Description: This file has functions for the setup for testing cpu account # +# controller. setup includes creating controller device, # +# mounting it with cgroup filesystem with option cpu account # +# and creating groups in it. # +# # +# Functions: setup(): creaes /dev/cpuacct, mounts cgroup fs on it, creates # +# groups in that etc. # +# usage(): Shows the usage of this file. # +# cleanup(): Does full system cleanup # +# # +# Precaution: Avoid system use by other applications/users to get fair and # +# appropriate results (avoid unnecessary killing of applicatio) # +# # +# Author: Rajasekhar Duddu <[email protected]> # +# # +# History: # +# # +# DATE NAME EMAIL DESC # +# # +# 14/07/09 Rajasekhar D <[email protected]> Created this test # +# # +################################################################################ + + + # Write the cleanup function +cleanup () +{ + echo "Cleanup called"; + rm -rf txt.x 2> /dev/null + rm -f cpuacct_task 2>/dev/null + rmdir /dev/cpuacct/group*/group* 2> /dev/null + rmdir /dev/cpuacct/group* 2> /dev/null + umount /dev/cpuacct/ 2> /dev/null + rmdir /dev/cpuacct 2> /dev/null + rm -rf tmp2 2> /dev/null +} +task_kill () +{ + for i in `ps -e | grep cpuacct_task | cut -d" " -f1` + do + kill -SIGUSR1 $i + done + rm -rf $PWD/txt.x 2> /dev/null + rm -f $PWD/cpuacct_task[0-8] 2>/dev/null + +} +#Create /dev/cpuacct & mount the cgroup file system with +#cpu accounting controller + +#clean any group created eralier (if any) + +setup () +{ + if [ -e /dev/cpuacct ] + then + echo "WARN:/dev/cpuacct already exist..overwriting"; + rmdir /dev/cpuacct/group*/group* 2> /dev/null + rmdir /dev/cpuacct/group* 2> /dev/null + umount /dev/cpuacct/ 2> /dev/null + rmdir /dev/cpuacct 2> /dev/null + + mkdir /dev/cpuacct; + else + mkdir /dev/cpuacct + fi + mount -t cgroup -ocpuacct none /dev/cpuacct 2> /dev/null + if [ $? -ne 0 ] + then + echo "TFAIL: Could not mount cgroup filesystem for cpu accounting on /dev/cpuacct..Exiting test"; + cleanup; + exit -1; + fi + + # Group created earlier may again be visible if not cleaned properly...so clean them + if [ -e /dev/cpuacct/group_1 ] + then + rmdir /dev/cpuacct/group*/group* 2> /dev/null + rmdir /dev/cpuacct/group* 2> /dev/null + echo "WARN: Earlier groups found and removed..."; + fi + +} + +# The usage of the script file +usage() +{ + echo "Could not start cpu account controller test"; + echo "usage: run_cpuacct_test.sh $TEST_NUM "; + echo "Skipping the cpu account controller test..."; +}diff -rupN ltp-full-20090731//testcases/kernel/controllers/cpuacct/README ltp-full-20090731.src//testcases/kernel/controllers/cpuacct/README
/testcases/kernel/controllers/cpuacct/README +51
-0@@ -0,0 +1,51 @@ +TEST SUITE: + +The directory cpuacct contains the tests related to cpu accounting controller. +More testcases are expected to be added in future. + +TESTS AIM: + +The aim of the tests is to test cpu accounting controller functionality. + +FILES DESCRIPTION: + +cpuacct_task.c +--------------- +This is the task which is run for eating up the cpu time. + + +myfunctions.sh +---------- +This file contains the functions which are common for all the tests. For ex. +the setup and cleanup functions which do the setup for running the test and do +the cleanup once the test finishes. The setup() function creates /dev/cpuacct +directory and mounts cgroup filesystem on it with accounting controller. It +then creates a number(n) of groups in /dev/cpuacct. The cleanup function does a +complete cleanup of the system. + +Most of the error scenarios have been taken care of for a sane cleanup of the +system. However if cleanup fails in any case, just manually execute the +commands written in cleanup function in myfunctions.sh. +One of the most common causes of failed cleanup is that you have done cd into +any of the groups in controller dir tree. + +run_cpuacct_test.sh +------------------ +This script creates different scenarios for cpu accounting controller testing and +starting (n) tasks in different groups to do some cpu allocations etc. It +checks for the cpu usage of the groups and reports test pass/fail accordingly. + +Makefile +-------- + +The usual makefile for this directory + +PASS/FAIL CRITERION: +================== +The test cases are intelligent enough in deciding the pass or failure of a +test. + +README: +-------- +The one you have gone through. +diff -rupN
ltp-full-20090731//testcases/kernel/controllers/cpuacct/run_cpuacct_test.shltp-full-20090731.src//testcases/kernel/controllers/cpuacct/run_cpuacct_test.sh/testcases/kernel/controllers/cpuacct/run_cpuacct_test.sh +375
-0@@ -0,0 +1,375 @@ +#!/bin/bash +# usage ./run_cpuacct_test.sh $TEST_NUM + +################################################################################# +# Copyright (c) International Business Machines Corp., 2008 # +# # +# 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 # +# # +################################################################################# +# Name Of File: run_cpuacct_test.sh # +# # +# Description: This file runs the setup for testing different cpu acctount # +# controller features. After setup it runs diff test cases in # +# diff setup. # +# # +# Test 01: Tests Cpu usage of Hierarchical cgroups # +# # +# Precaution: Avoid system use by other applications/users to get fair and # +# appropriate results (avoid unnecessary killing of applicatio) # +# # +# Author: Rajasekhar Duddu <[email protected]> # +# # +# History: # +# # +# DATE NAME EMAIL DESC # +# # +# 14/07/09 Rajasekhar D <[email protected]> Created this test # +# # +################################################################################# + +export TCID="cpuacct_test01"; +export TST_TOTAL=1; +export TST_COUNT=1; + +TEST_NUM=$1; +SCRIPT_PID=$$; +RC=0; +PWD=`pwd`; + +cd $LTPROOT/testcases/bin/ 2> /dev/null +. myfunctions.sh + +if [ "$USER" != root ]; then + tst_brkm TBROK ignored "Test must be run as root" + exit 0 +fi + +tst_kvercmp 2 6 30 2> /dev/null +if [ $? -eq 0 ]; then + tst_brkm TBROK ignored "Test should be run with kernel 2.6.30 or newer" + exit 0 +fi + +task_kill 2> /dev/null +cleanup + +cgroup_path="/dev/cpuacct"; +num_online_cpus=`cat /proc/cpuinfo | grep -w processor | wc -l` + +#Function to create tasks equal to num_online_cpus. +nr_tasks () +{ + $PWD/cpuacct_task & + pid=$! +} + +#Function to caluculate the threshold value. +get_threshold () +{ + num_online_cpus=`expr $num_online_cpus \* $num_online_cpus` + if [ $num_online_cpus -le 32 ] + then + threshold=32 + else + threshold=$num_online_cpus + fi + + threshold=`expr $threshold \* 2` +} +#Function which is called for reading the cpuacct.usage_percpu stat value for Parent and Child cgroups. +per_cpu_usage () +{ + attrc=0 + attrp=0 + i=0 + k=0 + while read line + do + j=0 + for k in $line + do + j=`expr $j + $k` + done + if [ "$i" == "0" ] + then + attrp=$j + i=`expr $i + 1` + else + attrc=`expr $j + $attrc` + fi + done < "./tmp2" +} + +#Function which verifies the cpu accounting of the Parent and the Child cgroups. + +check_attr() +{ + + if [ "$1" == "1" ] + then + if [ "$2" == "cpuacct.stat" ] + then + attr1="`sed -n 1p tmp2`" + attr2="`sed -n 2p tmp2`" + attr3="`sed -n 3p tmp2`" + attr4="`sed -n 4p tmp2`" + echo + echo "$2 for Parent cgroup is $attr1 : $attr2" + echo "$2 for Child cgroup is $attr3 : $attr4" + + if [ "$attr1" == "$attr3" ] && [ "$attr2" == "$attr4" ] + then + RC=$? + echo "TPASS CPU Accounting Controller: $2 PASSED" + + else + RC=$? + echo "TFAIL CPU Accounting Controller : $2 FAILED" + fi + elif [ "$2" == "cpuacct.usage_percpu" ] + then + per_cpu_usage + echo + echo "$2 for Parent cgroup : $attrp" + echo "$2 for Child cgroup : $attrc" + if [ "$attrp" == "$attrc" ] + then + RC=$? + echo "TPASS CPU Accounting Controller: $2 PASSED" + else + RC=$? + echo "TFAIL CPU Accounting Controller : $2 FAILED" + fi + else + attr1="`sed -n 1p tmp2`" + attr2="`sed -n 2p tmp2`" + + echo + echo "$2 for Parent cgroup is $attr1" + echo "$2 for Child cgroup is $attr2" + if [ "$attr1" == "$attr2" ] + then + RC=$? + echo "TPASS CPU Accounting Controller: $2 PASSED" + else + RC=$? + echo "TFAIL CPU Accounting Controller : $2 FAILED" + fi + + fi + else + + if [ "$2" == "cpuacct.stat" ] + then + attr0="`sed -n 1p tmp2 | cut -d" " -f2`" + attr1="`sed -n 2p tmp2 | cut -d" " -f2`" + attr2="`sed -n 3p tmp2 | cut -d" " -f2`" + attr3="`sed -n 4p tmp2 | cut -d" " -f2`" + attr4="`sed -n 5p tmp2 | cut -d" " -f2`" + attr5="`sed -n 6p tmp2 | cut -d" " -f2`" + attr_usr=`expr $attr2 + $attr4 ` + attr_sys=`expr $attr3 + $attr5` + echo + echo "$2 for Parent cgroup : $attr0::$attr1" + echo "$2 for Child cgroup : $attr_usr::$attr_sys" + get_threshold + diff_usr=`expr $attr0 - $attr_usr ` + [ ${diff_usr} -le 0 ] && diff_usr=$((0 - $diff_usr)) + + diff_sys=`expr $attr1 - $attr_sys` + [ ${diff_sys} -le 0 ] && diff_sys=$((0 - $diff_sys)) + + if [ "$diff_usr" -le "$threshold " ] && [ "$diff_sys" -le "$threshold" ] + then + RC=$? + echo "TPASS CPU Accounting Controller: $2 PASSED" + else + RC=$? + echo "TFAIL CPU Accounting Controller : $2 FAILED" + fi + elif [ "$2" == "cpuacct.usage_percpu" ] + then + per_cpu_usage + echo + echo "$2 for Parent cgroup : $attrp" + echo "$2 for Child cgroup : $attrc" + if [ "$attrp" == "$attrc" ] + then + RC=$? + echo "TPASS CPU Accounting Controller: $2 PASSED" + else + RC=$? + echo "TFAIL CPU Accounting Controller : $2 FAILED" + fi + + else + attr0="`sed -n 1p tmp2`" + attr1="`sed -n 2p tmp2`" + attr2="`sed -n 3p tmp2`" + attr=`expr $attr1 + $attr2` + echo + echo "$2 for Parent cgroup : $attr0" + echo "$2 for Child cgroup : $attr" + if [ "$attr0" == "$attr" ] + then + RC=$? + echo "TPASS CPU Accounting Controller: $2 PASSED" + else + RC=$? + echo "TFAIL CPU Accounting Controller : $2 FAILED" + fi + fi + fi +} + +echo "TEST $TEST_NUM: CPU ACCOUNTING CONTROLLER TESTING"; +echo "RUNNING SETUP....."; +setup; + +echo "TEST STARTED: Please avoid using system while this test executes"; + + +status=0 +case ${TEST_NUM} in + + "1" ) + gcc -o $PWD/cpuacct_task $PWD/cpuacct_task.c + ls $PWD/cpuacct_task &> /dev/null + if [ $? -ne 0 ] + then + echo "TFAIL Task file cpuacct_task.c not compiled..Please check Makefile...Exiting test" + exit -1 + fi + $PWD/cpuacct_task & + pid=$! + + mkdir $cgroup_path/group_1 $cgroup_path/group_1/group_11/ 2> /dev/null + if [ $? -ne 0 ] + then + echo "TFAIL Cannot create cpuacct cgroups..Exiting Test " + cleanup + exit -1 + fi + echo $pid > /$cgroup_path/group_1/group_11/tasks 2> /dev/null + if [ $? -ne 0 ] + then + echo "TFAIL Not able to move a task to the cgroup...Exiting Test" + cleanup 2> /dev/null + exit -1 + fi + sleep 5 + task_kill 2> /dev/null + for i in cpuacct.usage cpuacct.usage_percpu cpuacct.stat + do + cat $cgroup_path/group_1/$i $cgroup_path/group_1/group_11/$i > tmp2 + check_attr $1 $i + done + if [ $RC -ne 0 ] + then + status=1 + fi + + if [ $status -eq 0 ] + then + echo + echo "CPU Accounting Controller test executed successfully." + cleanup 2> /dev/null + cd $PWD + exit 0 + else + echo + echo "CPU Accounting Controller test execution Failed " + cleanup 2> /dev/null + cd $PWD + exit -1 + fi + ;; + + "2" ) + mkdir $cgroup_path/group_1 $cgroup_path/group_1/group_11 $cgroup_path/group_1/group_12 2> /dev/null + if [ $? -ne 0 ] + then + echo "TFAIL Cannot create cpuacct cgroups..Exiting Test " + cleanup 2> /dev/null + exit -1 + fi + + gcc -o $PWD/cpuacct_task $PWD/cpuacct_task.c + ls $PWD/cpuacct_task &> /dev/null + if [ $? -ne 0 ] + then + echo "TFAIL Task file cpuacct_task.c not compiled..Please check Makefile...Exiting test" + cleanup 2> /dev/null + exit -1 + fi + + for (( m=0 ; m<=$num_online_cpus ; m++ )) + do + nr_tasks + echo $pid > $cgroup_path/group_1/group_11/tasks 2> /dev/null + if [ $? -ne 0 ] + then + echo "TFAIL Not able to move a task to the cgroup...Exiting Test" + cleanup 2> /dev/null + exit -1 + fi + + + nr_tasks + echo $pid > $cgroup_path/group_1/group_12/tasks 2> /dev/null + if [ $? -ne 0 ] + then + echo "TFAIL Not able to move a task to the cgroup...Exiting Test" + cleanup 2> /dev/null + exit -1 + fi + sleep 2 + + done + task_kill 2> /dev/null + + for i in cpuacct.usage cpuacct.usage_percpu cpuacct.stat + do + cat $cgroup_path/group_1/$i $cgroup_path/group_1/group_11/$i $cgroup_path/group_1/group_12/$i > tmp2 + check_attr $1 $i + done + if [ $RC -ne 0 ] + then + status=1 + fi + if [ $status -eq 0 ] + then + echo + echo "CPU Accounting Controller test executed successfully." + cleanup 2> /dev/null + cd $PWD + exit 0 + else + echo + echo "CPU Accounting Controller test execution Failed " + cleanup 2> /dev/null + cd $PWD + exit -1 + fi + + ;; + + * ) + usage + exit -1 + ;; + esac +diff -rupN ltp-full-20090731//testcases/kernel/controllers/Makefile ltp-full-20090731.src//testcases/kernel/controllers/Makefile
/testcases/kernel/controllers/Makefile +8
-0@@ -7,6 +7,8 @@ CHECK_MEMCTL := $(shell grep -w memory / 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) CHECK_CPUSETCTL = $(shell grep -w cpuset /proc/cgroups 2>/dev/null|cut -f1) +CHECK_CPUACCTCTL := $(shell grep -w cpuacct /proc/cgroups 2>/dev/null|cut -f1) + endif ifdef CROSS_COMPILE@@ -18,6 +20,7 @@ SUBDIRS += memctl SUBDIRS += io-throttle SUBDIRS += freezer SUBDIRS += cpuset +SUBDIRS += cpuacct else $(info "Kernel is not compiled with control cgroup support") endif@@ -60,6 +63,11 @@ SUBDIRS += cpuset else $(info "Kernel is not compiled with cpuset resource controller support") endif +ifeq ($(CHECK_CPUACCTCTL),cpuacct) +SUBDIRS += cpuacct +else +$(info "Kernel is not compiled with cpuacct resource controller support") +endif endif # If at least one of the controllers is available then build libcontrollers.diff -rupN ltp-full-20090731//testcases/kernel/controllers/README ltp-full-20090731.src//testcases/kernel/controllers/README
/testcases/kernel/controllers/README +4
-0@@ -51,6 +51,10 @@ libcontrollers -------------- This directory contains the library for cpucontroller testing. +cpuacct +----------- +Directory containing the cpu accounting controller testcases. + Makefile -------- The usual Makefile to conduct all the tests.diff -rupN
ltp-full-20090731//testcases/kernel/controllers/test_controllers.shltp-full-20090731.src//testcases/kernel/controllers/test_controllers.sh/testcases/kernel/controllers/test_controllers.sh +12
-0@@ -43,6 +43,7 @@ then IOTHROTTLE_CONTROLLER=`grep -w blockio /proc/cgroups | cut -f1`; FREEZER=`grep -w freezer /proc/cgroups | cut -f1`; CPUSET_CONTROLLER=`grep -w cpuset /proc/cgroups | cut -f1` + CPUACCOUNT_CONTROLLER=`grep -w cpuacct /proc/cgroups | cut -f1` if [ "$CPU_CONTROLLER" = "cpu" ] then@@ -115,10 +116,22 @@ then echo "Kernel does not support cpuset controller"; echo "Skipping all cpuset controller testcases...."; fi + + if [ "$CPUACCOUNT_CONTROLLER" = "cpuacct" ] + then + $LTPROOT/testcases/bin/run_cpuacct_test.sh 1; + $LTPROOT/testcases/bin/run_cpuacct_test.sh 2; + else + echo "Could not start cpu accounting controller test"; + echo "usage: run_cpuacct_test.sh $TEST_NUM "; + echo "Skipping the cpu accounting controller test..."; + else echo "CONTROLLERS TESTCASES: WARNING" echo "Kernel does not support for control groups"; echo "Skipping all controllers testcases...."; + fi exit 0;
Quoted 1 line
Thanks
------------------------------------------------------------------------------
Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day trial. Simplify your report design, integration and deployment - and focus on what you do best, core application coding. Discover what's new with Crystal Reports now. http://p.sf.net/sfu/bobj-july
_______________________________________________
Ltp-list mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/ltp-list
Quoted 10 lines · Subrata Modak
Hi Raj,
Including few more people for review. My few nitpicks below.
Quoted 5 lines · Rajasekhar Duddu
Hi, I have developed a testcase for CPU Accounting Controller which is used to group tasks using cgroups and account the CPU usage of these groups of tasks.
Here I am posting the patch, please review the patch and let me know if it needs any changes, thanks.
Hi,
Few more comments below:
1) Checking your patch through linux*/scripts/checkpatch.pl:
ERROR: Missing Signed-off-by: line(s)
total: 48 errors, 89 warnings, 683 lines checked
Fix all the above errors/warnings,
2) Application of patch:
patching file testcases/kernel/controllers/cpuacct/cpuacct_task.c patching file testcases/kernel/controllers/cpuacct/cpuacct_testplan.txt patching file testcases/kernel/controllers/cpuacct/Makefile patching file testcases/kernel/controllers/cpuacct/myfunctions.sh patching file testcases/kernel/controllers/cpuacct/README patching file testcases/kernel/controllers/cpuacct/run_cpuacct_test.sh patching file testcases/kernel/controllers/Makefile
patching file testcases/kernel/controllers/README
patching file testcases/kernel/controllers/test_controllers.sh
patch: **** malformed patch at line 788: exit 0;
Fix the Patch itself for the malformed lines,
3) Running the tests:
<<<test_start>>>
tag=CPUACCT01 stime=1249970577 cmdline="$LTPROOT/testcases/bin/run_cpuacct_test.sh 1;" contacts=""
analysis=exit
<<<test_output>>>cpuacct_test01 1 TBROK : Test should be run with kernel 2.6.30 or
newer
<<<execution_status>>>
initiation_status="ok"
duration=0 termination_type=exited termination_id=0 corefile=no cutime=0 cstime=1
<<<test_end>>>
<<<test_start>>>
tag=CPUACCT02 stime=1249970577 cmdline="$LTPROOT/testcases/bin/run_cpuacct_test.sh 2;" contacts=""
analysis=exit
<<<test_output>>>
incrementing stopcpuacct_test01 1 TBROK : Test should be run with kernel 2.6.30 or
newer
<<<execution_status>>>
initiation_status="ok"
duration=0 termination_type=exited termination_id=0 corefile=no cutime=0 cstime=1
<<<test_end>>>
Since you are not allowing these tests to run below 2.6.30 kernel, i would request you to kindly share the results of test run on your machine with the LTP list.
Regards--
Subrata
Quoted 738 lines
Quoted 96 lines
diff -rupN
ltp-full-20090731//testcases/kernel/controllers/cpuacct/cpuacct_task.cltp-full-20090731.src//testcases/kernel/controllers/cpuacct/cpuacct_task.c/testcases/kernel/controllers/cpuacct/cpuacct_task.c +18
-0@@ -0,0 +1,18 @@ +#include <stdio.h> + +int main (void ) +{ +FILE *fp; + +while (1 ) + { + + fp=fopen ("txt.x" ,"w" ); +fclose (fp); + + } + +return 0 ; +} + +diff -rupN
ltp-full-20090731//testcases/kernel/controllers/cpuacct/cpuacct_testplan.txtltp-full-20090731.src//testcases/kernel/controllers/cpuacct/cpuacct_testplan.txt/testcases/kernel/controllers/cpuacct/cpuacct_testplan.txt +44
-0@@ -0,0 +1,44 @@ +The CPU Accounting controller testplan includes a complete set of +testcases that test the CPU Accounting controller in different scenarios. + + +TESTCASE DESCRIPTION: +==================== + +These tests will check if the cpu usage of the child cgroup is +getting reflected in the parent cgroup.Reports PASS if the cpu +usage is same for both the cgroups and FAIL if they differ. + +In these tests cpu usage of the tasks running in a group is read in +terms of 3 different stat values. + +'cpuacct.usage' gives the current cpu usage of the task running +in the group. +'cpuacct.usage_percpu' gives the cpu usage of each cpu. +'cpuacct.stat' gives the user and system cpu usage of the task running +in the group. + +Test01: STAT CHECK TEST +------------------------------- +This test is run by running a task in the child group and reading it's stat +values and comparing them with the parent group's stat values. + +Test02: STAT CHECK TEST +------------------------------- +This test is run by running num_online_cpus number of tasks in 2 child groups, +adding the stat values from the child groups and comparing them with the +parent's stat values. + +The values reported for user and system time in cpuacct.stat is not very +accurate and they can vary from the actual values by Threshold*num_online_cpus in the +worst case. +Where Threshold T = max(num_online_cpus^2, 32) + +In this test case, we allow for a max difference between actual and reported +values to be 2T. If the difference between parent's value and children's value +is greater than 2T, we mark the test as failed. + + +For any other information please refer to +Documentation/controllers/cpuacct.txt in kernel documentation. +diff -rupN ltp-full-20090731//testcases/kernel/controllers/cpuacct/Makefile ltp-full-20090731.src//testcases/kernel/controllers/cpuacct/Makefile
/testcases/kernel/controllers/cpuacct/Makefile +16
-0@@ -0,0 +1,16 @@ +CFLAGS += -Wall +CPPFLAGS += -I../../../../include -I../libcontrollers +LDLIBS += -lm -L../../../../lib/ -L../libcontrollers -lcontrollers -lltp + +SRCS = $(wildcard *.c) + +TARGETS = $(patsubst %.c,%,$(SRCS)) + +all: $(TARGETS) + +clean: + rm -f $(TARGETS) *.o + +install: + @set -e; for i in $(TARGETS) run_cpuacct_test.sh myfunctions.sh; do ln -f $$i ../../../bin/$$i ; chmod +x $$i ; done +diff -rupN
ltp-full-20090731//testcases/kernel/controllers/cpuacct/myfunctions.shltp-full-20090731.src//testcases/kernel/controllers/cpuacct/myfunctions.sh/testcases/kernel/controllers/cpuacct/myfunctions.sh line 2
Quoted 2 lines
/testcases/kernel/controllers/cpuacct/myfunctions.sh +2
-0@@ -0,0 +1,114 @@ +#!/bin/bash +# usage ./myfunctions.shCan this be changed to some other name apart from
myfunctions.sh?/testcases/kernel/controllers/cpuacct/myfunctions.sh line 5
Quoted 3 lines
/testcases/kernel/controllers/cpuacct/myfunctions.sh +3
-0+ +################################################################################# +# Copyright (c) International Business Machines Corp., 2008 #Change to 2009 where we are now ;-)
And then check you patch against
linux*/scripts/checkpatch.plfor any inconsistencies.Regards--
SubrataQuoted 625 lines
/testcases/kernel/controllers/cpuacct/myfunctions.sh +109
-0+# # +# 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 # +# # +################################################################################# +################################################################################ +# Name Of File: myfunctions.sh # +# # +# Description: This file has functions for the setup for testing cpu account # +# controller. setup includes creating controller device, # +# mounting it with cgroup filesystem with option cpu account # +# and creating groups in it. # +# # +# Functions: setup(): creaes /dev/cpuacct, mounts cgroup fs on it, creates # +# groups in that etc. # +# usage(): Shows the usage of this file. # +# cleanup(): Does full system cleanup # +# # +# Precaution: Avoid system use by other applications/users to get fair and # +# appropriate results (avoid unnecessary killing of applicatio) # +# # +# Author: Rajasekhar Duddu <[email protected]> # +# # +# History: # +# # +# DATE NAME EMAIL DESC # +# # +# 14/07/09 Rajasekhar D <[email protected]> Created this test # +# # +################################################################################ + + + # Write the cleanup function +cleanup () +{ + echo "Cleanup called"; + rm -rf txt.x 2> /dev/null + rm -f cpuacct_task 2>/dev/null + rmdir /dev/cpuacct/group*/group* 2> /dev/null + rmdir /dev/cpuacct/group* 2> /dev/null + umount /dev/cpuacct/ 2> /dev/null + rmdir /dev/cpuacct 2> /dev/null + rm -rf tmp2 2> /dev/null +} +task_kill () +{ + for i in `ps -e | grep cpuacct_task | cut -d" " -f1` + do + kill -SIGUSR1 $i + done + rm -rf $PWD/txt.x 2> /dev/null + rm -f $PWD/cpuacct_task[0-8] 2>/dev/null + +} +#Create /dev/cpuacct & mount the cgroup file system with +#cpu accounting controller + +#clean any group created eralier (if any) + +setup () +{ + if [ -e /dev/cpuacct ] + then + echo "WARN:/dev/cpuacct already exist..overwriting"; + rmdir /dev/cpuacct/group*/group* 2> /dev/null + rmdir /dev/cpuacct/group* 2> /dev/null + umount /dev/cpuacct/ 2> /dev/null + rmdir /dev/cpuacct 2> /dev/null + + mkdir /dev/cpuacct; + else + mkdir /dev/cpuacct + fi + mount -t cgroup -ocpuacct none /dev/cpuacct 2> /dev/null + if [ $? -ne 0 ] + then + echo "TFAIL: Could not mount cgroup filesystem for cpu accounting on /dev/cpuacct..Exiting test"; + cleanup; + exit -1; + fi + + # Group created earlier may again be visible if not cleaned properly...so clean them + if [ -e /dev/cpuacct/group_1 ] + then + rmdir /dev/cpuacct/group*/group* 2> /dev/null + rmdir /dev/cpuacct/group* 2> /dev/null + echo "WARN: Earlier groups found and removed..."; + fi + +} + +# The usage of the script file +usage() +{ + echo "Could not start cpu account controller test"; + echo "usage: run_cpuacct_test.sh $TEST_NUM "; + echo "Skipping the cpu account controller test..."; +}diff -rupN ltp-full-20090731//testcases/kernel/controllers/cpuacct/README ltp-full-20090731.src//testcases/kernel/controllers/cpuacct/README
/testcases/kernel/controllers/cpuacct/README +51
-0@@ -0,0 +1,51 @@ +TEST SUITE: + +The directory cpuacct contains the tests related to cpu accounting controller. +More testcases are expected to be added in future. + +TESTS AIM: + +The aim of the tests is to test cpu accounting controller functionality. + +FILES DESCRIPTION: + +cpuacct_task.c +--------------- +This is the task which is run for eating up the cpu time. + + +myfunctions.sh +---------- +This file contains the functions which are common for all the tests. For ex. +the setup and cleanup functions which do the setup for running the test and do +the cleanup once the test finishes. The setup() function creates /dev/cpuacct +directory and mounts cgroup filesystem on it with accounting controller. It +then creates a number(n) of groups in /dev/cpuacct. The cleanup function does a +complete cleanup of the system. + +Most of the error scenarios have been taken care of for a sane cleanup of the +system. However if cleanup fails in any case, just manually execute the +commands written in cleanup function in myfunctions.sh. +One of the most common causes of failed cleanup is that you have done cd into +any of the groups in controller dir tree. + +run_cpuacct_test.sh +------------------ +This script creates different scenarios for cpu accounting controller testing and +starting (n) tasks in different groups to do some cpu allocations etc. It +checks for the cpu usage of the groups and reports test pass/fail accordingly. + +Makefile +-------- + +The usual makefile for this directory + +PASS/FAIL CRITERION: +================== +The test cases are intelligent enough in deciding the pass or failure of a +test. + +README: +-------- +The one you have gone through. +diff -rupN
ltp-full-20090731//testcases/kernel/controllers/cpuacct/run_cpuacct_test.shltp-full-20090731.src//testcases/kernel/controllers/cpuacct/run_cpuacct_test.sh/testcases/kernel/controllers/cpuacct/run_cpuacct_test.sh +375
-0@@ -0,0 +1,375 @@ +#!/bin/bash +# usage ./run_cpuacct_test.sh $TEST_NUM + +################################################################################# +# Copyright (c) International Business Machines Corp., 2008 # +# # +# 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 # +# # +################################################################################# +# Name Of File: run_cpuacct_test.sh # +# # +# Description: This file runs the setup for testing different cpu acctount # +# controller features. After setup it runs diff test cases in # +# diff setup. # +# # +# Test 01: Tests Cpu usage of Hierarchical cgroups # +# # +# Precaution: Avoid system use by other applications/users to get fair and # +# appropriate results (avoid unnecessary killing of applicatio) # +# # +# Author: Rajasekhar Duddu <[email protected]> # +# # +# History: # +# # +# DATE NAME EMAIL DESC # +# # +# 14/07/09 Rajasekhar D <[email protected]> Created this test # +# # +################################################################################# + +export TCID="cpuacct_test01"; +export TST_TOTAL=1; +export TST_COUNT=1; + +TEST_NUM=$1; +SCRIPT_PID=$$; +RC=0; +PWD=`pwd`; + +cd $LTPROOT/testcases/bin/ 2> /dev/null +. myfunctions.sh + +if [ "$USER" != root ]; then + tst_brkm TBROK ignored "Test must be run as root" + exit 0 +fi + +tst_kvercmp 2 6 30 2> /dev/null +if [ $? -eq 0 ]; then + tst_brkm TBROK ignored "Test should be run with kernel 2.6.30 or newer" + exit 0 +fi + +task_kill 2> /dev/null +cleanup + +cgroup_path="/dev/cpuacct"; +num_online_cpus=`cat /proc/cpuinfo | grep -w processor | wc -l` + +#Function to create tasks equal to num_online_cpus. +nr_tasks () +{ + $PWD/cpuacct_task & + pid=$! +} + +#Function to caluculate the threshold value. +get_threshold () +{ + num_online_cpus=`expr $num_online_cpus \* $num_online_cpus` + if [ $num_online_cpus -le 32 ] + then + threshold=32 + else + threshold=$num_online_cpus + fi + + threshold=`expr $threshold \* 2` +} +#Function which is called for reading the cpuacct.usage_percpu stat value for Parent and Child cgroups. +per_cpu_usage () +{ + attrc=0 + attrp=0 + i=0 + k=0 + while read line + do + j=0 + for k in $line + do + j=`expr $j + $k` + done + if [ "$i" == "0" ] + then + attrp=$j + i=`expr $i + 1` + else + attrc=`expr $j + $attrc` + fi + done < "./tmp2" +} + +#Function which verifies the cpu accounting of the Parent and the Child cgroups. + +check_attr() +{ + + if [ "$1" == "1" ] + then + if [ "$2" == "cpuacct.stat" ] + then + attr1="`sed -n 1p tmp2`" + attr2="`sed -n 2p tmp2`" + attr3="`sed -n 3p tmp2`" + attr4="`sed -n 4p tmp2`" + echo + echo "$2 for Parent cgroup is $attr1 : $attr2" + echo "$2 for Child cgroup is $attr3 : $attr4" + + if [ "$attr1" == "$attr3" ] && [ "$attr2" == "$attr4" ] + then + RC=$? + echo "TPASS CPU Accounting Controller: $2 PASSED" + + else + RC=$? + echo "TFAIL CPU Accounting Controller : $2 FAILED" + fi + elif [ "$2" == "cpuacct.usage_percpu" ] + then + per_cpu_usage + echo + echo "$2 for Parent cgroup : $attrp" + echo "$2 for Child cgroup : $attrc" + if [ "$attrp" == "$attrc" ] + then + RC=$? + echo "TPASS CPU Accounting Controller: $2 PASSED" + else + RC=$? + echo "TFAIL CPU Accounting Controller : $2 FAILED" + fi + else + attr1="`sed -n 1p tmp2`" + attr2="`sed -n 2p tmp2`" + + echo + echo "$2 for Parent cgroup is $attr1" + echo "$2 for Child cgroup is $attr2" + if [ "$attr1" == "$attr2" ] + then + RC=$? + echo "TPASS CPU Accounting Controller: $2 PASSED" + else + RC=$? + echo "TFAIL CPU Accounting Controller : $2 FAILED" + fi + + fi + else + + if [ "$2" == "cpuacct.stat" ] + then + attr0="`sed -n 1p tmp2 | cut -d" " -f2`" + attr1="`sed -n 2p tmp2 | cut -d" " -f2`" + attr2="`sed -n 3p tmp2 | cut -d" " -f2`" + attr3="`sed -n 4p tmp2 | cut -d" " -f2`" + attr4="`sed -n 5p tmp2 | cut -d" " -f2`" + attr5="`sed -n 6p tmp2 | cut -d" " -f2`" + attr_usr=`expr $attr2 + $attr4 ` + attr_sys=`expr $attr3 + $attr5` + echo + echo "$2 for Parent cgroup : $attr0::$attr1" + echo "$2 for Child cgroup : $attr_usr::$attr_sys" + get_threshold + diff_usr=`expr $attr0 - $attr_usr ` + [ ${diff_usr} -le 0 ] && diff_usr=$((0 - $diff_usr)) + + diff_sys=`expr $attr1 - $attr_sys` + [ ${diff_sys} -le 0 ] && diff_sys=$((0 - $diff_sys)) + + if [ "$diff_usr" -le "$threshold " ] && [ "$diff_sys" -le "$threshold" ] + then + RC=$? + echo "TPASS CPU Accounting Controller: $2 PASSED" + else + RC=$? + echo "TFAIL CPU Accounting Controller : $2 FAILED" + fi + elif [ "$2" == "cpuacct.usage_percpu" ] + then + per_cpu_usage + echo + echo "$2 for Parent cgroup : $attrp" + echo "$2 for Child cgroup : $attrc" + if [ "$attrp" == "$attrc" ] + then + RC=$? + echo "TPASS CPU Accounting Controller: $2 PASSED" + else + RC=$? + echo "TFAIL CPU Accounting Controller : $2 FAILED" + fi + + else + attr0="`sed -n 1p tmp2`" + attr1="`sed -n 2p tmp2`" + attr2="`sed -n 3p tmp2`" + attr=`expr $attr1 + $attr2` + echo + echo "$2 for Parent cgroup : $attr0" + echo "$2 for Child cgroup : $attr" + if [ "$attr0" == "$attr" ] + then + RC=$? + echo "TPASS CPU Accounting Controller: $2 PASSED" + else + RC=$? + echo "TFAIL CPU Accounting Controller : $2 FAILED" + fi + fi + fi +} + +echo "TEST $TEST_NUM: CPU ACCOUNTING CONTROLLER TESTING"; +echo "RUNNING SETUP....."; +setup; + +echo "TEST STARTED: Please avoid using system while this test executes"; + + +status=0 +case ${TEST_NUM} in + + "1" ) + gcc -o $PWD/cpuacct_task $PWD/cpuacct_task.c + ls $PWD/cpuacct_task &> /dev/null + if [ $? -ne 0 ] + then + echo "TFAIL Task file cpuacct_task.c not compiled..Please check Makefile...Exiting test" + exit -1 + fi + $PWD/cpuacct_task & + pid=$! + + mkdir $cgroup_path/group_1 $cgroup_path/group_1/group_11/ 2> /dev/null + if [ $? -ne 0 ] + then + echo "TFAIL Cannot create cpuacct cgroups..Exiting Test " + cleanup + exit -1 + fi + echo $pid > /$cgroup_path/group_1/group_11/tasks 2> /dev/null + if [ $? -ne 0 ] + then + echo "TFAIL Not able to move a task to the cgroup...Exiting Test" + cleanup 2> /dev/null + exit -1 + fi + sleep 5 + task_kill 2> /dev/null + for i in cpuacct.usage cpuacct.usage_percpu cpuacct.stat + do + cat $cgroup_path/group_1/$i $cgroup_path/group_1/group_11/$i > tmp2 + check_attr $1 $i + done + if [ $RC -ne 0 ] + then + status=1 + fi + + if [ $status -eq 0 ] + then + echo + echo "CPU Accounting Controller test executed successfully." + cleanup 2> /dev/null + cd $PWD + exit 0 + else + echo + echo "CPU Accounting Controller test execution Failed " + cleanup 2> /dev/null + cd $PWD + exit -1 + fi + ;; + + "2" ) + mkdir $cgroup_path/group_1 $cgroup_path/group_1/group_11 $cgroup_path/group_1/group_12 2> /dev/null + if [ $? -ne 0 ] + then + echo "TFAIL Cannot create cpuacct cgroups..Exiting Test " + cleanup 2> /dev/null + exit -1 + fi + + gcc -o $PWD/cpuacct_task $PWD/cpuacct_task.c + ls $PWD/cpuacct_task &> /dev/null + if [ $? -ne 0 ] + then + echo "TFAIL Task file cpuacct_task.c not compiled..Please check Makefile...Exiting test" + cleanup 2> /dev/null + exit -1 + fi + + for (( m=0 ; m<=$num_online_cpus ; m++ )) + do + nr_tasks + echo $pid > $cgroup_path/group_1/group_11/tasks 2> /dev/null + if [ $? -ne 0 ] + then + echo "TFAIL Not able to move a task to the cgroup...Exiting Test" + cleanup 2> /dev/null + exit -1 + fi + + + nr_tasks + echo $pid > $cgroup_path/group_1/group_12/tasks 2> /dev/null + if [ $? -ne 0 ] + then + echo "TFAIL Not able to move a task to the cgroup...Exiting Test" + cleanup 2> /dev/null + exit -1 + fi + sleep 2 + + done + task_kill 2> /dev/null + + for i in cpuacct.usage cpuacct.usage_percpu cpuacct.stat + do + cat $cgroup_path/group_1/$i $cgroup_path/group_1/group_11/$i $cgroup_path/group_1/group_12/$i > tmp2 + check_attr $1 $i + done + if [ $RC -ne 0 ] + then + status=1 + fi + if [ $status -eq 0 ] + then + echo + echo "CPU Accounting Controller test executed successfully." + cleanup 2> /dev/null + cd $PWD + exit 0 + else + echo + echo "CPU Accounting Controller test execution Failed " + cleanup 2> /dev/null + cd $PWD + exit -1 + fi + + ;; + + * ) + usage + exit -1 + ;; + esac +diff -rupN ltp-full-20090731//testcases/kernel/controllers/Makefile ltp-full-20090731.src//testcases/kernel/controllers/Makefile
/testcases/kernel/controllers/Makefile +8
-0@@ -7,6 +7,8 @@ CHECK_MEMCTL := $(shell grep -w memory / 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) CHECK_CPUSETCTL = $(shell grep -w cpuset /proc/cgroups 2>/dev/null|cut -f1) +CHECK_CPUACCTCTL := $(shell grep -w cpuacct /proc/cgroups 2>/dev/null|cut -f1) + endif ifdef CROSS_COMPILE@@ -18,6 +20,7 @@ SUBDIRS += memctl SUBDIRS += io-throttle SUBDIRS += freezer SUBDIRS += cpuset +SUBDIRS += cpuacct else $(info "Kernel is not compiled with control cgroup support") endif@@ -60,6 +63,11 @@ SUBDIRS += cpuset else $(info "Kernel is not compiled with cpuset resource controller support") endif +ifeq ($(CHECK_CPUACCTCTL),cpuacct) +SUBDIRS += cpuacct +else +$(info "Kernel is not compiled with cpuacct resource controller support") +endif endif # If at least one of the controllers is available then build libcontrollers.diff -rupN ltp-full-20090731//testcases/kernel/controllers/README ltp-full-20090731.src//testcases/kernel/controllers/README
/testcases/kernel/controllers/README +4
-0@@ -51,6 +51,10 @@ libcontrollers -------------- This directory contains the library for cpucontroller testing. +cpuacct +----------- +Directory containing the cpu accounting controller testcases. + Makefile -------- The usual Makefile to conduct all the tests.diff -rupN
ltp-full-20090731//testcases/kernel/controllers/test_controllers.shltp-full-20090731.src//testcases/kernel/controllers/test_controllers.sh/testcases/kernel/controllers/test_controllers.sh +12
-0@@ -43,6 +43,7 @@ then IOTHROTTLE_CONTROLLER=`grep -w blockio /proc/cgroups | cut -f1`; FREEZER=`grep -w freezer /proc/cgroups | cut -f1`; CPUSET_CONTROLLER=`grep -w cpuset /proc/cgroups | cut -f1` + CPUACCOUNT_CONTROLLER=`grep -w cpuacct /proc/cgroups | cut -f1` if [ "$CPU_CONTROLLER" = "cpu" ] then@@ -115,10 +116,22 @@ then echo "Kernel does not support cpuset controller"; echo "Skipping all cpuset controller testcases...."; fi + + if [ "$CPUACCOUNT_CONTROLLER" = "cpuacct" ] + then + $LTPROOT/testcases/bin/run_cpuacct_test.sh 1; + $LTPROOT/testcases/bin/run_cpuacct_test.sh 2; + else + echo "Could not start cpu accounting controller test"; + echo "usage: run_cpuacct_test.sh $TEST_NUM "; + echo "Skipping the cpu accounting controller test..."; + else echo "CONTROLLERS TESTCASES: WARNING" echo "Kernel does not support for control groups"; echo "Skipping all controllers testcases...."; + fi exit 0;
Quoted 12 lines
Quoted 1 line
Thanks
------------------------------------------------------------------------------
Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day trial. Simplify your report design, integration and deployment - and focus on what you do best, core application coding. Discover what's new with Crystal Reports now. http://p.sf.net/sfu/bobj-july
_______________________________________________
Ltp-list mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/ltp-list
------------------------------------------------------------------------------
Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day trial. Simplify your report design, integration and deployment - and focus on what you do best, core application coding. Discover what's new with Crystal Reports now. http://p.sf.net/sfu/bobj-july
_______________________________________________
Ltp-list mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/ltp-list
Hi Subrata, I have done the changes to the patch as you have suggested, please review it and let me know if it needs any changes thanku.
I am psoting the results also here.
/testcases/kernel/controllers/cpuacct/cpuacct_task.c +14 -0
@@ -0,0 +1,14 @@ +#include <stdio.h> + +int main (void ) +{ +FILE *fp; + +while (1 ) { + fp =fopen ("txt.x" ,"w" ); +fclose (fp); + } +return 0 ; +} + +
/testcases/kernel/controllers/cpuacct/cpuacct_testplan.txt +44 -0
44 lines not on this page · raw message
/testcases/kernel/controllers/cpuacct/Makefile +16 -0
@@ -0,0 +1,16 @@ +CFLAGS += -Wall +CPPFLAGS += -I../../../../include -I../libcontrollers +LDLIBS += -lm -L../../../../lib/ -L../libcontrollers -lcontrollers -lltp + +SRCS = $(wildcard *.c) + +TARGETS = $(patsubst %.c,%,$(SRCS)) + +all: $(TARGETS) + +clean: + rm -f $(TARGETS) *.o + +install: + @set -e; for i in $(TARGETS) run_cpuacct_test.sh setup.sh; do ln -f $$i ../../../bin/$$i ; chmod +x $$i ; done +
/testcases/kernel/controllers/cpuacct/README +51 -0
51 lines not on this page · raw message
/testcases/kernel/controllers/cpuacct/run_cpuacct_test.sh +380 -0
380 lines not on this page · raw message
/testcases/kernel/controllers/cpuacct/setup.sh +114 -0
114 lines not on this page · raw message
/testcases/kernel/controllers/Makefile +8 -0
@@ -7,6 +7,8 @@ CHECK_MEMCTL := $(shell grep -w memory / 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) CHECK_CPUSETCTL = $(shell grep -w cpuset /proc/cgroups 2>/dev/null|cut -f1) +CHECK_CPUACCTCTL := $(shell grep -w cpuacct /proc/cgroups 2>/dev/null|cut -f1) + endif ifdef CROSS_COMPILE
@@ -18,6 +20,7 @@ SUBDIRS += memctl SUBDIRS += io-throttle SUBDIRS += freezer SUBDIRS += cpuset +SUBDIRS += cpuacct else $(info "Kernel is not compiled with control cgroup support") endif
@@ -60,6 +63,11 @@ SUBDIRS += cpuset else $(info "Kernel is not compiled with cpuset resource controller support") endif +ifeq ($(CHECK_CPUACCTCTL),cpuacct) +SUBDIRS += cpuacct +else +$(info "Kernel is not compiled with cpuacct resource controller support") +endif endif # If at least one of the controllers is available then build libcontrollers.
/testcases/kernel/controllers/README +4 -0
@@ -51,6 +51,10 @@ libcontrollers -------------- This directory contains the library for cpucontroller testing. +cpuacct +----------- +Directory containing the cpu accounting controller testcases. + Makefile -------- The usual Makefile to conduct all the tests.
/testcases/kernel/controllers/test_controllers.sh +13 -0
@@ -43,6 +43,7 @@ then IOTHROTTLE_CONTROLLER=`grep -w blockio /proc/cgroups | cut -f1`; FREEZER=`grep -w freezer /proc/cgroups | cut -f1`; CPUSET_CONTROLLER=`grep -w cpuset /proc/cgroups | cut -f1` + CPUACCOUNT_CONTROLLER=`grep -w cpuacct /proc/cgroups | cut -f1` if [ "$CPU_CONTROLLER" = "cpu" ] then
@@ -115,10 +116,22 @@ then echo "Kernel does not support cpuset controller"; echo "Skipping all cpuset controller testcases...."; fi + + if [ "$CPUACCOUNT_CONTROLLER" = "cpuacct" ] + then + $LTPROOT/testcases/bin/run_cpuacct_test.sh 1; + $LTPROOT/testcases/bin/run_cpuacct_test.sh 2; + else + echo "Could not start cpu accounting controller test"; + echo "usage: run_cpuacct_test.sh $TEST_NUM "; + echo "Skipping the cpu accounting controller test..."; + fi + else echo "CONTROLLERS TESTCASES: WARNING" echo "Kernel does not support for control groups"; echo "Skipping all controllers testcases...."; + fi exit 0;
Results:
# ./run_cpuacct_test.sh 1 Cleanup called TEST 1:CPU ACCOUNTING CONTROLLER TESTING RUNNING SETUP..... TEST STARTED: Please avoid using system while this test executes
cpuacct.usage for Parent cgroup is 5069122828 cpuacct.usage for Child cgroup is 5069122828 TPASS CPU Accounting Controller:cpuacct.usage PASSED
cpuacct.usage_percpu for Parent cgroup : 5069122828 cpuacct.usage_percpu for Child cgroup : 5069122828 TPASS CPU Accounting Controller:cpuacct.usage_percpu PASSED
cpuacct.stat for Parent cgroup is user 81 : system 416 cpuacct.stat for Child cgroup is user 81 : system 416 TPASS CPU Accounting Controller:cpuacct.stat PASSED
CPU Accounting Controller test executed successfully Cleanup called
./run_cpuacct_test.sh 2
Cleanup called
TEST 2:CPU ACCOUNTING CONTROLLER TESTING
RUNNING SETUP.....
TEST STARTED: Please avoid using system while this test executes
cpuacct.usage for Parent cgroup : 19946799644 cpuacct.usage for Child cgroup : 19946799644 TPASS CPU Accounting Controller:cpuacct.usage PASSED
cpuacct.usage_percpu for Parent cgroup : 19946799644 cpuacct.usage_percpu for Child cgroup : 19946799644 TPASS CPU Accounting Controller:cpuacct.usage_percpu PASSED
cpuacct.stat for Parent cgroup : 295::1489 cpuacct.stat for Child cgroup : 295::1489 TPASS CPU Accounting Controller:cpuacct.stat PASSED
CPU Accounting Controller test executed successfully Cleanup called
Thanks
Signature · 12 lines
Rajasekhar Duddu ([email protected]), Linux on System z - CSVT, IBM LTC, Bangalore. ------------------------------------------------------------------------------ Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day trial. Simplify your report design, integration and deployment - and focus on what you do best, core application coding. Discover what's new with Crystal Reports now. http://p.sf.net/sfu/bobj-july _______________________________________________ Ltp-list mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/ltp-list
Hey,
Thanks for sending that update once again. But still issues remain to be addressed:
1) # ls -l testcases/kernel/controllers/cpuacct/ total 72
-rwxr-xr-x 1 root root 4903 Aug 13 23:08 cpuacct_task
-rw-r--r-- 1 root root 121 Aug 13 23:05 cpuacct_task.c
-rw-r--r-- 1 root root 1665 Aug 13 23:05 cpuacct_testplan.txt
-rw-r--r-- 1 root root 377 Aug 13 23:05 Makefile
-rw-r--r-- 1 root root 1611 Aug 13 23:05 README -rwxr-xr-x 2 root root 11213 Aug 13 23:08 run_cpuacct_test.sh -rwxr-xr-x 2 root root 5075 Aug 13 23:05 setup.sh
You cannot have a generic file called "setup.sh" and then install it over to "$LTPROOT/testcases/bin/". There are many tests which will try to do the same and somebodyś "setup.sh" will be finally replaced by the other at "$LTPROOT/testcases/bin/". So, replace this file name with something more specific like "run_cpuacct_test_setup.sh", which is more meaningful.
2) The test results are not encouraging though. You have tried to directly run it from by (cd testcases/bin/) and then:
# ./run_cpuacct_test.sh 1 # ./run_cpuacct_test.sh 2
which is not correct. If you want to run just the CPUACCOUNTING controllers without the need to run the entire controller tests through test_controller.sh, then create a following file like:
# cat runtest/cpuacct CPUACCT01 $LTPROOT/testcases/bin/run_cpuacct_test.sh 1 CPUACCT02 $LTPROOT/testcases/bin/run_cpuacct_test.sh 2
Then try with:
./runltp -f cpuacct
But i get the following output on my machine:
<<<test_start>>>
tag=CPUACCT01 stime=1250185313 cmdline="$LTPROOT/testcases/bin/run_cpuacct_test.sh 1" contacts=""
analysis=exit
<<<test_output>>>
Cleanup called
TEST 1:CPU ACCOUNTING CONTROLLER TESTING
RUNNING SETUP.....
TEST STARTED: Please avoid using system while this test executes
gcc: /root/subrata/ltp/ltp-full-20090731/testcases/bin/cpuacct_task.c:
No such file or directory
gcc: no input files
TFAIL Task file cpuacct_task.c not compiled
Please check Makefile Exiting test
<<<execution_status>>>
initiation_status="ok"
duration=0 termination_type=exited termination_id=255 corefile=no cutime=3 cstime=11
<<<test_end>>>
<<<test_start>>>
tag=CPUACCT02 stime=1250185313 cmdline="$LTPROOT/testcases/bin/run_cpuacct_test.sh 2" contacts=""
analysis=exit
<<<test_output>>>
incrementing stop
Cleanup called
TEST 2:CPU ACCOUNTING CONTROLLER TESTING
RUNNING SETUP.....
TEST STARTED: Please avoid using system while this test executes
gcc: /root/subrata/ltp/ltp-full-20090731/testcases/bin/cpuacct_task.c:
No such file or directory
gcc: no input files
TFAIL Task file cpuacct_task.c not compiled
Please check Makefile Exiting test
Cleanup called
<<<execution_status>>>
initiation_status="ok"
duration=1 termination_type=exited termination_id=255 corefile=no cutime=5 cstime=13
<<<test_end>>>
What has gcc got to do during test run ??
Your makefile says that "testcases/kernel/controllers/cpuacct/cpuacct_task" will get installed at "testcases/bin/", but i do not find it after "make install", however "run_cpuacct_test.sh" was present at "testcases/bin/". Though i manually copied "testcases/kernel/controllers/cpuacct/cpuacct_task" to "testcases/bin/", still i get the above output. Please fix this and resend.
Regards--
Subrata
Quoted 774 lines · Rajasekhar Duddu
Hi Subrata, I have done the changes to the patch as you have suggested, please review it and let me know if it needs any changes thanku.
I am psoting the results also here.
Signed-off-by Duddu Rajasekhar<[email protected]>diff -rupN
ltp-full-20090731//testcases/kernel/controllers/cpuacct/cpuacct_task.cltp-full-20090731.src//testcases/kernel/controllers/cpuacct/cpuacct_task.c/testcases/kernel/controllers/cpuacct/cpuacct_task.c +14
-0@@ -0,0 +1,14 @@ +#include <stdio.h> + +int main (void ) +{ +FILE *fp; + +while (1 ) { + fp =fopen ("txt.x" ,"w" ); +fclose (fp); + } +return 0 ; +} + +diff -rupN
ltp-full-20090731//testcases/kernel/controllers/cpuacct/cpuacct_testplan.txtltp-full-20090731.src//testcases/kernel/controllers/cpuacct/cpuacct_testplan.txt/testcases/kernel/controllers/cpuacct/cpuacct_testplan.txt +44
-0@@ -0,0 +1,44 @@ +The CPU Accounting controller testplan includes a complete set of +testcases that test the CPU Accounting controller in different scenarios. + + +TESTCASE DESCRIPTION: +==================== + +These tests will check if the cpu usage of the child cgroup is +getting reflected in the parent cgroup.Reports PASS if the cpu +usage is same for both the cgroups and FAIL if they differ. + +In these tests cpu usage of the tasks running in a group is read in +terms of 3 different stat values. + +'cpuacct.usage' gives the current cpu usage of the task running +in the group. +'cpuacct.usage_percpu' gives the cpu usage of each cpu. +'cpuacct.stat' gives the user and system cpu usage of the task running +in the group. + +Test01: STAT CHECK TEST +------------------------------- +This test is run by running a task in the child group and reading it's stat +values and comparing them with the parent group's stat values. + +Test02: STAT CHECK TEST +------------------------------- +This test is run by running num_online_cpus number of tasks in 2 child groups, +adding the stat values from the child groups and comparing them with the +parent's stat values. + +The values reported for user and system time in cpuacct.stat is not very +accurate and they can vary from the actual values by Threshold*num_online_cpus in the +worst case. +Where Threshold T = max(num_online_cpus^2, 32) + +In this test case, we allow for a max difference between actual and reported +values to be 2T. If the difference between parent's value and children's value +is greater than 2T, we mark the test as failed. + + +For any other information please refer to +Documentation/controllers/cpuacct.txt in kernel documentation. +diff -rupN ltp-full-20090731//testcases/kernel/controllers/cpuacct/Makefile ltp-full-20090731.src//testcases/kernel/controllers/cpuacct/Makefile
/testcases/kernel/controllers/cpuacct/Makefile +16
-0@@ -0,0 +1,16 @@ +CFLAGS += -Wall +CPPFLAGS += -I../../../../include -I../libcontrollers +LDLIBS += -lm -L../../../../lib/ -L../libcontrollers -lcontrollers -lltp + +SRCS = $(wildcard *.c) + +TARGETS = $(patsubst %.c,%,$(SRCS)) + +all: $(TARGETS) + +clean: + rm -f $(TARGETS) *.o + +install: + @set -e; for i in $(TARGETS) run_cpuacct_test.sh setup.sh; do ln -f $$i ../../../bin/$$i ; chmod +x $$i ; done +diff -rupN ltp-full-20090731//testcases/kernel/controllers/cpuacct/README ltp-full-20090731.src//testcases/kernel/controllers/cpuacct/README
/testcases/kernel/controllers/cpuacct/README +51
-0@@ -0,0 +1,51 @@ +TEST SUITE: + +The directory cpuacct contains the tests related to cpu accounting controller. +More testcases are expected to be added in future. + +TESTS AIM: + +The aim of the tests is to test cpu accounting controller functionality. + +FILES DESCRIPTION: + +cpuacct_task.c +--------------- +This is the task which is run for eating up the cpu time. + + +setup.sh +---------- +This file contains the functions which are common for all the tests. For ex. +the setup and cleanup functions which do the setup for running the test and do +the cleanup once the test finishes. The setup() function creates /dev/cpuacct +directory and mounts cgroup filesystem on it with accounting controller. It +then creates a number(n) of groups in /dev/cpuacct. The cleanup function does a +complete cleanup of the system. + +Most of the error scenarios have been taken care of for a sane cleanup of the +system. However if cleanup fails in any case, just manually execute the +commands written in cleanup function in setup.sh. +One of the most common causes of failed cleanup is that you have done cd into +any of the groups in controller dir tree. + +run_cpuacct_test.sh +------------------ +This script creates different scenarios for cpu accounting controller testing and +starting (n) tasks in different groups to do some cpu allocations etc. It +checks for the cpu usage of the groups and reports test pass/fail accordingly. + +Makefile +-------- + +The usual makefile for this directory + +PASS/FAIL CRITERION: +================== +The test cases are intelligent enough in deciding the pass or failure of a +test. + +README: +-------- +The one you have gone through. +diff -rupN
ltp-full-20090731//testcases/kernel/controllers/cpuacct/run_cpuacct_test.shltp-full-20090731.src//testcases/kernel/controllers/cpuacct/run_cpuacct_test.sh/testcases/kernel/controllers/cpuacct/run_cpuacct_test.sh +380
-0@@ -0,0 +1,380 @@ +#!/bin/bash +# usage ./run_cpuacct_test.sh $TEST_NUM +############################################################################# +# Copyright (c) International Business Machines Corp., 2009 # +# # +# 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 # +# # +############################################################################# +# Name Of File: run_cpuacct_test.sh # +# # +# Description: This file runs the setup for testing different cpu acctount # +# controller features. After setup it runs diff test cases in # +# diff setup. # +# # +# Test 01: Tests Cpu usage of Hierarchical cgroups # +# # +# Precaution: Avoid system use by other applications/users to get fair and# +# appropriate results (avoid unnecessary killing of # +# application) # +# # +# Author: Rajasekhar Duddu <[email protected]> # +# # +# History: # +# # +# DATE NAME EMAIL DESC # +# # +# 14/07/09 Rajasekhar D <[email protected]> Created this test # +# # +############################################################################# + +export TCID="cpuacct_test01"; +export TST_TOTAL=1; +export TST_COUNT=1; + +TEST_NUM=$1; +SCRIPT_PID=$$; +RC=0; +PWD=`pwd`; + +cd $LTPROOT/testcases/bin/ 2> /dev/null +. setup.sh + +if [ "$USER" != root ]; then + tst_brkm TBROK ignored "Test must be run as root" + exit 0 +fi + +tst_kvercmp 2 6 30 2> /dev/null +if [ $? -eq 0 ]; then + tst_brkm TBROK ignored "Test should be run with kernel 2.6.30 or newer" + exit 0 +fi + +task_kill 2> /dev/null +cleanup + +mes="CPU Accounting Controller" +cg_path="/dev/cpuacct"; +num_online_cpus=`cat /proc/cpuinfo | grep -w processor | wc -l` + +#Function to create tasks equal to num_online_cpus. +nr_tasks () +{ + $PWD/cpuacct_task & + pid=$! +} + +#Function to caluculate the threshold value. +get_threshold () +{ + num_online_cpus=`expr $num_online_cpus \* $num_online_cpus` + if [ $num_online_cpus -le 32 ] + then + threshold=32 + else + threshold=$num_online_cpus + fi + threshold=`expr $threshold \* 2` +} + +#Function which is called for reading the cpuacct.usage_percpu stat value +#for Parent and Child cgroups. +per_cpu_usage () +{ + attrc=0 + attrp=0 + i=0 + k=0 + while read line + do + j=0 + for k in $line + do + j=`expr $j + $k` + done + if [ "$i" == "0" ] + then + attrp=$j + i=`expr $i + 1` + else + attrc=`expr $j + $attrc` + fi + done < "./tmp2" +} + +#Function which verifies the cpu accounting of the Parent and the Child cgroups. +check_attr() +{ + + if [ "$1" == "1" ] + then + if [ "$2" == "cpuacct.stat" ] + then + attr1="`sed -n 1p tmp2`" + attr2="`sed -n 2p tmp2`" + attr3="`sed -n 3p tmp2`" + attr4="`sed -n 4p tmp2`" + echo + echo "$2 for Parent cgroup is $attr1 : $attr2" + echo "$2 for Child cgroup is $attr3 : $attr4" + + if [ "$attr1" == "$attr3" ] && [ "$attr2" == "$attr4" ] + then + RC=$? + echo "TPASS $mes:$2 PASSED" + + else + RC=$? + echo "TFAIL $mes:$2 FAILED" + fi + elif [ "$2" == "cpuacct.usage_percpu" ] + then + per_cpu_usage + echo + echo "$2 for Parent cgroup : $attrp" + echo "$2 for Child cgroup : $attrc" + if [ "$attrp" == "$attrc" ] + then + RC=$? + echo "TPASS $mes:$2 PASSED" + else + RC=$? + echo "TFAIL $mes:$2 FAILED" + fi + else + attr1="`sed -n 1p tmp2`" + attr2="`sed -n 2p tmp2`" + + echo + echo "$2 for Parent cgroup is $attr1" + echo "$2 for Child cgroup is $attr2" + if [ "$attr1" == "$attr2" ] + then + RC=$? + echo "TPASS $mes:$2 PASSED" + else + RC=$? + echo "TFAIL $mes:$2 FAILED" + fi + + fi + else + + if [ "$2" == "cpuacct.stat" ] + then + attr0="`sed -n 1p tmp2 | cut -d" " -f2`" + attr1="`sed -n 2p tmp2 | cut -d" " -f2`" + attr2="`sed -n 3p tmp2 | cut -d" " -f2`" + attr3="`sed -n 4p tmp2 | cut -d" " -f2`" + attr4="`sed -n 5p tmp2 | cut -d" " -f2`" + attr5="`sed -n 6p tmp2 | cut -d" " -f2`" + attr_usr=`expr $attr2 + $attr4 ` + attr_sys=`expr $attr3 + $attr5` + echo + echo "$2 for Parent cgroup : $attr0::$attr1" + echo "$2 for Child cgroup : $attr_usr::$attr_sys" + get_threshold + diff_usr=`expr $attr0 - $attr_usr ` + [ ${diff_usr} -le 0 ] && diff_usr=$((0 - $diff_usr)) + + diff_sys=`expr $attr1 - $attr_sys` + [ ${diff_sys} -le 0 ] && diff_sys=$((0 - $diff_sys)) + if [ "$diff_usr" -le "$threshold" ] && \ + [ "$diff_sys" -le "$threshold" ] + then + RC=$? + echo "TPASS $mes:$2 PASSED" + else + RC=$? + echo "TFAIL $mes:$2 FAILED" + fi + elif [ "$2" == "cpuacct.usage_percpu" ] + then + per_cpu_usage + echo + echo "$2 for Parent cgroup : $attrp" + echo "$2 for Child cgroup : $attrc" + if [ "$attrp" == "$attrc" ] + then + RC=$? + echo "TPASS $mes:$2 PASSED" + else + RC=$? + echo "TFAIL $mes:$2 FAILED" + fi + + else + attr0="`sed -n 1p tmp2`" + attr1="`sed -n 2p tmp2`" + attr2="`sed -n 3p tmp2`" + attr=`expr $attr1 + $attr2` + echo + echo "$2 for Parent cgroup : $attr0" + echo "$2 for Child cgroup : $attr" + if [ "$attr0" == "$attr" ] + then + RC=$? + echo "TPASS $mes:$2 PASSED" + else + RC=$? + echo "TFAIL $mes:$2 FAILED" + fi + fi + fi +} + +echo "TEST $TEST_NUM:CPU ACCOUNTING CONTROLLER TESTING"; +echo "RUNNING SETUP....."; +setup; + +echo "TEST STARTED: Please avoid using system while this test executes"; + + +status=0 +case ${TEST_NUM} in + "1" ) + gcc -o $PWD/cpuacct_task $PWD/cpuacct_task.c + ls $PWD/cpuacct_task &> /dev/null + if [ $? -ne 0 ] + then + echo "TFAIL Task file cpuacct_task.c not compiled" + echo "Please check Makefile Exiting test" + exit -1 + fi + $PWD/cpuacct_task & + pid=$! + + mkdir $cg_path/group_1 2> /dev/null + mkdir $cg_path/group_1/group_11/ 2> /dev/null + if [ $? -ne 0 ] + then + echo "TFAIL Cannot create cpuacct cgroups Exiting Test" + cleanup + exit -1 + fi + echo $pid > /$cg_path/group_1/group_11/tasks 2> /dev/null + if [ $? -ne 0 ] + then + echo "TFAIL Not able to move a task to the cgroup" + echo "Exiting Test" + cleanup 2> /dev/null + exit -1 + fi + sleep 5 + task_kill 2> /dev/null + for i in cpuacct.usage cpuacct.usage_percpu cpuacct.stat + do + cat $cg_path/group_1/$i \ + $cg_path/group_1/group_11/$i > tmp2 + check_attr $1 $i + done + if [ $RC -ne 0 ] + then + status=1 + fi + + if [ $status -eq 0 ] + then + echo + echo "$mes test executed successfully" + cleanup 2> /dev/null + cd $PWD + exit 0 + else + echo + echo "$mes test execution Failed" + cleanup 2> /dev/null + cd $PWD + exit -1 + fi + ;; + + "2" ) + mkdir $cg_path/group_1 2> /dev/null + mkdir $cg_path/group_1/group_11 2> /dev/null + mkdir $cg_path/group_1/group_12 2> /dev/null + if [ $? -ne 0 ] + then + echo "TFAIL Cannot create cpuacct cgroups Exiting Test" + cleanup 2> /dev/null + exit -1 + fi + + gcc -o $PWD/cpuacct_task $PWD/cpuacct_task.c + ls $PWD/cpuacct_task &> /dev/null + if [ $? -ne 0 ] + then + echo "TFAIL Task file cpuacct_task.c not compiled" + echo "Please check Makefile Exiting test" + cleanup 2> /dev/null + exit -1 + fi + for (( m=0 ; m<=$num_online_cpus ; m++ )) + do + nr_tasks + echo $pid > $cg_path/group_1/group_11/tasks + if [ $? -ne 0 ] + then + echo "TFAIL Not able to move task to cgroup" + echo "Exiting Test" + cleanup 2> /dev/null + exit -1 + fi + nr_tasks + echo $pid >$cg_path/group_1/group_12/tasks + if [ $? -ne 0 ] + then + echo "TFAIL Not able to move task to cgroup" + echo "Exiting Test" + cleanup 2> /dev/null + exit -1 + fi + sleep 2 + done + task_kill 2> /dev/null + for i in cpuacct.usage cpuacct.usage_percpu cpuacct.stat + do + cat $cg_path/group_1/$i \ + $cg_path/group_1/group_11/$i \ + $cg_path/group_1/group_12/$i >tmp2 + check_attr $1 $i + done + if [ $RC -ne 0 ] + then + status=1 + fi + if [ $status -eq 0 ] + then + echo + echo "$mes test executed successfully" + cleanup 2> /dev/null + cd $PWD + exit 0 + else + echo + echo "$mes test execution Failed" + cleanup 2> /dev/null + cd $PWD + exit -1 + fi + + ;; + * ) + usage + exit -1 + ;; + esac +diff -rupN
ltp-full-20090731//testcases/kernel/controllers/cpuacct/setup.shltp-full-20090731.src//testcases/kernel/controllers/cpuacct/setup.sh/testcases/kernel/controllers/cpuacct/setup.sh +114
-0@@ -0,0 +1,114 @@ +#!/bin/bash +# usage ./setup.sh + +################################################################################ +# Copyright (c) International Business Machines Corp., 2009 # +# # +# 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 # +# # +################################################################################ +################################################################################ +# Name Of File: setup.sh # +# # +# Description: This file has functions for the setup for testing cpu account # +# controller. setup includes creating controller device, # +# mounting it with cgroup filesystem with option cpu account # +# and creating groups in it. # +# # +# Functions: setup(): creaes /dev/cpuacct, mounts cgroup fs on it, creates # +# groups in that etc. # +# usage(): Shows the usage of this file. # +# cleanup(): Does full system cleanup # +# # +# Precaution: Avoid system use by other applications/users to get fair and # +# appropriate results (avoid unnecessary killing of applicatio) # +# # +# Author: Rajasekhar Duddu <[email protected]> # +# # +# History: # +# # +# DATE NAME EMAIL DESC # +# # +# 14/07/09 Rajasekhar D <[email protected]> Created this test # +# # +################################################################################ + +# The cleanup function +cleanup () +{ + echo "Cleanup called" + rm -rf txt.x 2> /dev/null + rm -f cpuacct_task 2>/dev/null + rmdir /dev/cpuacct/group*/group* 2> /dev/null + rmdir /dev/cpuacct/group* 2> /dev/null + umount /dev/cpuacct/ 2> /dev/null + rmdir /dev/cpuacct 2> /dev/null + rm -rf tmp2 2> /dev/null +} +task_kill () +{ + for i in `ps -e | grep cpuacct_task | cut -d" " -f1` + do + kill -SIGUSR1 $i + done + rm -rf $PWD/txt.x 2> /dev/null + rm -f $PWD/cpuacct_task[0-8] 2>/dev/null +} +#Create /dev/cpuacct & mount the cgroup file system with +#cpu accounting controller + +#clean any group created eralier (if any) + +setup () +{ + if [ -e /dev/cpuacct ] + then + echo "WARN:/dev/cpuacct already exist..overwriting" + rmdir /dev/cpuacct/group*/group* 2> /dev/null + rmdir /dev/cpuacct/group* 2> /dev/null + umount /dev/cpuacct/ 2> /dev/null + rmdir /dev/cpuacct 2> /dev/null + + mkdir /dev/cpuacct + else + mkdir /dev/cpuacct + fi + mount -t cgroup -ocpuacct none /dev/cpuacct 2> /dev/null + if [ $? -ne 0 ] + then + echo "TFAIL: Could not mount cgroup filesystem" + echo "Exiting test" + cleanup + exit -1 + fi + + # Group created earlier may again be visible if not cleaned properly. + #so clean them + if [ -e /dev/cpuacct/group_1 ] + then + rmdir /dev/cpuacct/group*/group* 2> /dev/null + rmdir /dev/cpuacct/group* 2> /dev/null + echo "WARN: Earlier groups found and removed..."; + fi + +} + +# The usage of the script file +usage() +{ + echo "Could not start cpu account controller test"; + echo "usage: run_cpuacct_test.sh $TEST_NUM "; + echo "Skipping the cpu account controller test..."; +}diff -rupN ltp-full-20090731//testcases/kernel/controllers/Makefile ltp-full-20090731.src//testcases/kernel/controllers/Makefile
/testcases/kernel/controllers/Makefile +8
-0@@ -7,6 +7,8 @@ CHECK_MEMCTL := $(shell grep -w memory / 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) CHECK_CPUSETCTL = $(shell grep -w cpuset /proc/cgroups 2>/dev/null|cut -f1) +CHECK_CPUACCTCTL := $(shell grep -w cpuacct /proc/cgroups 2>/dev/null|cut -f1) + endif ifdef CROSS_COMPILE@@ -18,6 +20,7 @@ SUBDIRS += memctl SUBDIRS += io-throttle SUBDIRS += freezer SUBDIRS += cpuset +SUBDIRS += cpuacct else $(info "Kernel is not compiled with control cgroup support") endif@@ -60,6 +63,11 @@ SUBDIRS += cpuset else $(info "Kernel is not compiled with cpuset resource controller support") endif +ifeq ($(CHECK_CPUACCTCTL),cpuacct) +SUBDIRS += cpuacct +else +$(info "Kernel is not compiled with cpuacct resource controller support") +endif endif # If at least one of the controllers is available then build libcontrollers.diff -rupN ltp-full-20090731//testcases/kernel/controllers/README ltp-full-20090731.src//testcases/kernel/controllers/README
/testcases/kernel/controllers/README +4
-0@@ -51,6 +51,10 @@ libcontrollers -------------- This directory contains the library for cpucontroller testing. +cpuacct +----------- +Directory containing the cpu accounting controller testcases. + Makefile -------- The usual Makefile to conduct all the tests.diff -rupN
ltp-full-20090731//testcases/kernel/controllers/test_controllers.shltp-full-20090731.src//testcases/kernel/controllers/test_controllers.sh/testcases/kernel/controllers/test_controllers.sh +13
-0@@ -43,6 +43,7 @@ then IOTHROTTLE_CONTROLLER=`grep -w blockio /proc/cgroups | cut -f1`; FREEZER=`grep -w freezer /proc/cgroups | cut -f1`; CPUSET_CONTROLLER=`grep -w cpuset /proc/cgroups | cut -f1` + CPUACCOUNT_CONTROLLER=`grep -w cpuacct /proc/cgroups | cut -f1` if [ "$CPU_CONTROLLER" = "cpu" ] then@@ -115,10 +116,22 @@ then echo "Kernel does not support cpuset controller"; echo "Skipping all cpuset controller testcases...."; fi + + if [ "$CPUACCOUNT_CONTROLLER" = "cpuacct" ] + then + $LTPROOT/testcases/bin/run_cpuacct_test.sh 1; + $LTPROOT/testcases/bin/run_cpuacct_test.sh 2; + else + echo "Could not start cpu accounting controller test"; + echo "usage: run_cpuacct_test.sh $TEST_NUM "; + echo "Skipping the cpu accounting controller test..."; + fi + else echo "CONTROLLERS TESTCASES: WARNING" echo "Kernel does not support for control groups"; echo "Skipping all controllers testcases...."; + fi exit 0;Results:
# ./run_cpuacct_test.sh 1 Cleanup called TEST 1:CPU ACCOUNTING CONTROLLER TESTING RUNNING SETUP..... TEST STARTED: Please avoid using system while this test executescpuacct.usage for Parent cgroup is 5069122828 cpuacct.usage for Child cgroup is 5069122828 TPASS CPU Accounting Controller:cpuacct.usage PASSED
cpuacct.usage_percpu for Parent cgroup : 5069122828 cpuacct.usage_percpu for Child cgroup : 5069122828 TPASS CPU Accounting Controller:cpuacct.usage_percpu PASSED
cpuacct.stat for Parent cgroup is user 81 : system 416 cpuacct.stat for Child cgroup is user 81 : system 416 TPASS CPU Accounting Controller:cpuacct.stat PASSED
CPU Accounting Controller test executed successfully Cleanup called
./run_cpuacct_test.sh 2
Cleanup called
TEST 2:CPU ACCOUNTING CONTROLLER TESTING
RUNNING SETUP.....
TEST STARTED: Please avoid using system while this test executescpuacct.usage for Parent cgroup : 19946799644 cpuacct.usage for Child cgroup : 19946799644 TPASS CPU Accounting Controller:cpuacct.usage PASSED
cpuacct.usage_percpu for Parent cgroup : 19946799644 cpuacct.usage_percpu for Child cgroup : 19946799644 TPASS CPU Accounting Controller:cpuacct.usage_percpu PASSED
Quoted 8 lines
cpuacct.stat for Parent cgroup : 295::1489 cpuacct.stat for Child cgroup : 295::1489 TPASS CPU Accounting Controller:cpuacct.stat PASSED
CPU Accounting Controller test executed successfully Cleanup called
Thanks
------------------------------------------------------------------------------
Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day trial. Simplify your report design, integration and deployment - and focus on what you do best, core application coding. Discover what's new with Crystal Reports now. http://p.sf.net/sfu/bobj-july
_______________________________________________
Ltp-list mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/ltp-list
n Thu, Aug 13, 2009 at 10:18 AM, Subrata
Quoted 84 lines · Modak
Hey,
Thanks for sending that update once again. But still issues remain to be addressed:
1) # ls -l testcases/kernel/controllers/cpuacct/
total 72(quoted diff) +0
-7-rwxr-xr-x 1 root root 4903 Aug 13 23:08 cpuacct_task -rw-r--r-- 1 root root 121 Aug 13 23:05 cpuacct_task.c -rw-r--r-- 1 root root 1665 Aug 13 23:05 cpuacct_testplan.txt -rw-r--r-- 1 root root 377 Aug 13 23:05 Makefile -rw-r--r-- 1 root root 1611 Aug 13 23:05 README -rwxr-xr-x 2 root root 11213 Aug 13 23:08 run_cpuacct_test.sh -rwxr-xr-x 2 root root 5075 Aug 13 23:05 setup.shYou cannot have a generic file called "
setup.sh" and then install it over to "$LTPROOT/testcases/bin/". There are many tests which will try to do the same and somebodyś "setup.sh" will be finally replaced by the other at "$LTPROOT/testcases/bin/". So, replace this file name with something more specific like "run_cpuacct_test_setup.sh", which is more meaningful.2) The test results are not encouraging though. You have tried to directly run it from by (cd testcases/bin/) and then:
# ./run_cpuacct_test.sh 1 # ./run_cpuacct_test.sh 2which is not correct. If you want to run just the CPUACCOUNTING controllers without the need to run the entire controller tests through
test_controller.sh, then create a following file like:# cat runtest/cpuacct CPUACCT01 $LTPROOT/testcases/bin/run_cpuacct_test.sh 1 CPUACCT02 $LTPROOT/testcases/bin/run_cpuacct_test.sh 2Then try with:
./runltp -f cpuacct
But i get the following output on my machine:
<<<
test_start>>>
tag=CPUACCT01 stime=1250185313 cmdline="$LTPROOT/testcases/bin/run_cpuacct_test.sh 1" contacts=""
analysis=exit
<<<test_output>>>
Cleanup called
TEST 1:CPU ACCOUNTING CONTROLLER TESTING
RUNNING SETUP.....
TEST STARTED: Please avoid using system while this test executes
gcc:/root/subrata/ltp/ltp-full-20090731/testcases/bin/cpuacct_task.c:
No such file or directory
gcc: no input files
TFAIL Task filecpuacct_task.cnot compiled
Please checkMakefileExiting test
<<<execution_status>>>
initiation_status="ok"
duration=0 termination_type=exited termination_id=255 corefile=no cutime=3 cstime=11
<<<test_end>>>
<<<test_start>>>
tag=CPUACCT02 stime=1250185313 cmdline="$LTPROOT/testcases/bin/run_cpuacct_test.sh 2" contacts=""
analysis=exit
<<<test_output>>>
incrementing stop
Cleanup called
TEST 2:CPU ACCOUNTING CONTROLLER TESTING
RUNNING SETUP.....
TEST STARTED: Please avoid using system while this test executes
gcc:/root/subrata/ltp/ltp-full-20090731/testcases/bin/cpuacct_task.c:
No such file or directory
gcc: no input files
TFAIL Task filecpuacct_task.cnot compiled
Please checkMakefileExiting test
Cleanup called
<<<execution_status>>>
initiation_status="ok"
duration=1 termination_type=exited termination_id=255 corefile=no cutime=5 cstime=13
<<<test_end>>>
Quoted 8 lines
What has gcc got to do during test run ??
Your makefile says that "testcases/kernel/controllers/cpuacct/cpuacct_task" will get installed at "testcases/bin/", but i do not find it after "make install", however "run_cpuacct_test.sh" was present at "testcases/bin/". Though i manually copied "testcases/kernel/controllers/cpuacct/cpuacct_task" to "testcases/bin/", still i get the above output. Please fix this and resend.
Duddu,
I'd reject this right away:
+case ${TEST_NUM} in
+ "1" )
+ gcc -o $PWD/cpuacct_task $PWD/cpuacct_task.c + ls $PWD/cpuacct_task &> /dev/null + if [ $? -ne 0 ] + then + echo "TFAIL Task file cpuacct_task.c not compiled" + echo "Please check Makefile Exiting test" + exit -1
+ fi
If your testcase can't live without gcc, then it needs to be
redesigned. I will do the Makefile work making things conform to a proper standard, but I don't want to have to go hacking a bunch of scripts if I can help it...
Thanks,
-Garrett
Quoted 6 lines · Rajasekhar Duddu
Quoted 5 lines
Hi Subrata, I have done the changes to the patch as you have suggested, please review it and let me know if it needs any changes thanku.
I am psoting the results also here.
------------------------------------------------------------------------------
Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day trial. Simplify your report design, integration and deployment - and focus on what you do best, core application coding. Discover what's new with Crystal Reports now. http://p.sf.net/sfu/bobj-july
_______________________________________________
Ltp-list mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/ltp-list
Hi here is the update cpuaccounting controller patch, in which I have modified it as per the earlier coments, please review this patch and let me know if it needs any more changes.
I am pasting the LOG also here for reveiwing it.
/runtest/cpuacct +2 -0
@@ -0,0 +1,2 @@ +CPUACCT01 $LTPROOT/testcases/bin/run_cpuacct_test.sh 1 +CPUACCT02 $LTPROOT/testcases/bin/run_cpuacct_test.sh 2
/testcases/kernel/controllers/cpuacct/cpuacct_setup.sh +113 -0
113 lines not on this page · raw message
/testcases/kernel/controllers/cpuacct/cpuacct_task01.c +14 -0
@@ -0,0 +1,14 @@ +#include <stdio.h> + +int main (void ) +{ +FILE *fp; + +while (1 ) { + fp =fopen ("txt.x" ,"w" ); +fclose (fp); + } +return 0 ; +} + +
/testcases/kernel/controllers/cpuacct/cpuacct_testplan.txt +44 -0
44 lines not on this page · raw message
/testcases/kernel/controllers/cpuacct/Makefile +16 -0
@@ -0,0 +1,16 @@ +CFLAGS += -Wall +CPPFLAGS += -I../../../../include -I../libcontrollers +LDLIBS += -lm -L../../../../lib/ -L../libcontrollers -lcontrollers -lltp + +SRCS = $(wildcard *.c) + +TARGETS = $(patsubst %.c,%,$(SRCS)) + +all: $(TARGETS) + +clean: + rm -f $(TARGETS) *.o + +install: + @set -e; for i in $(TARGETS) run_cpuacct_test.sh cpuacct_setup.sh cpuacct_task01 ; do ln -f $$i ../../../bin/$$i ; chmod +x $$i ; done +
/testcases/kernel/controllers/cpuacct/README +51 -0
51 lines not on this page · raw message
/testcases/kernel/controllers/cpuacct/run_cpuacct_test.sh +385 -0
385 lines not on this page · raw message
/testcases/kernel/controllers/Makefile +7 -0
@@ -7,6 +7,7 @@ CHECK_MEMCTL := $(shell grep -w memory / 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) CHECK_CPUSETCTL = $(shell grep -w cpuset /proc/cgroups 2>/dev/null|cut -f1) +CHECK_CPUACCTCTL := $(shell grep -w cpuacct /proc/cgroups 2>/dev/null|cut -f1) endif ifdef CROSS_COMPILE
@@ -17,6 +18,7 @@ SUBDIRS += memctl SUBDIRS += io-throttle SUBDIRS += freezer SUBDIRS += cpuset +SUBDIRS += cpuacct else $(info "Kernel is not compiled with control cgroup support") endif
@@ -58,6 +60,11 @@ SUBDIRS += cpuset else $(info "Kernel is not compiled with cpuset resource controller support") endif +ifeq ($(CHECK_CPUACCTCTL),cpuacct) +SUBDIRS += cpuacct +else +$(info "Kernel is not compiled with cpuacct resource controller support") +endif endif # If at least one of the controllers is available then build libcontrollers.
/testcases/kernel/controllers/README +4 -0
@@ -51,6 +51,10 @@ libcontrollers -------------- This directory contains the library for cpucontroller testing. +cpuacct +----------- +Directory containing the cpu accounting controller testcases. + Makefile -------- The usual Makefile to conduct all the tests.
/testcases/kernel/controllers/test_controllers.sh +10 -0
@@ -42,6 +42,7 @@ then IOTHROTTLE_CONTROLLER=`grep -w blockio /proc/cgroups | cut -f1`; FREEZER=`grep -w freezer /proc/cgroups | cut -f1`; CPUSET_CONTROLLER=`grep -w cpuset /proc/cgroups | cut -f1` + CPUACCOUNT_CONTROLLER=`grep -w cpuacct /proc/cgroups | cut -f1` if [ "$CPU_CONTROLLER" = "cpu" ] then
@@ -112,6 +113,15 @@ then echo "Kernel does not support cpuset controller"; echo "Skipping all cpuset controller testcases...."; fi + if [ "$CPUACCOUNT_CONTROLLER" = "cpuacct" ] + then + $LTPROOT/testcases/bin/run_cpuacct_test.sh 1; + $LTPROOT/testcases/bin/run_cpuacct_test.sh 2; + else + echo "Could not start cpu accounting controller test"; + echo "usage: run_cpuacct_test.sh $TEST_NUM "; + echo "Skipping the cpu accounting controller test..."; + fi else echo "CONTROLLERS TESTCASES: WARNING" echo "Kernel does not support for control groups";
LOG:
[root@p510 ltp-intermediate-20090822]# ./runltp -f cpuacct
Running tests.......
<<<test_start>>>
tag=CPUACCT01 stime=1251202954 cmdline="$LTPROOT/testcases/bin/run_cpuacct_test.sh 1" contacts=""
analysis=exit
<<<test_output>>>
Cleanup called
TEST 1:CPU ACCOUNTING CONTROLLER TESTING
RUNNING SETUP.....
TEST STARTED: Please avoid using system while this test executes
cpuacct.usage for Parent cgroup is 5016035936 cpuacct.usage for Child cgroup is 5016035936 TPASS CPU Accounting Controller:cpuacct.usage PASSED
cpuacct.usage_percpu for Parent cgroup : 5016035936 cpuacct.usage_percpu for Child cgroup : 5016035936 TPASS CPU Accounting Controller:cpuacct.usage_percpu PASSED
cpuacct.stat for Parent cgroup is user 94 : system 387 cpuacct.stat for Child cgroup is user 94 : system 387 TPASS CPU Accounting Controller:cpuacct.stat PASSED
CPU Accounting Controller test executed successfully Cleanup called
<<<execution_status>>>
initiation_status="ok"
duration=8 termination_type=exited termination_id=0 corefile=no cutime=114 cstime=399
<<<test_end>>>
<<<test_start>>>
tag=CPUACCT02 stime=1251202962 cmdline="$LTPROOT/testcases/bin/run_cpuacct_test.sh 2" contacts=""
analysis=exit
<<<test_output>>>
incrementing stop
Cleanup called
TEST 2:CPU ACCOUNTING CONTROLLER TESTING
RUNNING SETUP.....
TEST STARTED: Please avoid using system while this test executes
cpuacct.usage for Parent cgroup : 34281951552 cpuacct.usage for Child cgroup : 34281951552 TPASS CPU Accounting Controller:cpuacct.usage PASSED
cpuacct.usage_percpu for Parent cgroup : 34281951552 cpuacct.usage_percpu for Child cgroup : 34281951552 TPASS CPU Accounting Controller:cpuacct.usage_percpu PASSED
cpuacct.stat for Parent cgroup : 275::1691 cpuacct.stat for Child cgroup : 274::1690 TPASS CPU Accounting Controller:cpuacct.stat PASSED
CPU Accounting Controller test executed successfully Cleanup called
<<<execution_status>>>
initiation_status="ok"
duration=14 termination_type=exited termination_id=0 corefile=no cutime=296 cstime=1706
<<<test_end>>>
INFO: ltp-pan reported all tests PASS
LTP Version: LTP-20090731
###############################################################"
Done executing testcases."
LTP Version: LTP-20090731
###############################################################"[root@p510 ltp-intermediate-20090822]#
Signature · 12 lines
Rajasekhar Duddu ([email protected]), Linux on System z - CSVT, IBM LTC, Bangalore. ------------------------------------------------------------------------------ Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day trial. Simplify your report design, integration and deployment - and focus on what you do best, core application coding. Discover what's new with Crystal Reports now. http://p.sf.net/sfu/bobj-july _______________________________________________ Ltp-list mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/ltp-list
Hi Raj,
Quoted 8 lines · Rajasekhar Duddu
Hi here is the update cpuaccounting controller patch, in which I have modified it as per the earlier coments, please review this patch and let me know if it needs any more changes.
I am pasting the LOG also here for reveiwing it.
Signed-off-by Duddu Rajasekhar<[email protected]>
Thanks. The tests passed on my 2.6.30 kernel system this time. Checking your patches in. Thanks for making this contribution to LTP.
Regards--
Subrata
Quoted 798 lines
diff -rupN ltp//runtest/cpuacct ltp.src//runtest/cpuacct
/runtest/cpuacct +2
-0@@ -0,0 +1,2 @@ +CPUACCT01 $LTPROOT/testcases/bin/run_cpuacct_test.sh 1 +CPUACCT02 $LTPROOT/testcases/bin/run_cpuacct_test.sh 2diff -rupN
ltp//testcases/kernel/controllers/cpuacct/cpuacct_setup.shltp.src//testcases/kernel/controllers/cpuacct/cpuacct_setup.sh/testcases/kernel/controllers/cpuacct/cpuacct_setup.sh +113
-0@@ -0,0 +1,113 @@ +#!/bin/bash +# usage ./cpuacct_setup.sh + +################################################################################ +# Copyright (c) International Business Machines Corp., 2009 # +# # +# 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 # +# # +################################################################################ +################################################################################ +# Name Of File: setup.sh # +# # +# Description: This file has functions for the setup for testing cpu account # +# controller. setup includes creating controller device, # +# mounting it with cgroup filesystem with option cpu account # +# and creating groups in it. # +# # +# Functions: setup(): creaes /dev/cpuacct, mounts cgroup fs on it, creates # +# groups in that etc. # +# usage(): Shows the usage of this file. # +# cleanup(): Does full system cleanup # +# # +# Precaution: Avoid system use by other applications/users to get fair and # +# appropriate results (avoid unnecessary killing of applicatio) # +# # +# Author: Rajasekhar Duddu <[email protected]> # +# # +# History: # +# # +# DATE NAME EMAIL DESC # +# # +# 14/07/09 Rajasekhar D <[email protected]> Created this test # +# # +################################################################################ + +# The cleanup function +cleanup () +{ + echo "Cleanup called" + rm -rf txt* + rmdir /dev/cpuacct/group*/group* 2> /dev/null + rmdir /dev/cpuacct/group* 2> /dev/null + umount /dev/cpuacct/ 2> /dev/null + rmdir /dev/cpuacct 2> /dev/null + rm -rf tmp2 2> /dev/null +} +task_kill () +{ + for i in `ps -e | grep cpuacct_taski* | cut -d" " -f1` + do + kill -SIGUSR1 $i + done + sleep 1 + rm -rf txt* 2> /dev/null +} +#Create /dev/cpuacct & mount the cgroup file system with +#cpu accounting controller + +#clean any group created eralier (if any) + +setup () +{ + if [ -e /dev/cpuacct ] + then + echo "WARN:/dev/cpuacct already exist..overwriting" + rmdir /dev/cpuacct/group*/group* 2> /dev/null + rmdir /dev/cpuacct/group* 2> /dev/null + umount /dev/cpuacct/ 2> /dev/null + rmdir /dev/cpuacct 2> /dev/null + + mkdir /dev/cpuacct + else + mkdir /dev/cpuacct + fi + mount -t cgroup -ocpuacct none /dev/cpuacct 2> /dev/null + if [ $? -ne 0 ] + then + echo "TFAIL: Could not mount cgroup filesystem" + echo "Exiting test" + cleanup + exit -1 + fi + + # Group created earlier may again be visible if not cleaned properly. + #so clean them + if [ -e /dev/cpuacct/group_1 ] + then + rmdir /dev/cpuacct/group*/group* 2> /dev/null + rmdir /dev/cpuacct/group* 2> /dev/null + echo "WARN: Earlier groups found and removed..."; + fi + +} + +# The usage of the script file +usage() +{ + echo "Could not start cpu account controller test"; + echo "usage: run_cpuacct_test.sh $TEST_NUM "; + echo "Skipping the cpu account controller test..."; +}diff -rupN
ltp//testcases/kernel/controllers/cpuacct/cpuacct_task01.cltp.src//testcases/kernel/controllers/cpuacct/cpuacct_task01.c/testcases/kernel/controllers/cpuacct/cpuacct_task01.c +14
-0@@ -0,0 +1,14 @@ +#include <stdio.h> + +int main (void ) +{ +FILE *fp; + +while (1 ) { + fp =fopen ("txt.x" ,"w" ); +fclose (fp); + } +return 0 ; +} + +diff -rupN
ltp//testcases/kernel/controllers/cpuacct/cpuacct_testplan.txtltp.src//testcases/kernel/controllers/cpuacct/cpuacct_testplan.txt/testcases/kernel/controllers/cpuacct/cpuacct_testplan.txt +44
-0@@ -0,0 +1,44 @@ +The CPU Accounting controller testplan includes a complete set of +testcases that test the CPU Accounting controller in different scenarios. + + +TESTCASE DESCRIPTION: +==================== + +These tests will check if the cpu usage of the child cgroup is +getting reflected in the parent cgroup.Reports PASS if the cpu +usage is same for both the cgroups and FAIL if they differ. + +In these tests cpu usage of the tasks running in a group is read in +terms of 3 different stat values. + +'cpuacct.usage' gives the current cpu usage of the task running +in the group. +'cpuacct.usage_percpu' gives the cpu usage of each cpu. +'cpuacct.stat' gives the user and system cpu usage of the task running +in the group. + +Test01: STAT CHECK TEST +------------------------------- +This test is run by running a task in the child group and reading it's stat +values and comparing them with the parent group's stat values. + +Test02: STAT CHECK TEST +------------------------------- +This test is run by running num_online_cpus number of tasks in 2 child groups, +adding the stat values from the child groups and comparing them with the +parent's stat values. + +The values reported for user and system time in cpuacct.stat is not very +accurate and they can vary from the actual values by Threshold*num_online_cpus in the +worst case. +Where Threshold T = max(num_online_cpus^2, 32) + +In this test case, we allow for a max difference between actual and reported +values to be 2T. If the difference between parent's value and children's value +is greater than 2T, we mark the test as failed. + + +For any other information please refer to +Documentation/controllers/cpuacct.txt in kernel documentation. +diff -rupN ltp//testcases/kernel/controllers/cpuacct/Makefile ltp.src//testcases/kernel/controllers/cpuacct/Makefile
/testcases/kernel/controllers/cpuacct/Makefile +16
-0@@ -0,0 +1,16 @@ +CFLAGS += -Wall +CPPFLAGS += -I../../../../include -I../libcontrollers +LDLIBS += -lm -L../../../../lib/ -L../libcontrollers -lcontrollers -lltp + +SRCS = $(wildcard *.c) + +TARGETS = $(patsubst %.c,%,$(SRCS)) + +all: $(TARGETS) + +clean: + rm -f $(TARGETS) *.o + +install: + @set -e; for i in $(TARGETS) run_cpuacct_test.sh cpuacct_setup.sh cpuacct_task01 ; do ln -f $$i ../../../bin/$$i ; chmod +x $$i ; done +diff -rupN ltp//testcases/kernel/controllers/cpuacct/README ltp.src//testcases/kernel/controllers/cpuacct/README
/testcases/kernel/controllers/cpuacct/README +51
-0@@ -0,0 +1,51 @@ +TEST SUITE: + +The directory cpuacct contains the tests related to cpu accounting controller. +More testcases are expected to be added in future. + +TESTS AIM: + +The aim of the tests is to test cpu accounting controller functionality. + +FILES DESCRIPTION: + +cpuacct_task01.c +--------------- +This is the task which is run for eating up the cpu time. + + +cpuacct_setup.sh +---------- +This file contains the functions which are common for all the tests. For ex. +the setup and cleanup functions which do the setup for running the test and do +the cleanup once the test finishes. The setup() function creates /dev/cpuacct +directory and mounts cgroup filesystem on it with accounting controller. It +then creates a number(n) of groups in /dev/cpuacct. The cleanup function does a +complete cleanup of the system. + +Most of the error scenarios have been taken care of for a sane cleanup of the +system. However if cleanup fails in any case, just manually execute the +commands written in cleanup function in setup.sh. +One of the most common causes of failed cleanup is that you have done cd into +any of the groups in controller dir tree. + +run_cpuacct_test.sh +------------------ +This script creates different scenarios for cpu accounting controller testing and +starting (n) tasks in different groups to do some cpu allocations etc. It +checks for the cpu usage of the groups and reports test pass/fail accordingly. + +Makefile +-------- + +The usual makefile for this directory + +PASS/FAIL CRITERION: +================== +The test cases are intelligent enough in deciding the pass or failure of a +test. + +README: +-------- +The one you have gone through. +diff -rupN
ltp//testcases/kernel/controllers/cpuacct/run_cpuacct_test.shltp.src//testcases/kernel/controllers/cpuacct/run_cpuacct_test.sh/testcases/kernel/controllers/cpuacct/run_cpuacct_test.sh +385
-0@@ -0,0 +1,385 @@ +#!/bin/bash +# usage ./run_cpuacct_test.sh $TEST_NUM +############################################################################# +# Copyright (c) International Business Machines Corp., 2009 # +# # +# 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 # +# # +############################################################################# +# Name Of File: run_cpuacct_test.sh # +# # +# Description: This file runs the setup for testing different cpu acctount # +# controller features. After setup it runs diff test cases in # +# diff setup. # +# # +# Test 01: Tests Cpu usage of Hierarchical cgroups # +# # +# Precaution: Avoid system use by other applications/users to get fair and# +# appropriate results (avoid unnecessary killing of # +# application) # +# # +# Author: Rajasekhar Duddu <[email protected]> # +# # +# History: # +# # +# DATE NAME EMAIL DESC # +# # +# 14/07/09 Rajasekhar D <[email protected]> Created this test # +# # +############################################################################# + +export TCID="cpuacct_test01"; +export TST_TOTAL=1; +export TST_COUNT=1; + +TEST_NUM=$1; +SCRIPT_PID=$$; +RC=0; +PWD=`pwd`; + +cd $LTPROOT/testcases/bin/ 2> /dev/null +. cpuacct_setup.sh + +if [ "$USER" != root ]; then + tst_brkm TBROK ignored "Test must be run as root" + exit 0 +fi + +tst_kvercmp 2 6 30 2> /dev/null +if [ $? -eq 0 ]; then + tst_brkm TBROK ignored "Test should be run with kernel 2.6.30 or newer" + exit 0 +fi + +task_kill 2> /dev/null +cleanup + +mes="CPU Accounting Controller" +cg_path="/dev/cpuacct"; +num_online_cpus=`cat /proc/cpuinfo | grep -w processor | wc -l` + +#Function to create tasks equal to num_online_cpus. +nr_tasks () +{ + $PWD/cpuacct_task01 & + pid=$! +} + +#Function to caluculate the threshold value. +get_threshold () +{ + num_online_cpus=`expr $num_online_cpus \* $num_online_cpus` + if [ $num_online_cpus -le 32 ] + then + threshold=32 + else + threshold=$num_online_cpus + fi + threshold=`expr $threshold \* 2` +} + +#Function which is called for reading the cpuacct.usage_percpu stat value +#for Parent and Child cgroups. +per_cpu_usage () +{ + attrc=0 + attrp=0 + i=0 + k=0 + while read line + do + j=0 + for k in $line + do + j=`expr $j + $k` + done + if [ "$i" == "0" ] + then + attrp=$j + i=`expr $i + 1` + else + attrc=`expr $j + $attrc` + fi + done < "./tmp2" +} + +#Function which verifies the cpu accounting of the Parent and the Child cgroups. +check_attr() +{ + + if [ "$1" == "1" ] + then + if [ "$2" == "cpuacct.stat" ] + then + attr1="`sed -n 1p tmp2`" + attr2="`sed -n 2p tmp2`" + attr3="`sed -n 3p tmp2`" + attr4="`sed -n 4p tmp2`" + echo + echo "$2 for Parent cgroup is $attr1 : $attr2" + echo "$2 for Child cgroup is $attr3 : $attr4" + + if [ "$attr1" == "$attr3" ] && [ "$attr2" == "$attr4" ] + then + RC=$? + echo "TPASS $mes:$2 PASSED" + + else + RC=$? + echo "TFAIL $mes:$2 FAILED" + fi + elif [ "$2" == "cpuacct.usage_percpu" ] + then + per_cpu_usage + echo + echo "$2 for Parent cgroup : $attrp" + echo "$2 for Child cgroup : $attrc" + if [ "$attrp" == "$attrc" ] + then + RC=$? + echo "TPASS $mes:$2 PASSED" + else + RC=$? + echo "TFAIL $mes:$2 FAILED" + fi + else + attr1="`sed -n 1p tmp2`" + attr2="`sed -n 2p tmp2`" + + echo + echo "$2 for Parent cgroup is $attr1" + echo "$2 for Child cgroup is $attr2" + if [ "$attr1" == "$attr2" ] + then + RC=$? + echo "TPASS $mes:$2 PASSED" + else + RC=$? + echo "TFAIL $mes:$2 FAILED" + fi + + fi + else + + if [ "$2" == "cpuacct.stat" ] + then + attr0="`sed -n 1p tmp2 | cut -d" " -f2`" + attr1="`sed -n 2p tmp2 | cut -d" " -f2`" + attr2="`sed -n 3p tmp2 | cut -d" " -f2`" + attr3="`sed -n 4p tmp2 | cut -d" " -f2`" + attr4="`sed -n 5p tmp2 | cut -d" " -f2`" + attr5="`sed -n 6p tmp2 | cut -d" " -f2`" + attr_usr=`expr $attr2 + $attr4 ` + attr_sys=`expr $attr3 + $attr5` + echo + echo "$2 for Parent cgroup : $attr0::$attr1" + echo "$2 for Child cgroup : $attr_usr::$attr_sys" + get_threshold + diff_usr=`expr $attr0 - $attr_usr ` + [ ${diff_usr} -le 0 ] && diff_usr=$((0 - $diff_usr)) + + diff_sys=`expr $attr1 - $attr_sys` + [ ${diff_sys} -le 0 ] && diff_sys=$((0 - $diff_sys)) + if [ "$diff_usr" -le "$threshold" ] && \ + [ "$diff_sys" -le "$threshold" ] + then + RC=$? + echo "TPASS $mes:$2 PASSED" + else + RC=$? + echo "TFAIL $mes:$2 FAILED" + fi + elif [ "$2" == "cpuacct.usage_percpu" ] + then + per_cpu_usage + echo + echo "$2 for Parent cgroup : $attrp" + echo "$2 for Child cgroup : $attrc" + if [ "$attrp" == "$attrc" ] + then + RC=$? + echo "TPASS $mes:$2 PASSED" + else + RC=$? + echo "TFAIL $mes:$2 FAILED" + fi + + else + attr0="`sed -n 1p tmp2`" + attr1="`sed -n 2p tmp2`" + attr2="`sed -n 3p tmp2`" + attr=`expr $attr1 + $attr2` + echo + echo "$2 for Parent cgroup : $attr0" + echo "$2 for Child cgroup : $attr" + if [ "$attr0" == "$attr" ] + then + RC=$? + echo "TPASS $mes:$2 PASSED" + else + RC=$? + echo "TFAIL $mes:$2 FAILED" + fi + fi + fi +} + +echo "TEST $TEST_NUM:CPU ACCOUNTING CONTROLLER TESTING"; +echo "RUNNING SETUP....."; +setup; + +echo "TEST STARTED: Please avoid using system while this test executes"; + + +status=0 +case ${TEST_NUM} in + "1" ) + ls $PWD/cpuacct_task01 &> /dev/null + if [ $? -ne 0 ] + then + echo "TFAIL Task file cpuacct_task01.c not compiled" + echo "Please check Makefile Exiting test" + task_kill 2> /dev/null + exit -1 + fi + $PWD/cpuacct_task01 & + pid=$! + + mkdir $cg_path/group_1 2> /dev/null + mkdir $cg_path/group_1/group_11/ 2> /dev/null + if [ $? -ne 0 ] + then + echo "TFAIL Cannot create cpuacct cgroups Exiting Test" + cleanup + task_kill 2> /dev/null + exit -1 + fi + echo $pid > /$cg_path/group_1/group_11/tasks 2> /dev/null + if [ $? -ne 0 ] + then + echo "TFAIL Not able to move a task to the cgroup" + echo "Exiting Test" + cleanup 2> /dev/null + task_kill 2> /dev/null + exit -1 + fi + sleep 5 + task_kill 2> /dev/null + for i in cpuacct.usage cpuacct.usage_percpu cpuacct.stat + do + cat $cg_path/group_1/$i \ + $cg_path/group_1/group_11/$i > tmp2 + check_attr $1 $i + if [ $RC -ne 0 ] + then + status=1 + fi + done + if [ $status -eq 0 ] + then + echo + echo "$mes test executed successfully" + cleanup 2> /dev/null + task_kill 2> /dev/null + exit 0 + else + echo + echo "$mes test execution Failed" + cleanup 2> /dev/null + exit -1 + fi + ;; + + "2" ) + mkdir $cg_path/group_1 2> /dev/null + mkdir $cg_path/group_1/group_11 2> /dev/null + mkdir $cg_path/group_1/group_12 2> /dev/null + if [ $? -ne 0 ] + then + echo "TFAIL Cannot create cpuacct cgroups Exiting Test" + cleanup 2> /dev/null + task_kill 2> /dev/null + exit -1 + fi + + ls $PWD/cpuacct_task01 &> /dev/null + if [ $? -ne 0 ] + then + echo "TFAIL Task file cpuacct_task01.c not compiled" + echo "Please check Makefile Exiting test" + cleanup 2> /dev/null + task_kill 2> /dev/null + exit -1 + fi + for (( m=0 ; m<=$num_online_cpus ; m++ )) + do + nr_tasks + echo $pid > $cg_path/group_1/group_11/tasks + if [ $? -ne 0 ] + then + echo "TFAIL Not able to move task to cgroup" + echo "Exiting Test" + cleanup 2> /dev/null + task_kill 2> /dev/null + exit -1 + fi + nr_tasks + echo $pid >$cg_path/group_1/group_12/tasks + if [ $? -ne 0 ] + then + echo "TFAIL Not able to move task to cgroup" + echo "Exiting Test" + cleanup 2> /dev/null + task_kill 2> /dev/null + exit -1 + fi + sleep 2 + done + task_kill 2> /dev/null + for i in cpuacct.usage cpuacct.usage_percpu cpuacct.stat + do + cat $cg_path/group_1/$i \ + $cg_path/group_1/group_11/$i \ + $cg_path/group_1/group_12/$i >tmp2 + check_attr $1 $i + if [ $RC -ne 0 ] + then + status=1 + fi + done + if [ $status -eq 0 ] + then + echo + echo "$mes test executed successfully" + cleanup 2> /dev/null + task_kill 2> /dev/null + cd $PWD + exit 0 + else + echo + echo "$mes test execution Failed" + cleanup 2> /dev/null + task_kill 2> /dev/null + cd $PWD + exit -1 + fi + + ;; + * ) + usage + exit -1 + ;; + esac +diff -rupN ltp//testcases/kernel/controllers/Makefile ltp.src//testcases/kernel/controllers/Makefile
/testcases/kernel/controllers/Makefile +7
-0@@ -7,6 +7,7 @@ CHECK_MEMCTL := $(shell grep -w memory / 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) CHECK_CPUSETCTL = $(shell grep -w cpuset /proc/cgroups 2>/dev/null|cut -f1) +CHECK_CPUACCTCTL := $(shell grep -w cpuacct /proc/cgroups 2>/dev/null|cut -f1) endif ifdef CROSS_COMPILE@@ -17,6 +18,7 @@ SUBDIRS += memctl SUBDIRS += io-throttle SUBDIRS += freezer SUBDIRS += cpuset +SUBDIRS += cpuacct else $(info "Kernel is not compiled with control cgroup support") endif@@ -58,6 +60,11 @@ SUBDIRS += cpuset else $(info "Kernel is not compiled with cpuset resource controller support") endif +ifeq ($(CHECK_CPUACCTCTL),cpuacct) +SUBDIRS += cpuacct +else +$(info "Kernel is not compiled with cpuacct resource controller support") +endif endif # If at least one of the controllers is available then build libcontrollers.diff -rupN ltp//testcases/kernel/controllers/README ltp.src//testcases/kernel/controllers/README
/testcases/kernel/controllers/README +4
-0@@ -51,6 +51,10 @@ libcontrollers -------------- This directory contains the library for cpucontroller testing. +cpuacct +----------- +Directory containing the cpu accounting controller testcases. + Makefile -------- The usual Makefile to conduct all the tests.diff -rupN
ltp//testcases/kernel/controllers/test_controllers.shltp.src//testcases/kernel/controllers/test_controllers.sh/testcases/kernel/controllers/test_controllers.sh +10
-0@@ -42,6 +42,7 @@ then IOTHROTTLE_CONTROLLER=`grep -w blockio /proc/cgroups | cut -f1`; FREEZER=`grep -w freezer /proc/cgroups | cut -f1`; CPUSET_CONTROLLER=`grep -w cpuset /proc/cgroups | cut -f1` + CPUACCOUNT_CONTROLLER=`grep -w cpuacct /proc/cgroups | cut -f1` if [ "$CPU_CONTROLLER" = "cpu" ] then@@ -112,6 +113,15 @@ then echo "Kernel does not support cpuset controller"; echo "Skipping all cpuset controller testcases...."; fi + if [ "$CPUACCOUNT_CONTROLLER" = "cpuacct" ] + then + $LTPROOT/testcases/bin/run_cpuacct_test.sh 1; + $LTPROOT/testcases/bin/run_cpuacct_test.sh 2; + else + echo "Could not start cpu accounting controller test"; + echo "usage: run_cpuacct_test.sh $TEST_NUM "; + echo "Skipping the cpu accounting controller test..."; + fi else echo "CONTROLLERS TESTCASES: WARNING" echo "Kernel does not support for control groups";LOG:
[root@p510 ltp-intermediate-20090822]# ./runltp -f cpuacctRunning tests.......
<<<test_start>>>
tag=CPUACCT01 stime=1251202954 cmdline="$LTPROOT/testcases/bin/run_cpuacct_test.sh 1" contacts=""
analysis=exit
<<<test_output>>>
Cleanup called
TEST 1:CPU ACCOUNTING CONTROLLER TESTING
RUNNING SETUP.....
TEST STARTED: Please avoid using system while this test executescpuacct.usage for Parent cgroup is 5016035936 cpuacct.usage for Child cgroup is 5016035936 TPASS CPU Accounting Controller:cpuacct.usage PASSED
cpuacct.usage_percpu for Parent cgroup : 5016035936 cpuacct.usage_percpu for Child cgroup : 5016035936 TPASS CPU Accounting Controller:cpuacct.usage_percpu PASSED
cpuacct.stat for Parent cgroup is user 94 : system 387 cpuacct.stat for Child cgroup is user 94 : system 387 TPASS CPU Accounting Controller:cpuacct.stat PASSED
CPU Accounting Controller test executed successfully Cleanup called
<<<execution_status>>>
initiation_status="ok"
duration=8 termination_type=exited termination_id=0 corefile=no cutime=114 cstime=399
<<<test_end>>>
<<<test_start>>>
tag=CPUACCT02 stime=1251202962 cmdline="$LTPROOT/testcases/bin/run_cpuacct_test.sh 2" contacts=""
analysis=exit
<<<test_output>>>
incrementing stop
Cleanup called
TEST 2:CPU ACCOUNTING CONTROLLER TESTING
RUNNING SETUP.....
TEST STARTED: Please avoid using system while this test executescpuacct.usage for Parent cgroup : 34281951552 cpuacct.usage for Child cgroup : 34281951552 TPASS CPU Accounting Controller:cpuacct.usage PASSED
cpuacct.usage_percpu for Parent cgroup : 34281951552 cpuacct.usage_percpu for Child cgroup : 34281951552 TPASS CPU Accounting Controller:cpuacct.usage_percpu PASSED
cpuacct.stat for Parent cgroup : 275::1691 cpuacct.stat for Child cgroup : 274::1690 TPASS CPU Accounting Controller:cpuacct.stat PASSED
CPU Accounting Controller test executed successfully Cleanup called
<<<execution_status>>>
initiation_status="ok"
duration=14 termination_type=exited termination_id=0 corefile=no cutime=296 cstime=1706
<<<test_end>>>
INFO: ltp-pan reported all tests PASS
LTP Version: LTP-20090731
Quoted 8 lines
###############################################################" Done executing testcases." LTP Version: LTP-20090731 ###############################################################"[root@p510 ltp-intermediate-20090822]#
------------------------------------------------------------------------------
Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day trial. Simplify your report design, integration and deployment - and focus on what you do best, core application coding. Discover what's new with Crystal Reports now. http://p.sf.net/sfu/bobj-july
_______________________________________________
Ltp-list mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/ltp-list