diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 420b333..4360aba 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -10,7 +10,7 @@ jobs: - uses: actions/checkout@v2 - name: build run: | - brew install autoconf automake libtool + brew install autoconf automake libtool txt2man ./autogen.sh ./configure make @@ -30,6 +30,10 @@ jobs: runs-on: ubuntu-latest steps: - uses: actions/checkout@v2 + - name: install build dependencies + run: | + sudo apt-get update + sudo env DEBIAN_FRONTEND=noninteractive apt-get install -qy txt2man - name: first_build run: | ./autogen.sh diff --git a/Makefile.am b/Makefile.am index 238f5d9..98730ed 100644 --- a/Makefile.am +++ b/Makefile.am @@ -8,3 +8,13 @@ distclean-local: rm -rf autom4te.cache rm -f aclocal.m4 compile config.* configure depcomp INSTALL install-sh \ Makefile.in missing src/Makefile.in test-driver test/Makefile.in + +man/stress.1: man/stress.txt + txt2man -t stress \ + -r stress-@PACKAGE_VERSION@ \ + -d "@RELEASE_DAY@" \ + -s 1 \ + -v "tool to impose load on and stress test systems" \ + $< > $@ + +.PHONY: distclean-local diff --git a/configure.ac b/configure.ac index f0ad24b..643abb8 100644 --- a/configure.ac +++ b/configure.ac @@ -1,5 +1,6 @@ AC_PREREQ([2.69]) AC_INIT([stress], [1.0.7], [https://github.com/resurrecting-open-source-projects/stress/issues]) +AC_SUBST([RELEASE_DAY], ["21 Jan 2023"], [Day of release (used in man page)]) AC_CONFIG_SRCDIR([src/stress.c]) AC_CONFIG_HEADERS([config.h]) AM_INIT_AUTOMAKE @@ -17,6 +18,9 @@ AC_FUNC_FORK AC_FUNC_MALLOC AC_CHECK_FUNCS([alarm sqrt strerror]) +# Checks for build helpers +AC_CHECK_PROG(TXT2MAN_CHECK, txt2man, yes) +AS_IF([test x"$TXT2MAN_CHECK" != x"yes"], [AC_MSG_ERROR([txt2man tool needed to generate man page])]) # Special functions AC_ARG_ENABLE([static], AS_HELP_STRING([--enable-static], diff --git a/man/create-man.sh b/man/create-man.sh deleted file mode 100755 index 5ea345c..0000000 --- a/man/create-man.sh +++ /dev/null @@ -1,24 +0,0 @@ -#!/bin/bash - -# Copyright 2015-2020 Joao Eriberto Mota Filho -# Create a manpage using txt2man command. Version 2.0, 2020-06-19. -# This file is part of txt2man package for Debian. -# This script can be used under BSD-3-Clause license. - -#-------------------------------------------------------- -# Don't change the following lines -TEST=$(txt2man -h 2> /dev/null) -[ "$TEST" ] || { echo -e "\nYou need to install txt2man, from https://github.com/mvertes/txt2man.\n"; exit 1; } - -function create-man { -txt2man -d "$T2M_DATE" -t $T2M_NAME -r $T2M_NAME-$T2M_VERSION -s $T2M_LEVEL -v "$T2M_DESC" $T2M_NAME.txt > $T2M_NAME.$T2M_LEVEL -} -#-------------------------------------------------------- - -# Put here all data for your first manpage (in T2M lines) -T2M_DATE="21 Jan 2023" -T2M_NAME=stress -T2M_VERSION=1.0.7 -T2M_LEVEL=1 -T2M_DESC="tool to impose load on and stress test systems" -create-man diff --git a/man/stress.1 b/man/stress.1 deleted file mode 100644 index edeb65a..0000000 --- a/man/stress.1 +++ /dev/null @@ -1,152 +0,0 @@ -.\" Text automatically generated by txt2man -.TH stress 1 "21 Jan 2023" "stress-1.0.7" "tool to impose load on and stress test systems" -.SH NAME -\fBstress \fP- tool to impose load on and stress test a computer system -\fB -.SH SYNOPSIS -.nf -.fam C - \fBstress\fP [\fIOPTIONS\fP] - -.fam T -.fi -.fam T -.fi -.SH DESCRIPTION -\fBstress\fP is a tool that imposes a configurable amount of CPU, memory, I/O, -or disk \fBstress\fP on a POSIX-compliant operating system and reports any errors -it detects. -.PP -\fBstress\fP is not a benchmark. It is a tool used by system administrators to -evaluate how well their systems will scale, by kernel programmers to evaluate -perceived performance characteristics, and by systems programmers to expose -the classes of bugs which only or more frequently manifest themselves when -the system is under heavy load. -.SH OPTIONS -.TP -.B --?, \fB--help\fP -Show this help statement. -.TP -.B -\fB--version\fP -Show version statement. -.TP -.B -\fB-v\fP, \fB--verbose\fP -Be verbose. -.TP -.B -\fB-q\fP, \fB--quiet\fP -Be quiet. -.TP -.B -\fB-n\fP, \fB--dry-run\fP -Show what would have been done. -.TP -.B -\fB-t\fP, \fB--timeout\fP -Timeout after N seconds. This option is ignored by \fB-n\fP. -.TP -.B -\fB--backoff\fP -Wait for factor of microseconds before starting work. -.TP -.B -\fB-c\fP, \fB--cpu\fP -Spawn N workers spinning on \fBsqrt\fP(). -.TP -.B -\fB-i\fP, \fB--io\fP -Spawn N workers spinning on \fBsync\fP(). -.TP -.B -\fB-m\fP, \fB--vm\fP -Spawn N workers spinning on \fBmalloc\fP()/free(). -.TP -.B -\fB--vm-bytes\fP -Malloc B bytes per vm worker (default is 256MB). -.TP -.B -\fB--vm-stride\fP -Touch a byte every B bytes (default is 4096). -.TP -.B -\fB--vm-hang\fP -Sleep N secs before free (default none, 0 is inf). -.TP -.B -\fB--vm-keep\fP -Redirty memory instead of freeing and reallocating. -.TP -.B -\fB-d\fP, \fB--hdd\fP -Spawn N workers spinning on \fBwrite\fP()/unlink(). -.TP -.B -\fB--hdd-bytes\fP -Write B bytes per hdd worker (default is 1GB). The file -will be created with \fBmkstemp\fP() in the current directory. -.PP -Note: Numbers may be suffixed with s,m,h,d,y (time) or B,K,M,G (size). -.SH EXAMPLES -The simple case is that you just want to bring the system load average up to an -arbitrary value. The following forks 13 processes, each of which spins in a -tight loop calculating the \fBsqrt\fP() of a random number acquired with \fBrand\fP(). -.PP -.nf -.fam C - stress -c 13 - -.fam T -.fi -Long options are supported, as well as is making the output less verbose. The -following forks 1024 processes, and only reports error messages if any. -.PP -.nf -.fam C - stress --quiet --cpu 1k - -.fam T -.fi -To see how your system performs when it is I/O bound, use the \fB-i\fP switch. The -following forks 4 processes, each of which spins in a tight loop calling -\fBsync\fP(), which is a system call that flushes memory buffers to disk. -.PP -.nf -.fam C - stress -i 4 - -.fam T -.fi -Multiple hogs may be combined on the same command line. The following does -everything the preceding examples did in one command, but also turns up the -verbosity level as well as showing how to cause the command to self-terminate -after 1 minute. -.PP -.nf -.fam C - stress -c 13 -i 4 --verbose --timeout 1m - -.fam T -.fi -You can write a file of arbitrary length to disk. The file is created with -\fBmkstemp\fP() in the current directory. -.PP -.nf -.fam C - stress -d 1 --hdd-bytes 13 - - Large file support is enabled. - - stress -d 1 --hdd-bytes 3G - -.fam T -.fi -.SH AUTHOR -\fBstress\fP was originally developed by Amos Waterland and -is maintained by some volunteers. -.PP -Currently, source code and newer versions are available at -https://github.com/resurrecting-open-source-projects/\fBstress\fP diff --git a/man/stress.txt b/man/stress.txt index 0771a61..d728fdd 100644 --- a/man/stress.txt +++ b/man/stress.txt @@ -23,7 +23,8 @@ OPTIONS -n, --dry-run Show what would have been done. -t, --timeout Timeout after N seconds. This option is ignored by -n. --backoff Wait for factor of microseconds before starting work. - -c, --cpu Spawn N workers spinning on sqrt(). + -c, --cpu Spawn N workers spinning on pseudo-random number generation + and sqrt(). -i, --io Spawn N workers spinning on sync(). -m, --vm Spawn N workers spinning on malloc()/free(). --vm-bytes Malloc B bytes per vm worker (default is 256MB). @@ -39,7 +40,8 @@ OPTIONS EXAMPLES The simple case is that you just want to bring the system load average up to an arbitrary value. The following forks 13 processes, each of which spins in a - tight loop calculating the sqrt() of a random number acquired with rand(). + tight loop calculating the sqrt() of a random number acquired from a fixed-seed + pseudo-random number generator (xoroshiro128+). stress -c 13 diff --git a/src/stress.c b/src/stress.c index a02c53e..e5fec8b 100644 --- a/src/stress.c +++ b/src/stress.c @@ -3,6 +3,7 @@ * Copyright 2001-2010 Amos Waterland * Copyright 2021-2023 Joao Eriberto Mota Filho * Copyright 2023 Vratislav Bendel + * Copyright 2025 Marcus Müller * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License @@ -23,6 +24,7 @@ #include #include #include +#include #include #include #include @@ -479,9 +481,47 @@ void worker_init(void) int hogcpu (void) { - while (1) - sqrt (rand ()); - + /* initial state for PRNG */ + static uint32_t s[] = { + 4 /* chosen by fair dice roll */, + 42 /* the answer */, + 3 /* pi */, + 0xCAFECA4E /* because who doesn't like cake? */ + }; + while (1) { + /* START xoroshirp128plus: + Written in 2018 by David Blackman and Sebastiano Vigna (vigna@acm.org) + + To the extent possible under law, the author has dedicated all copyright + and related and neighboring rights to this software to the public domain + worldwide. + + Permission to use, copy, modify, and/or distribute this software for any + purpose with or without fee is hereby granted. + + THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES + WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF + MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR + ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES + WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN + ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR + IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + */ + + const uint32_t result = s[0] + s[3]; + const uint32_t t = s[1] << 9; + + s[2] ^= s[0]; + s[3] ^= s[1]; + s[1] ^= s[2]; + s[0] ^= s[3]; + + s[2] ^= t; + + s[3] = (s[3] << 11) | (s[3]>> (32-11)); + /* END xoroshirp128plus */ + volatile double value = sqrt ((double)(result)); + } return 0; } @@ -762,7 +802,8 @@ usage (int status) " -n, --dry-run show what would have been done\n" " -t, --timeout N timeout after N seconds\n" " --backoff N wait factor of N microseconds before work starts\n" - " -c, --cpu N spawn N workers spinning on sqrt()\n" + " -c, --cpu N spawn N workers spinning on pseudo-random number generation\n" + " and sqrt()\n" " -i, --io N spawn N workers spinning on sync()\n" " -m, --vm N spawn N workers spinning on malloc()/free()\n" " --vm-bytes B malloc B bytes per vm worker (default is 256MB)\n"