On Thu, Feb 28, 2008 at 04:21:36PM +0530, Dhaval Giani wrote:
> On Thu, Feb 28, 2008 at 10:05:21AM +0530, Sudhir Kumar wrote:
> > Hi
First of all thanks a lot for getting your time.
(I know how much busy you are nowadays:)
I have tried to address your comments below.
> >
> > This patch creates the framework for controllers testcases in LTP. This also
> > creates the first and second testcase for cpu controller and adds some
> > documentation.
> >
>
> Hi Sudhir,
>
> This is a very big patch, you might want to split it into 3 different
> patches, one for the framework and one for each testcase.
Yes you are correct!! I was worrying about that.
Now onwards i will take care of that.
>
> Minor comments follow,
>
> > <cpuctl1.patch>
> >
> > Signed-off-by: Sudhir Kumar <[EMAIL PROTECTED]>
> >
> > Index: ltp-full-20071130/runtest/controllers
> > ===================================================================
> > --- /dev/null
> > +++ ltp-full-20071130/runtest/controllers
> > @@ -0,0 +1,2 @@
> > +#DESCRIPTION:Resource Management testing
> > +controllers test_controllers.sh
> > Index: ltp-full-20071130/testcases/kernel/Makefile
> > ===================================================================
> > --- ltp-full-20071130.orig/testcases/kernel/Makefile
> > +++ ltp-full-20071130/testcases/kernel/Makefile
> > @@ -1,4 +1,4 @@
> > -SUBDIRS = numa containers include fs io ipc mem pty sched security syscalls
> > +SUBDIRS = numa containers controllers include fs io ipc mem pty sched
> > security syscalls
> > UCLINUX_SUBDIRS = syscalls
> >
> > all:
> > Index: ltp-full-20071130/testcases/kernel/controllers/Makefile
> > ===================================================================
> > --- /dev/null
> > +++ ltp-full-20071130/testcases/kernel/controllers/Makefile
> > @@ -0,0 +1,25 @@
> > +SUBDIRS = cpuctl
> > +CHECK_CPUCTL = $(shell grep -w cpu /proc/cgroups|cut -f1)
> > +all:
> > + @set -e;
> > +ifeq ($(CHECK_CPUCTL),cpu)
> > +
> > + for i in $(SUBDIRS); do $(MAKE) -C $$i $@ ;done;
> > +else
> > + echo "Kernel is not compiled with cpu controller support";
> > +endif
> > +
> > +install:
> > + @set -e; \
> > + ln -f test_controllers.sh ../../bin/test_controllers.sh;
> > +
> > +ifeq ($(CHECK_CPUCTL),cpu)
> > +
> > + for i in $(SUBDIRS); do $(MAKE) -C $$i install ; done; \
> > + chmod ugo+x test_controllers.sh;
> > +else
> > + echo "Kernel is not compiled with cpu controller support";
> > +endif
> > +
> > +clean:
> > + @set -e; for i in $(SUBDIRS); do $(MAKE) -C $$i clean ; done
> > Index: ltp-full-20071130/testcases/kernel/controllers/README
> > ===================================================================
> > --- /dev/null
> > +++ ltp-full-20071130/testcases/kernel/controllers/README
> > @@ -0,0 +1,38 @@
> > +The complete dir tree is for testcases for resource management testing of
> > linux kernel.
> > +For the test plan please refer to the file testplan.txt
> > +
> > +--------------
> > +***WARNING:***
> > +--------------
> > +The test creates the cpu controller device as /dev/cpuctl. In case you
> > already have
> > +/dev/cpuctl it may be overwritten. So please rename it to have a backup of
> > your file.
> > +
> > +
> > +FILES DESCRIPTION:
> > +
> > +testplan.txt
> > +------------
> > +A brief description of the plan for resource management testing.
> > +
> > +test_controllers.sh
> > +-------------------
> > +This is the main script file that starts the test. It first checks if cpu
> > controller
> > +is enabled. If not enabled then it will not run the test and will exit
> > giving warning.
> > +
> > +README
> > +------
> > +This file.
> > +
> > +cpuctl
> > +------
> > +Directory containing the cpu controller testcases. A similar directory
> > will be created for
> > +any new controller.
> > +
> > +Makefile
> > +--------
> > +The usual Makefile to conduct all the tests.
> > +
> > +Before starting compilation this file checks if the kernel is supporting
> > the cpu controller.
> > +If yes it enters lower directory and compiles the source files otherwise
> > exits warning to user.
> > +Hence the user has to take care of the fact that the test runs or just
> > quiets.
>
> ^^^^^
> quits
> (?)
Thanks.
>
> > +(Your kernel needs to be 2.6.24-rc1 onwards with proper config options)
> > Index: ltp-full-20071130/testcases/kernel/controllers/cpuctl/Makefile
> > ===================================================================
> > --- /dev/null
> > +++ ltp-full-20071130/testcases/kernel/controllers/cpuctl/Makefile
> > @@ -0,0 +1,16 @@
> > +CFLAGS += -Wall
> > +CPPFLAGS += -I../../../../include
> > +LDLIBS += -lm -L../../../../lib/ -lltp
> > +
> > +SRCS = $(wildcard *.c)
> > +
> > +TARGETS = $(patsubst %.c,%,$(SRCS))
> > +
> > +all: $(TARGETS)
> > +
> > +clean:
> > + rm -f $(TARGETS) *.o
> > +
> > +install:
> > + @set -e; for i in $(TARGETS) run_cpuctl_test.sh ; do ln -f $$i
> > ../../../bin/$$i ; chmod +x $$i ; done
> > +
> > Index: ltp-full-20071130/testcases/kernel/controllers/cpuctl/README
> > ===================================================================
> > --- /dev/null
> > +++ ltp-full-20071130/testcases/kernel/controllers/cpuctl/README
> > @@ -0,0 +1,65 @@
> > +
> > +TEST SUITE:
> > +
> > +The directory cpuctl contains the tests related to the cpu controller.
> > +At present there is only 1 testcase but it is the first test case in it's
> > +series of test cases and further testcases will be added in the forthcoming
> > +release of LTP
> > +
> > +TEST AIM:
> > +
> > +The aim of the test is to find any dependency of cpu controller on exact
> > value
> > +of shares to schedule the tasks. For example if there are two groups
> > running
> > +1 task each then they must get the cpu time in the same ratio irrespective
> > of
> > +the share values i.e. share ratios 1:2, 10:20, 100:200, 1000:2000 etc
> > should
> > +give the same cpu usage for each group.
> > +
>
> This is not very clear. One gets the impression that the cpu usage
> should remain constant across changes in share ratios, but that might
> not be case. It is dependent on other factors. What the expected usage
> would be is that the bandwidth used by the groups would always be in the
> ratio of their shares.
I tried giving example. I will correct in a new patch.
>
> > +FILES DESCRIPTION:
> > +
> > +cpuctl_enabled_check.sh
> > +-----------------------
> > +This file is in 1 directory up and is the threshold to run the test.
> > +This script file checks the kernel version and if FAIR_GROUP_SCHEDULER has
> > been
> > +compiled in the kernel. If not then the test is not run and user is asked
> > if
> > +he wants the new kernel be compiled with proper configuration and then run
> > the test.
> > +
> > +cpuctl_test01.c
> > +---------------
> > +The test case for cpu controller testing. This basicaly runs a task in a
> > group
> > +under cpu controller. Each task runs for an interval TIME_INTERVAL seconds
> > and
> > +reports the total time it could run on all cpus(for convinience given in %
> > ).
> > +
> > +After say n TIME_INTERVAL it modifies it's shares and again report the cpu
> > +usage.
> > +
> > +run_cpuctl_test.sh
> > +----------
> > +This file contains the script which does setup for the test. It creates a
> > +/dev/cpuctl directory, mounts cgroup filesystem on it with cpu. It then
> > creates
> > +a number(n) of groups in /dev/cpuctl and fires (n) tasks to run at the
> > same time.
> > +
>
> Who gives the value n?
The script decides this value based on the test and the num of cpus in
the machine. For example for fairness testing a scenario in which number
of groups is not equal to number of cpus is better than in which the two
are equal.
>
> > +Makefile
> > +--------
> > +
> > +The usual makefile for this directory
> > +
> > +README:
> > +--------
> > +The one you have gone through
> > +
> > +$LTPROOT/output/cpuctl_results.txt
> > +--------------
> > +This file will be created to log the results once the test is run. It
> > contains the test
> > +results which are numbers and following is a description which will help
> > to understand
> > +the results.
> > +
> > +The cpu time for each group(task ) is calculated in %. There are two
> > outcomes of the test:
> > +
> > +1. A group should get cpu time in the same ratio as it's shares.
> > +
> > +2. This time should not change with the changes in share values while the
> > ratio in those
> > + values is same.
> > +
>
> This is something that cannot be guaranteed as the conditions in which
> the test runs is not the same.
I agree. For now I will correct it. Once the RT task migration is
possible easily we can create similar conditions for diff runs.
>
> > +NOTE: In case 1 a variation of 1-2 % is acceptable.
> > +
> > +
> > Index: ltp-full-20071130/testcases/kernel/controllers/cpuctl/cpuctl_test01.c
> > ===================================================================
> > --- /dev/null
> > +++ ltp-full-20071130/testcases/kernel/controllers/cpuctl/cpuctl_test01.c
> > @@ -0,0 +1,187 @@
> > +/******************************************************************************/
> > +/*
> > */
> > +/* Copyright (c) International Business Machines Corp., 2007
> > */
> > +/*
> > */
> > +/* 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
> > */
> > +/*
> > */
> > +/******************************************************************************/
> > +
> > +/******************************************************************************/
> > +/*
> > */
> > +/* File: cpuctl_test01.c
> > */
> > +/*
> > */
> > +/* Description: This is a c program that tests the cpucontroller fairness
> > of */
> > +/* scheduling the tasks according to their group shares. This
> > */
> > +/* testcase tests the ability of the cpu controller to
> > provide */
> > +/* fairness for share values (absolute).
> > */
> > +/*
> > */
> > +/* Total Tests: 2
> > */
> > +/*
> > */
> > +/* Test Name: cpu_controller_test01
> > */
> > +/*
> > */
> > +/* Test Assertion
> > */
> > +/* Please refer to the file cpuctl_testplan.txt
> > */
> > +/*
> > */
> > +/* Author: Sudhir Kumar [EMAIL PROTECTED] */
>
> This has been sent using [EMAIL PROTECTED] Perhaps use the same
> address?
Yeah.. I will add in next patch.
Thanks
Sudhir
>
> > +/*
> > */
> > +/* History:
> > */
> > +/* Created- 20/12/2007 -Sudhir Kumar [EMAIL PROTECTED] */
> > +/*
> > */
> > +/******************************************************************************/
> > +
> > +/* Standard Include Files */
> > +#include <unistd.h>
> > +#include <math.h>
> > +#include <signal.h>
> > +#include <stdio.h>
> > +#include <stdlib.h>
> > +#include <string.h>
> > +#include <sys/resource.h>
> > +#include <sys/syscall.h>
> > +#include <sys/time.h>
> > +#include <sys/types.h>
> > +#include <time.h>
> > +#include <unistd.h>
> > +
> > +#include "test.h" /* LTP harness APIs*/
> > +
> > +#define TIME_INTERVAL 60 /* Time interval in seconds*/
> > +#define NUM_INTERVALS 3 /* How many iterations of TIME_INTERVAL
> > */
> > +#define NUM_SETS 7 /* How many share values (with same ratio)*/
> > +#define MULTIPLIER 10 /* decides the rate at which share
> > value gets multiplied*/
> > +
> > +extern int Tst_count;
> > +char *TCID = "cpu_controller_test01";
> > +int TST_TOTAL = 1;
> > +pid_t scriptpid;
> > +extern void
> > +cleanup()
> > +{
> > + kill (scriptpid, SIGUSR1);/* Inform the shell to do cleanup*/
> > + tst_exit (); /* Report exit status*/
> > +}
> > +
> > +int write_to_file (char * file, const char* mode, unsigned int value);
> > +void signal_handler_alarm (int signal );
> > +int timer_expired = 0;
> > +
> > +int main(int argc, char* argv[])
> > +{
> > +
> > + int num_cpus; /* To calculate cpu time in %*/
> > + char mygroup[32], mytaskfile[32], mysharesfile[32], ch;
> > + pid_t pid;
> > + int my_group_num, /* A number attached with a group*/
> > + fd, /* A descriptor to open a fifo for
> > synchronized start*/
> > + first_counter =0, /* To take n number of readings*/
> > + second_counter=0; /* To track number of times the base
> > value of shares has been changed*/
> > + double total_cpu_time, /* Accumulated cpu time*/
> > + delta_cpu_time, /* Time the task could run on cpu(s)
> > (in an interval)*/
> > + prev_cpu_time=0;
> > + struct rusage cpu_usage;
> > + time_t current_time, prev_time, delta_time;
> > + unsigned long int myshares = 1; /* Simply the base value to start with*/
> > + struct sigaction newaction, oldaction;
> > + /* Signal handling for alarm*/
> > + sigemptyset (&newaction.sa_mask);
> > + newaction.sa_handler = signal_handler_alarm;
> > + newaction.sa_flags=0;
> > + sigaction (SIGALRM, &newaction, &oldaction);
> > +
> > + /* Check if all parameters passed are correct*/
> > + if ((argc < 5) || ((my_group_num = atoi(argv[1])) <= 0) || ((scriptpid
> > = atoi(argv[3])) <= 0) || ((num_cpus = atoi(argv[4])) <= 0))
> > + {
> > + tst_brkm (TBROK, cleanup, "Invalid input parameters\n");
> > + }
> > +
> > + myshares *= my_group_num;
> > + sprintf(mygroup,"%s", argv[2]);
> > + sprintf(mytaskfile, "%s", mygroup);
> > + sprintf(mysharesfile, "%s", mygroup);
> > + strcat (mytaskfile,"/tasks");
> > + strcat (mysharesfile,"/cpu.shares");
> > + pid = getpid();
> > + write_to_file (mytaskfile, "a", pid); /* Assign the task to it's
> > group*/
> > + write_to_file (mysharesfile, "w", myshares);
> > +
> > + fd = open ("./myfifo", 0);
> > + if (fd == -1)
> > + {
> > + tst_brkm (TBROK, cleanup, "Could not open fifo for
> > synchronization");
> > + }
> > +
> > + fprintf(stdout,"\ntask-%d SHARES=%lu\n",my_group_num, myshares);
> > + read (fd, &ch, 1); /* To block all tasks here and fire
> > them up at the same time*/
> > + prev_time = time (NULL); /* Note down the time*/
> > +
> > + while (1)
> > + {
> > + /* Need to run some cpu intensive task, which also frequently
> > checks the timer value*/
> > + double f = 274.345, mytime; /*just a float number to take
> > sqrt*/
> > + alarm (TIME_INTERVAL);
> > + timer_expired = 0;
> > + while (!timer_expired) /* Let the task run on cpu for
> > TIME_INTERVAL*/
> > + f = sqrt (f*f); /* Time of this operation should not be
> > high otherwise we can
> > + * exceed the TIME_INTERVAL to measure
> > cpu usage
> > + */
> > + current_time = time (NULL);
> > + delta_time = current_time - prev_time; /* Duration in
> > case it is not exact TIME_INTERVAL*/
> > +
> > + getrusage (0, &cpu_usage);
> > + total_cpu_time = (cpu_usage.ru_utime.tv_sec +
> > cpu_usage.ru_utime.tv_usec * 1e-6 + /* user time*/
> > + cpu_usage.ru_stime.tv_sec +
> > cpu_usage.ru_stime.tv_usec * 1e-6) ; /* system time*/
> > + delta_cpu_time = total_cpu_time -
> > prev_cpu_time;
> > +
> > + prev_cpu_time = total_cpu_time;
> > + prev_time = current_time;
> > + if (delta_time > TIME_INTERVAL)
> > + mytime = (delta_cpu_time * 100) / (delta_time
> > * num_cpus);
> > + else
> > + mytime = (delta_cpu_time * 100) /
> > (TIME_INTERVAL * num_cpus);
> > +
> > + fprintf (stdout,"PID: %u\ttask-%d:cpu time --->
> > %6.3f\%(%fs) --->%lu(shares)\tinterval:%lu\n",getpid(),my_group_num,
> > mytime, delta_cpu_time, myshares, delta_time);
> > + first_counter++;
> > +
> > + if (first_counter >= NUM_INTERVALS) /* Take n sets
> > of readings for each shares value*/
> > + {
> > + first_counter = 0;
> > + second_counter++;
> > + if (second_counter >= NUM_SETS)
> > + exit (0); /* This task is
> > done with its job*/
> > + myshares = MULTIPLIER * myshares; /* Keep
> > same ratio but change values*/
> > + write_to_file (mysharesfile, "w", myshares);
> > + fprintf(stdout,"\ntask-%d
> > SHARES=%lu\n",my_group_num, myshares);
> > + }/* end if*/
> > + }/* end while*/
> > +}/* end main*/
> > +
> > +
> > +int write_to_file (char *file, const char *mode, unsigned int value)
> > +{
> > + FILE *fp;
> > + fp = fopen (file, mode);
> > + if (fp == NULL)
> > + {
> > + tst_brkm (TBROK, cleanup, "Could not open file %s for writing",
> > file);
> > + }
> > + fprintf (fp, "%u\n", value);
> > + fclose (fp);
> > + return 0;
> > +}
> > +
> > +void signal_handler_alarm (int signal)
> > +{
> > + timer_expired = 1;
> > +}
> > Index:
> > ltp-full-20071130/testcases/kernel/controllers/cpuctl/cpuctl_testplan.txt
> > ===================================================================
> > --- /dev/null
> > +++
> > ltp-full-20071130/testcases/kernel/controllers/cpuctl/cpuctl_testplan.txt
> > @@ -0,0 +1,48 @@
> > +The cpucontroller testplan includes a complete set of testcases that test
> > the cpu controller
> > +in different scenarios. So this testcase is the first in it's series.
> > +
> > +**This testcase tests the cpu controller under flat hierarchy.**
> > +
> > +
> > +The test plan for this testcase is as below:
> > +
> > +First of all mount the cpu controller on /dev/cpuctl and create n groups.
> > The number of
> > +groups should be > the number of cpus for checking scheduling fairness(as
> > we will run 1
> > +task per group). then we create say n groups. By default each group is
> > assigned 1024
> > +shares. The cpu controller schedules the tasks in different groups on the
> > basis of the
> > +shares assigned to that group. So the cpu usage of a task depends on the
> > amount of shares
> > +it's group has out of the total number of shares(no upper limit). Let us
> > say that we have
> > +3 groups(1 task each) A,B,C each having 1, 2, 3 shares respectively. Hence
> > if the tasks are
> > +running infinitely they are supposed to get 16.66%, 33.33%, 50% cpu time
> > respectively. This
> > +test case tests that each group should get the cpu time in the same(above)
> > ratio irrespective
> > +of the shares values provided the ratio is not changed i.e. the cpu time
> > per group should not
> > +change if we change the shares from 1, 2, 3 to 100, 200, 300 or to 10K,
> > 20K, 30K etc.
> > +
> > +How to view the results:
> > +-----------------------
> > +
> > +Say if there are n groups then
> > +
> > +total share weight = grp1 share + grp2 shares +......upto n grps
> > +
> > +then expected time of any grp (say grp1)
> > + =100 * (grp1 share) /(total share weight) %
> > +
> > +Note:-
> > +(*If there were say 2 task in this group then both task might devide the
> > time of this group
> > + *and it would create no effect on tasks in other group. So a task will
> > always get time from
> > + *it's group time only and will never affect other groups share of time )
> > +
> > +
> > +The cpu time for each group(task ) is calculated in %. There are two
> > outcomes of the test:
> > +
> > +1. A group should get cpu time in the same ratio as it's shares.
> > +
> > +2. This time should not change with the changes in share values while the
> > ratio in those
> > + values is same.
> > +
> > +NOTE: In case 1 a variation of 1-2 % is acceptable.
> > +
> > +(remember here we have 1 task per group)
> > +
> > +For any other information please refer to cgroup.txt in kernel
> > documentation.
> > Index:
> > ltp-full-20071130/testcases/kernel/controllers/cpuctl/run_cpuctl_test.sh
> > ===================================================================
> > --- /dev/null
> > +++ ltp-full-20071130/testcases/kernel/controllers/cpuctl/run_cpuctl_test.sh
> > @@ -0,0 +1,200 @@
> > +#!/bin/bash
> > +# usage ./runcpuctl_test.sh
> > +
> > +#################################################################################
> > +# Copyright (c) International Business Machines Corp., 2007
> > #
> > +#
> > #
> > +# 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_cpuctl_test.sh
> > #
> > +#
> > #
> > +# Description: This file runs the setup for testing cpucontroller.
> > #
> > +# After setup it runs some of the tasks in different groups.
> > #
> > +# setup includes creating controller device, mounting it
> > with #
> > +# cgroup filesystem with option cpu and creating groups in
> > it. #
> > +#
> > #
> > +# Functions: get_num_groups(): decides number of groups based on num of
> > cpus #
> > +# setup(): creaes /dev/cpuctl, mounts cgroup fs on it,
> > creates #
> > +# groups in that, creates fifo to fire tasks at one time.
> > #
> > +#
> > #
> > +# Precaution: Avoid system use by other applications/users to get fair
> > and #
> > +# appropriate results
> > #
> > +#
> > #
> > +# Author: Sudhir Kumar <[EMAIL PROTECTED]> #
> > +#
> > #
> > +# History:
> > #
> > +#
> > #
> > +# DATE NAME EMAIL DESC
> > #
> > +#
> > #
> > +# 20/12/07 Sudhir Kumar <[EMAIL PROTECTED]> Created this test #
> > +#
> > #
> > +#################################################################################
> > +
> > +
> > +export TCID="cpuctl_test01";
> > +export TST_TOTAL=1;
> > +export TST_COUNT=1;
> > +
> > +RC=0; # return code from functions
> > +NUM_CPUS=1; # at least 1 cpu is there
> > +NUM_GROUPS=2; # min number of groups
> > +
> > +PWD=`pwd`
> > +cd $LTPROOT/testcases/bin/
> > +
> > +get_num_groups() # Number of tasks should be >= number of cpu's (to
> > check scheduling fairness)
> > +{
> > + NUM_CPUS=`cat /proc/cpuinfo | grep -w processor | wc -l`
> > + num_grps=$(echo "$NUM_CPUS * 1.5"|bc) # temp variable num_grps
> > + int_part=`echo $num_grps | cut -d"." -f1`
> > + dec_part=`echo $num_grps | cut -d"." -f2`
> > +
> > + if [ $dec_part -gt 0 ]
> > + then
> > + NUM_GROUPS=$(echo "$int_part + 1"|bc)
> > + else
> > + NUM_GROUPS=$int_part;
> > + fi
> > +}
> > +
> > +# Write the cleanup function
> > +cleanup ()
> > +{
> > + echo "Cleanup called"
> > + rm -f cpuctl_task_* 2>/dev/null
> > + rmdir /dev/cpuctl/group_* 2> /dev/null
> > + umount /dev/cpuctl 2> /dev/null
> > + rmdir /dev/cpuctl 2> /dev/null
> > + rm -f myfifo 2>/dev/null
> > +
> > +}
> > + # Create /dev/cpuctl & mount the cgroup file system with cpu controller
> > + #clean any group created eralier (if any)
> > +
> > +setup ()
> > +{
> > + if [ -e /dev/cpuctl ]
> > + then
> > + echo "WARN:/dev/cpuctl already exist..overwriting"; # or a
> > warning ?
> > + cleanup;
> > + mkdir /dev/cpuctl;
> > + else
> > + mkdir /dev/cpuctl
> > + fi
> > + mount -t cgroup -ocpu cgroup /dev/cpuctl 2> /dev/null
> > + if [ $? -ne 0 ]
> > + then
> > + echo "ERROR: Could not mount cgroup filesystem on
> > /dev/cpuctl..Exiting test";
> > + cleanup;
> > + exit -1;
> > + fi
> > +
> > + # Group created earlier may again be visible if not cleaned
> > properly...so clean them
> > + if [ -e /dev/cpuctl/group_1 ]
> > + then
> > + rmdir /dev/cpuctl/group*
> > + echo "WARN: Earlier groups found and removed...";
> > + fi
> > +
> > + #Create a fifo to make all tasks wait on it
> > + mkfifo myfifo 2> /dev/null;
> > + if [ $? -ne 0 ]
> > + then
> > + echo "ERROR: Can't create fifo...Check your
> > permissions..Exiting test";
> > + cleanup;
> > + exit -1;
> > + fi
> > +
> > + # Create different groups
> > + i=1;
> > + while [ $i -le $NUM_GROUPS ]
> > + do
> > + group=group_$i;
> > + mkdir /dev/cpuctl/$group;# 2>/dev/null
> > + if [ $? -ne 0 ]
> > + then
> > + echo "ERROR: Can't create $group...Check your
> > permissions..Exiting test";
> > + cleanup;
> > + exit -1;
> > + fi
> > + i=`expr $i + 1`
> > + done
> > +}
> > +
> > +########################## main #######################
> > + echo "TEST: CPU CONTROLLER TESTING";
> > + echo "RUNNING SETUP.....";
> > + get_num_groups;
> > + if [ $NUM_GROUPS -lt 2 ]
> > + then
> > + NUM_GROUPS=2; # min num of groups for testing
> > + fi
> > +
> > + setup;
> > +
> > + # Trap the signal from any abnormaly terminated task
> > + # and kill all others and let cleanup be called
> > + trap 'echo "signal caught from task"; killall cpuctl_task_*;' SIGUSR1;
> > +
> > + echo "TEST STARTED: Please avoid using system while this test executes";
> > + #Check if c source file has been compiled and then run it in
> > different groups
> > + if [ -f cpuctl_test01 ]
> > + then
> > + echo `date` >> $LTPROOT/output/cpuctl_results.txt;
> > + for i in $(seq 1 $NUM_GROUPS)
> > + do
> > + cp cpuctl_test01 cpuctl_task_$i 2>/dev/null;
> > + chmod +x cpuctl_task_$i;
> > + ./cpuctl_task_$i $i /dev/cpuctl/group_$i $$ $NUM_CPUS
> > >>$LTPROOT/output/cpuctl_results.txt 2>/dev/null &
> > + if [ $? -ne 0 ]
> > + then
> > + echo "Error: Could not run ./cpuctl_task_$i"
> > + cleanup;
> > + exit -1;
> > + else
> > + PID[$i]=$!;
> > + fi
> > + i=`expr $i + 1`
> > + done
> > + else
> > + echo "Source file not compiled..Plz check Makefile...Exiting
> > test"
> > + cleanup;
> > + exit -1;
> > + fi
> > + sleep 3
> > + echo TASKS FIRED
> > + echo helloworld > myfifo;
> > +
> > + #wait for the tasks to finish for cleanup and status report to pan
> > + for i in $(seq 1 $NUM_GROUPS)
> > + do
> > + wait ${PID[$i]};
> > + RC=$?; # Return status of the task being waited
> > + # In abnormal termination of anyone trap will kill all others
> > + # and they will return non zero exit status. So Test broke!!
> > + if [ $RC -ne 0 ]
> > + then
> > + echo "Task $i exited abnormalywith return value: $RC";
> > + tst_resm TINFO "Test could not execute for the expected
> > duration";
> > + cleanup;
> > + exit -1;
> > + fi
> > + done
> > + echo "Cpu controller test executed successfully.Results written to
> > file";
> > + echo "Please review the results in $LTPROOT/output/cpuctl_results.txt"
> > + cleanup;
> > + cd $PWD
> > + exit 0; #to let PAN reprt success of test
> > Index: ltp-full-20071130/testcases/kernel/controllers/testplan.txt
> > ===================================================================
> > --- /dev/null
> > +++ ltp-full-20071130/testcases/kernel/controllers/testplan.txt
> > @@ -0,0 +1,10 @@
> > +THE RESOURCE MANAGEMENT (CONTROLLERS) TEST PLAN
> > +
> > +This directory "controllers" is created to include all test cases related
> > to the resource
> > +controllers in linux. The testplan at present includes testing of cpu
> > controller and memory
> > +controller. This is the first testcase in LTP to test the resource
> > controllers (and tests
> > +cpu controller only). Future testcases willl be included to test the cpu
> > controller further
> > +and memory controller. Each controller will have it's own directory to
> > contain all test cases.
> > +
> > +
> > +For more information on resource controllers please refer to cgroups.txt
> > in kernel documentation.
> > Index: ltp-full-20071130/testcases/kernel/controllers/test_controllers.sh
> > ===================================================================
> > --- /dev/null
> > +++ ltp-full-20071130/testcases/kernel/controllers/test_controllers.sh
> > @@ -0,0 +1,54 @@
> > +#!/bin/bash
> > +#usage ./test_controllers.sh
> > +##################################################################################
> > +# Copyright (c) International Business Machines Corp., 2007
> > #
> > +#
> > #
> > +# 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: test_controllers.sh
> > #
> > +#
> > #
> > +# Description:
> > #
> > +# This file runs the tests for resource management ie to
> > test cpu #
> > +# controller and memory controller. (for now cpu controller
> > only) #
> > +#
> > #
> > +# Author: Sudhir Kumar <[EMAIL PROTECTED]> #
> > +#
> > #
> > +# History:
> > #
> > +#
> > #
> > +# DATE NAME EMAIL DESC
> > #
> > +#
> > #
> > +# 20/12/07 Sudhir Kumar <[EMAIL PROTECTED]> Created this test #
> > +#
> > #
> > +##################################################################################
> > +
> > +if [ -f /proc/cgroups ]
> > +then
> > + CPU_CONTROLLER=`grep -w cpu /proc/cgroups | cut -f1`;
> > + if [ "$CPU_CONTROLLER" = "cpu" ]
> > + then
> > + $LTPROOT/testcases/bin/run_cpuctl_test.sh;
> > + else
> > + echo "CONTROLLERS TESTCASES: WARNING";
> > + echo "Kernel does not support for cpu controller";
> > + echo "Skipping all controllers testcases....";
> > + fi
> > +else
> > + echo "CONTROLLERS TESTCASES: WARNING"
> > + echo "Kernel does not support for control groups";
> > + echo "Skipping all controllers testcases....";
> > +fi
> > +
> > +exit 0;
> >
>
> --
> regards,
> Dhaval
-------------------------------------------------------------------------
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2008.
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
_______________________________________________
Ltp-list mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/ltp-list