By default, the autotest wrapper for stress is assigning a number of workers of every tipe (CPU, memory, disk) equal to 2 times the number of CPUs detected on the machine. As the default memory chunk used by each memory worker is 256 MB and the default file size is 1GB, there might be occasions where:
1) n_memory_workers * 256 MB > Available memory 2) n_hdd_workers * 1GB > Space available on FS If 1) is met, system goes OOM and then kernel starts to kill processes, creating a real mess. If 2) is met, the test will fail. So let's fix the heuristic being used to evaluate the sizes per thread when no parameters to the program stress are provided. Signed-off-by: Lucas Meneghel Rodrigues <[email protected]> --- client/tests/stress/control | 33 +++++++++++++++++++- client/tests/stress/stress.py | 69 +++++++++++++++++++++++++---------------- 2 files changed, 74 insertions(+), 28 deletions(-) diff --git a/client/tests/stress/control b/client/tests/stress/control index 1b53cc2..75272b2 100644 --- a/client/tests/stress/control +++ b/client/tests/stress/control @@ -6,6 +6,37 @@ TIME='MEDIUM' TEST_CATEGORY='Functional' TEST_CLASS='Software' DOC='''\ -stress is not a benchmark, but is rather a tool designed to put given subsytems under a specified load. Instances in which this is useful include those in which a system administrator wishes to perform tuning activities, a kernel or libc programmer wishes to evaluate denial of service possibilities, etc. +stress is not a benchmark, but is rather a tool designed to put given subsytems +under a specified load. Instances in which this is useful include those in +which a system administrator wishes to perform tuning activities, a kernel or +libc programmer wishes to evaluate denial of service possibilities, etc. + +Stress command line options: + + -?, --help show this help statement + --version show version statement + -v, --verbose be verbose + -q, --quiet be quiet + -n, --dry-run show what would have been done + -t, --timeout N timeout after N seconds + --backoff N wait factor of N microseconds before work starts + -c, --cpu N spawn N workers spinning on sqrt() + -i, --io N spawn N workers spinning on sync() + -m, --vm N spawn N workers spinning on malloc()/free() + --vm-bytes B malloc B bytes per vm worker (default is 256MB) + --vm-stride B touch a byte every B bytes (default is 4096) + --vm-hang N sleep N secs before free (default is none, 0 is inf) + --vm-keep redirty memory instead of freeing and reallocating + -d, --hdd N spawn N workers spinning on write()/unlink() + --hdd-bytes B write B bytes per hdd worker (default is 1GB) + --hdd-noclean do not unlink files created by hdd workers + Example: %s --cpu 8 --io 4 --vm 2 --vm-bytes 128M --timeout 10s + Note: Numbers may be suffixed with s,m,h,d,y (time) or B,K,M,G (size). + +Autotest module options: + args = Arguments passed to the stress test. If omitted, an heuristic + will be used to calculate sensible defaults + stress_length = Time length on which stress will run, in seconds. + By default is 60s. ''' job.run_test('stress') diff --git a/client/tests/stress/stress.py b/client/tests/stress/stress.py index 61708a8..c0447b2 100644 --- a/client/tests/stress/stress.py +++ b/client/tests/stress/stress.py @@ -3,6 +3,14 @@ from autotest_lib.client.bin import test, utils class stress(test.test): + """ + Calls stress, a simple program which aims to impose certain types of + computing stress on the target machine. + @author: Yi Yang ([email protected]) + + In order to verify at a glance the options supported by the program stress, + check out the options summary located at the stress example control file. + """ version = 1 def initialize(self): @@ -19,33 +27,40 @@ class stress(test.test): utils.system('make') - def run_once(self, args = ''): + def run_once(self, args = '', stress_length=60): if not args: - threads = 2*utils.count_cpus() - args = '-c %d -i %d -m %d -d %d -t 60 -v' % \ - (threads, threads, threads, threads) + # We will use 2 workers of each type for each CPU detected + threads = 2 * utils.count_cpus() - utils.system(self.srcdir + '/src/stress ' + args) + # Sometimes the default memory used by each memory worker (256 M) + # might make our machine go OOM and then funny things might start to + # happen. Let's avoid that. + mb = utils.freememtotal() + utils.read_from_meminfo('SwapFree') / 2 + memory_per_thread = (mb * 1024) / threads + + # Even though unlikely, it's good to prevent from allocating more + # disk than this machine actually has on its autotest directory + # (limit the amount of disk used to max of 90 % of free space) + free_disk = utils.freespace(self.srcdir) + file_size_per_thread = 1024 ** 2 + if (0.9 * free_disk) < file_size_per_thread * threads: + file_size_per_thread = (0.9 * free_disk) / threads -# -v Turn up verbosity. -# -q Turn down verbosity. -# -n Show what would have been done (dry-run) -# -t secs Time out after secs seconds. -# --backoff usecs Wait for factor of usecs microseconds before starting -# -c forks Spawn forks processes each spinning on sqrt(). -# -i forks Spawn forks processes each spinning on sync(). -# -m forks Spawn forks processes each spinning on malloc(). -# --vm-bytes bytes Allocate bytes number of bytes. The default is 1. -# --vm-hang Instruct each vm hog process to go to sleep after -# allocating memory. This contrasts with their normal -# behavior, which is to free the memory and reallocate -# ad infinitum. This is useful for simulating low memory -# conditions on a machine. For example, the following -# command allocates 256M of RAM and holds it until killed. -# -# % stress --vm 2 --vm-bytes 128M --vm-hang -# -d forks Spawn forks processes each spinning on write(). -# --hdd-bytes bytes Write bytes number of bytes. The default is 1GB. -# --hdd-noclean Do not unlink file(s) to which random data is written. -# -# Note: Suffixes may be s,m,h,d,y (time) or k,m,g (size). + # Number of CPU workers spinning on sqrt() + args = '--cpu %d ' % threads + # Number of IO workers spinning on sync() + args += '--io %d ' % threads + # Number of Memory workers spinning on malloc()/free() + args += '--vm %d ' % threads + # Amount of memory used per each worker + args += '--vm-bytes %d ' % memory_per_thread + # Number of HD workers spinning on write()/ulink() + args += '--hdd %d ' % threads + # Size of the files created by each worker in bytes + args += '--hdd-bytes %d ' % file_size_per_thread + # Time for which the stress test will run + args += '--timeout %d ' % stress_length + # Verbose flag + args += '--verbose' + + utils.system(self.srcdir + '/src/stress ' + args) -- 1.6.5.2 _______________________________________________ Autotest mailing list [email protected] http://test.kernel.org/cgi-bin/mailman/listinfo/autotest
