diff -Nru stress-ng-0.03.18/coredump.c stress-ng-0.03.15/coredump.c --- stress-ng-0.03.18/coredump.c 2015-02-17 18:29:01.000000000 +0000 +++ stress-ng-0.03.15/coredump.c 2015-02-09 23:44:46.000000000 +0000 @@ -29,7 +29,7 @@ #include "stress-ng.h" -#if defined(__linux__) +#if defined (__linux__) /* * set_coredump() * limit what is coredumped because diff -Nru stress-ng-0.03.18/debian/changelog stress-ng-0.03.15/debian/changelog --- stress-ng-0.03.18/debian/changelog 2015-02-18 16:06:42.000000000 +0000 +++ stress-ng-0.03.15/debian/changelog 2015-02-21 21:51:35.000000000 +0000 @@ -1,79 +1,8 @@ -stress-ng (0.03.18-1) unstable; urgency=medium +stress-ng (0.03.15-1~ubuntu14.04.1) trusty-backports; urgency=medium - * Makefile: bump version - * Move order of hadamard matrix method, now in alphabetical order - * Fix macro typos - STESS -> STRESS (LP: #1423241) - * Add in matrix info into help + * No-change backport to trusty (LP: #1420154) - -- Colin King Wed, 18 Feb 2015 16:08:00 +0000 - -stress-ng (0.03.17-1) unstable; urgency=medium - - * Makefile: bump version - * Fix name clash on union on *BSD systems - * Explicitly ignore return from wait*() calls by (void) cast - * Add minimize/maximize to matrix size - * Add --cache-prefetch option - * Make opt_sequential int32 and print out hogs if --seq is being used - * Handle builds for system calls that don't exist - * stress-vm-rw: include missing header - * Ignore args in kcmp for systems that don't support this call - * Forgot ULL after fibonacci uint64_t assignment, warning on 32 bit mips - * Add longjmp stressor - * Constify a few more function args - * Add in some shifts to vecmath - * Constify a few more func args - * Make cache no-ops into do {} while (0) statement - * Move PR_* bit flags to bottom nybble, makes stress-ng smaller - * Fix spelling mistake in manual: subtrace -> subtract - * Forgot to capitalise the matrix product methods - * Add two more matrix product methods - * man page: long double floats -> floats for matrix - * Add matrix stressor with a bunch of stressor methods - * stress-shm-sysv: initialise shm_ids as -1 to indicate not set - * Use semun union when passing values to semctl, fixes powerpc segfault - * stress-rdrand: move #includes to fix build warning on ARM - * Make mallopt code depend on GNUC and linux - * Reduce MAX stress-fallocate allocation size for 32 bit systems - * Move #includes in io-priority to stop build warnings - * Add --malloc-thresh tuneable option - * Used #if defined(...) consistently. - * Munge stressor names when showing hoggers - * Remove repeated #if defined() checks, simplify them into stress-ng.h - * Add another example to the manual - * Increase maximum lease breakers - * stress-lease: max sure the pid array is large enough - * Add --aggressive option - * Don't print null string of no hogs listed when dispatching hogd - * Add --minimize and --maximize options - * Add --stack-fill option - * Update syscalls.txt with recently added syscalls - * stress-fallocate: only use fallocate if FALLOC_FL_* defined - * stress-fallocate: employ linux fallocate on linux builds - * Add --fallocate-bytes option - - -- Colin King Tue, 17 Feb 2015 18:28:00 +0000 - -stress-ng (0.03.16-1) unstable; urgency=medium - - * Makefile: bump version again - * Fix missing .TP in man page - * Re-work the "dispatching hogs" message to log atomically - * Add --syslog option to log non-debug messages to syslog - * stress-hdd: don't use strtok_r, we're not threaded - * Just define KCMP_* ourselves, broken distros don't have linux/kcmp.h - * stress-kcmp: close fd1, fix resource leak - * Add kcmp stressor - * Remove unnecessary { } - * Remove redundant assignment of first enum to zero - * Make --random 0 select the number of on-line CPUs - * Forgot to make RDRAND check arch specific - * Add check to see if rdrand is supported and skip stressor if not - * stress-pthread: increase to 1024 pthreads per stressor - * stress-pthread: handle error correctly; as from the return from pthread* - * Make pr_failed more generic and make a new pr_failed_errno macro - - -- Colin King Fri, 13 Feb 2015 19:40:00 +0000 + -- Felix Geyer Sat, 21 Feb 2015 22:51:35 +0100 stress-ng (0.03.15-1) unstable; urgency=medium diff -Nru stress-ng-0.03.18/io-priority.c stress-ng-0.03.15/io-priority.c --- stress-ng-0.03.18/io-priority.c 2015-02-17 18:29:01.000000000 +0000 +++ stress-ng-0.03.15/io-priority.c 2015-02-09 23:44:46.000000000 +0000 @@ -24,15 +24,11 @@ */ #define _GNU_SOURCE -#include "stress-ng.h" - #include #include #include #include - -#if defined(STRESS_IOPRIO) - +#if defined (__linux__) #include /* @@ -51,6 +47,7 @@ #define IOPRIO_PRIO_VALUE(class, data) (((class) << 13) | data) #endif +#include "stress-ng.h" /* * get_opt_ionice_class() @@ -58,16 +55,16 @@ */ int get_opt_ionice_class(const char *const str) { -#if defined(IOPRIO_CLASS_IDLE) +#if defined (IOPRIO_CLASS_IDLE) if (!strcmp("idle", str)) return IOPRIO_CLASS_IDLE; #endif -#if defined(IOPRIO_CLASS_BE) +#if defined (IOPRIO_CLASS_BE) if (!strcmp("besteffort", str) || !strcmp("be", str)) return IOPRIO_CLASS_BE; #endif -#if defined(IOPRIO_CLASS_RT) +#if defined (IOPRIO_CLASS_RT) if (!strcmp("realtime", str) || !strcmp("rt", str)) return IOPRIO_CLASS_RT; @@ -76,13 +73,13 @@ fprintf(stderr, "Invalid ionice-class option: %s\n", str); fprintf(stderr, "Available options are:"); -#if defined(IOPRIO_CLASS_IDLE) +#if defined (IOPRIO_CLASS_IDLE) fprintf(stderr, " idle"); #endif -#if defined(IOPRIO_CLASS_BE) +#if defined (IOPRIO_CLASS_BE) fprintf(stderr, " besteffort be"); #endif -#if defined(IOPRIO_CLASS_RT) +#if defined (IOPRIO_CLASS_RT) fprintf(stderr, " realtime rt"); #endif fprintf(stderr, "\n"); @@ -90,7 +87,7 @@ exit(EXIT_FAILURE); } -#if defined(STRESS_IOPRIO) +#if defined (__linux__) /* * ioprio_set() * ioprio_set system call diff -Nru stress-ng-0.03.18/log.c stress-ng-0.03.15/log.c --- stress-ng-0.03.18/log.c 2015-02-17 18:29:01.000000000 +0000 +++ stress-ng-0.03.15/log.c 2015-02-09 23:44:46.000000000 +0000 @@ -28,7 +28,6 @@ #include #include #include -#include #include "stress-ng.h" @@ -41,7 +40,7 @@ */ int print( FILE *fp, - const uint64_t flag, + const int flag, const char *const fmt, ...) { va_list ap; @@ -59,12 +58,14 @@ type = "debug"; if (flag & PR_INFO) type = "info"; - if (flag & PR_FAIL) + if (flag & PR_FAIL) { type = "fail"; + } - n = snprintf(buf, sizeof(buf), "%s: [%i] ", type, getpid()); + n = snprintf(buf, sizeof(buf), "%s: %s: [%i] ", + app_name, type, getpid()); ret = vsnprintf(buf + n, sizeof(buf) - n, fmt, ap); - fprintf(fp, "%s: %s", app_name, buf); + fprintf(fp, "%s", buf); fflush(fp); if (flag & PR_FAIL) { @@ -78,12 +79,6 @@ } } } - - /* Log messages if syslog requested, don't log DEBUG */ - if ((opt_flags & OPT_FLAGS_SYSLOG) && - (!(flag & PR_DEBUG))) { - syslog(LOG_INFO, "%s", buf); - } } va_end(ap); @@ -94,13 +89,9 @@ * pr_failed() * print failure message with errno */ -void pr_failed( - const uint64_t flag, - const char *name, - const char *what, - const int err) +void pr_failed(const int flag, const char *name, const char *what) { print(stderr, flag, "%s: %s failed, errno=%d (%s)\n", - name, what, err, strerror(err)); + name, what, errno, strerror(errno)); } diff -Nru stress-ng-0.03.18/madvise.c stress-ng-0.03.15/madvise.c --- stress-ng-0.03.18/madvise.c 2015-02-17 18:29:01.000000000 +0000 +++ stress-ng-0.03.15/madvise.c 2015-02-09 23:44:46.000000000 +0000 @@ -88,7 +88,7 @@ * madvise_random() * apply random madvise setting to a memory region */ -int madvise_random(void *addr, const size_t length) +int madvise_random(void *addr, size_t length) { #if _BSD_SOURCE if (opt_flags & OPT_FLAGS_MMAP_MADVISE) { diff -Nru stress-ng-0.03.18/Makefile stress-ng-0.03.15/Makefile --- stress-ng-0.03.18/Makefile 2015-02-18 16:06:42.000000000 +0000 +++ stress-ng-0.03.15/Makefile 2015-02-09 23:44:46.000000000 +0000 @@ -16,7 +16,7 @@ # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. # -VERSION=0.03.18 +VERSION=0.03.15 # # Codename "stressed silicon" # @@ -52,15 +52,12 @@ stress-hsearch.c \ stress-inotify.c \ stress-iosync.c \ - stress-kcmp.c \ stress-kill.c \ stress-lease.c \ stress-lsearch.c \ stress-link.c \ stress-lockf.c \ - stress-longjmp.c \ stress-malloc.c \ - stress-matrix.c \ stress-memcpy.c \ stress-mincore.c \ stress-mmap.c \ diff -Nru stress-ng-0.03.18/mincore.c stress-ng-0.03.15/mincore.c --- stress-ng-0.03.18/mincore.c 2015-02-17 18:29:01.000000000 +0000 +++ stress-ng-0.03.15/mincore.c 2015-02-09 23:44:46.000000000 +0000 @@ -35,7 +35,7 @@ * madvise_random() * apply random madvise setting to a memory region */ -int mincore_touch_pages(void *buf, const size_t buf_len) +int mincore_touch_pages(void *buf, size_t buf_len) { #if (_BSD_SOURCE || _SVID_SOURCE) && !defined(__gnu_hurd__) unsigned char *vec; diff -Nru stress-ng-0.03.18/out-of-memory.c stress-ng-0.03.15/out-of-memory.c --- stress-ng-0.03.18/out-of-memory.c 2015-02-17 18:29:01.000000000 +0000 +++ stress-ng-0.03.15/out-of-memory.c 2015-02-09 23:44:46.000000000 +0000 @@ -33,14 +33,14 @@ #include "stress-ng.h" -#if defined(__linux__) +#if defined (__linux__) /* * set_oom_adjustment() * attempt to stop oom killer * if we have root privileges then try and make process * unkillable by oom killer */ -void set_oom_adjustment(const char *name, const bool killable) +void set_oom_adjustment(const char *name, bool killable) { char path[PATH_MAX]; int fd; @@ -91,7 +91,7 @@ return; } #else -void set_oom_adjustment(const char *name, const bool killable) +void set_oom_adjustment(const char *name, bool killable) { (void)name; (void)killable; diff -Nru stress-ng-0.03.18/proc-name.c stress-ng-0.03.15/proc-name.c --- stress-ng-0.03.18/proc-name.c 2015-02-17 18:29:01.000000000 +0000 +++ stress-ng-0.03.15/proc-name.c 2015-02-09 23:44:46.000000000 +0000 @@ -26,7 +26,7 @@ #include "stress-ng.h" -#if defined(__linux__) +#if defined (__linux__) #include /* diff -Nru stress-ng-0.03.18/sched.c stress-ng-0.03.15/sched.c --- stress-ng-0.03.18/sched.c 2015-02-17 18:29:01.000000000 +0000 +++ stress-ng-0.03.15/sched.c 2015-02-09 23:44:46.000000000 +0000 @@ -41,7 +41,7 @@ */ void set_sched(const int sched, const int sched_priority) { -#if defined(SCHED_FIFO) || defined(SCHED_RR) +#if defined (SCHED_FIFO) || defined (SCHED_RR) int min, max; #endif int rc; @@ -50,7 +50,7 @@ switch (sched) { case UNDEFINED: /* No preference, don't set */ return; -#if defined(SCHED_FIFO) || defined(SCHED_RR) +#if defined (SCHED_FIFO) || defined (SCHED_RR) case SCHED_FIFO: case SCHED_RR: min = sched_get_priority_min(sched); diff -Nru stress-ng-0.03.18/stress-affinity.c stress-ng-0.03.15/stress-affinity.c --- stress-ng-0.03.18/stress-affinity.c 2015-02-17 18:29:01.000000000 +0000 +++ stress-ng-0.03.15/stress-affinity.c 2015-02-09 23:44:46.000000000 +0000 @@ -24,9 +24,7 @@ */ #define _GNU_SOURCE -#include "stress-ng.h" - -#if defined(STRESS_AFFINITY) +#if defined(__linux__) #include #include @@ -34,6 +32,7 @@ #include #include +#include "stress-ng.h" /* * stress on sched_affinity() diff -Nru stress-ng-0.03.18/stress-aio.c stress-ng-0.03.15/stress-aio.c --- stress-ng-0.03.18/stress-aio.c 2015-02-17 18:29:01.000000000 +0000 +++ stress-ng-0.03.15/stress-aio.c 2015-02-09 23:44:46.000000000 +0000 @@ -24,9 +24,7 @@ */ #define _GNU_SOURCE -#include "stress-ng.h" - -#if defined(STRESS_AIO) +#if defined (__linux__) #include #include @@ -39,11 +37,11 @@ #include #include +#include "stress-ng.h" #define BUFFER_SZ (16) static uint64_t opt_aio_requests = DEFAULT_AIO_REQUESTS; -static bool set_aio_requests = false; /* per request async I/O data */ typedef struct { @@ -56,7 +54,6 @@ void stress_set_aio_requests(const char *optarg) { - set_aio_requests = true; opt_aio_requests = get_uint64(optarg); check_range("aio-requests", opt_aio_requests, MIN_AIO_REQUESTS, MAX_AIO_REQUESTS); @@ -73,13 +70,6 @@ { register size_t i; - if (!set_aio_requests) { - if (opt_flags & OPT_FLAGS_MAXIMIZE) - opt_aio_requests = MAX_AIO_REQUESTS; - if (opt_flags & OPT_FLAGS_MINIMIZE) - opt_aio_requests = MIN_AIO_REQUESTS; - } - for (i = 0; i < size; i++) buffer[i] = request + i; } diff -Nru stress-ng-0.03.18/stress-bigheap.c stress-ng-0.03.15/stress-bigheap.c --- stress-ng-0.03.18/stress-bigheap.c 2015-02-17 18:29:01.000000000 +0000 +++ stress-ng-0.03.15/stress-bigheap.c 2015-02-09 23:44:46.000000000 +0000 @@ -39,7 +39,7 @@ #include "stress-ng.h" static uint64_t opt_bigheap_growth = DEFAULT_BIGHEAP_GROWTH; -static bool set_bigheap_growth = false; + /* * stress_set_bigheap_growth() @@ -47,7 +47,6 @@ */ void stress_set_bigheap_growth(const char *optarg) { - set_bigheap_growth = true; opt_bigheap_growth = get_uint64_byte(optarg); check_range("bigheap-growth", opt_bigheap_growth, MIN_BIGHEAP_GROWTH, MAX_BIGHEAP_GROWTH); @@ -71,12 +70,6 @@ uint32_t restarts = 0, nomems = 0; const size_t page_size = stress_get_pagesize(); - if (!set_bigheap_growth) { - if (opt_flags & OPT_FLAGS_MAXIMIZE) - opt_bigheap_growth = MAX_BIGHEAP_GROWTH; - if (opt_flags & OPT_FLAGS_MINIMIZE) - opt_bigheap_growth = MIN_BIGHEAP_GROWTH; - } again: pid = fork(); if (pid < 0) { @@ -92,7 +85,7 @@ name, errno, strerror(errno)); (void)kill(pid, SIGTERM); (void)kill(pid, SIGKILL); - (void)waitpid(pid, &status, 0); + waitpid(pid, &status, 0); } else if (WIFSIGNALED(status)) { pr_dbg(stderr, "%s: child died: %d (instance %d)\n", name, WTERMSIG(status), instance); diff -Nru stress-ng-0.03.18/stress-brk.c stress-ng-0.03.15/stress-brk.c --- stress-ng-0.03.18/stress-brk.c 2015-02-17 18:29:01.000000000 +0000 +++ stress-ng-0.03.15/stress-brk.c 2015-02-09 23:44:46.000000000 +0000 @@ -67,7 +67,7 @@ name, errno, strerror(errno)); (void)kill(pid, SIGTERM); (void)kill(pid, SIGKILL); - (void)waitpid(pid, &status, 0); + waitpid(pid, &status, 0); } else if (WIFSIGNALED(status)) { pr_dbg(stderr, "%s: child died: %d (instance %d)\n", name, WTERMSIG(status), instance); diff -Nru stress-ng-0.03.18/stress-bsearch.c stress-ng-0.03.15/stress-bsearch.c --- stress-ng-0.03.18/stress-bsearch.c 2015-02-17 18:29:01.000000000 +0000 +++ stress-ng-0.03.15/stress-bsearch.c 2015-02-09 23:44:46.000000000 +0000 @@ -30,8 +30,7 @@ #include "stress-ng.h" -static uint64_t opt_bsearch_size = DEFAULT_BSEARCH_SIZE; -static bool set_bsearch_size = false; +uint64_t opt_bsearch_size = DEFAULT_BSEARCH_SIZE; /* * stress_set_bsearch_size() @@ -39,7 +38,6 @@ */ void stress_set_bsearch_size(const char *optarg) { - set_bsearch_size = true; opt_bsearch_size = get_uint64_byte(optarg); check_range("bsearch-size", opt_bsearch_size, MIN_BSEARCH_SIZE, MAX_BSEARCH_SIZE); @@ -82,19 +80,12 @@ const char *name) { int32_t *data, *ptr, prev = 0; - size_t n, n8, i; + const size_t n = (size_t)opt_bsearch_size; + const size_t n8 = (n + 7) & ~7; + size_t i; (void)instance; - if (!set_bsearch_size) { - if (opt_flags & OPT_FLAGS_MAXIMIZE) - opt_bsearch_size = MAX_BSEARCH_SIZE; - if (opt_flags & OPT_FLAGS_MINIMIZE) - opt_bsearch_size = MIN_BSEARCH_SIZE; - } - n = (size_t)opt_bsearch_size; - n8 = (n + 7) & ~7; - /* allocate in multiples of 8 */ if ((data = malloc(sizeof(int32_t) * n8)) == NULL) { pr_failed_dbg(name, "malloc"); @@ -127,6 +118,7 @@ pr_fail(stderr, "element %zu found %" PRIu32 ", expecting %" PRIu32 "\n", i, *result, *ptr); } + } (*counter)++; } while (opt_do_run && (!max_ops || *counter < max_ops)); diff -Nru stress-ng-0.03.18/stress-cache.c stress-ng-0.03.15/stress-cache.c --- stress-ng-0.03.18/stress-cache.c 2015-02-17 18:29:01.000000000 +0000 +++ stress-ng-0.03.15/stress-cache.c 2015-02-09 23:44:46.000000000 +0000 @@ -27,7 +27,7 @@ #include #include #include -#if defined(_POSIX_PRIORITY_SCHEDULING) || defined(__linux__) +#if defined (_POSIX_PRIORITY_SCHEDULING) || defined (__linux__) #include #endif @@ -36,9 +36,6 @@ /* The compiler optimises out the unused cache flush and mfence calls */ #define CACHE_WRITE(flag) \ for (j = 0; j < MEM_CACHE_SIZE; j++) { \ - if ((flag) & OPT_FLAGS_CACHE_PREFETCH) { \ - __builtin_prefetch(&mem_cache[i + 1], 1, 1); \ - } \ mem_cache[i] += mem_cache[(MEM_CACHE_SIZE - 1) - i] + r;\ if ((flag) & OPT_FLAGS_CACHE_FLUSH) { \ clflush(&mem_cache[i]); \ @@ -89,18 +86,6 @@ case OPT_FLAGS_CACHE_FENCE | OPT_FLAGS_CACHE_FLUSH: CACHE_WRITE(OPT_FLAGS_CACHE_FLUSH | OPT_FLAGS_CACHE_FENCE); break; - case OPT_FLAGS_CACHE_PREFETCH: - CACHE_WRITE(OPT_FLAGS_CACHE_PREFETCH); - break; - case OPT_FLAGS_CACHE_PREFETCH | OPT_FLAGS_CACHE_FLUSH: - CACHE_WRITE(OPT_FLAGS_CACHE_PREFETCH | OPT_FLAGS_CACHE_FLUSH); - break; - case OPT_FLAGS_CACHE_PREFETCH | OPT_FLAGS_CACHE_FENCE: - CACHE_WRITE(OPT_FLAGS_CACHE_PREFETCH | OPT_FLAGS_CACHE_FENCE); - break; - case OPT_FLAGS_CACHE_PREFETCH | OPT_FLAGS_CACHE_FLUSH | OPT_FLAGS_CACHE_FENCE: - CACHE_WRITE(OPT_FLAGS_CACHE_PREFETCH | OPT_FLAGS_CACHE_FLUSH | OPT_FLAGS_CACHE_FENCE); - break; default: CACHE_WRITE(0); break; diff -Nru stress-ng-0.03.18/stress-clock.c stress-ng-0.03.15/stress-clock.c --- stress-ng-0.03.18/stress-clock.c 2015-02-17 18:29:01.000000000 +0000 +++ stress-ng-0.03.15/stress-clock.c 2015-02-09 23:44:46.000000000 +0000 @@ -24,8 +24,6 @@ */ #define _GNU_SOURCE -#include "stress-ng.h" - #include #include #include @@ -34,7 +32,9 @@ #include #include -#if defined(STRESS_CLOCK) +#if _POSIX_C_SOURCE >= 199309L + +#include "stress-ng.h" static const int clocks[] = { #ifdef CLOCK_REALTIME diff -Nru stress-ng-0.03.18/stress-cpu.c stress-ng-0.03.15/stress-cpu.c --- stress-ng-0.03.18/stress-cpu.c 2015-02-17 18:29:01.000000000 +0000 +++ stress-ng-0.03.15/stress-cpu.c 2015-02-09 23:44:46.000000000 +0000 @@ -1044,7 +1044,7 @@ */ static void stress_cpu_fibonacci(void) { - const uint64_t fn_res = 0xa94fad42221f2702ULL; + const uint64_t fn_res = 0xa94fad42221f2702; register uint64_t f1 = 0, f2 = 1, fn; do { diff -Nru stress-ng-0.03.18/stress-dentry.c stress-ng-0.03.15/stress-dentry.c --- stress-ng-0.03.18/stress-dentry.c 2015-02-17 18:29:01.000000000 +0000 +++ stress-ng-0.03.15/stress-dentry.c 2015-02-09 23:44:46.000000000 +0000 @@ -58,11 +58,9 @@ static dentry_order_t order = ORDER_REVERSE; static uint64_t opt_dentries = DEFAULT_DENTRIES; -static bool set_dentries = false; void stress_set_dentries(const char *optarg) { - set_dentries = true; opt_dentries = get_uint64(optarg); check_range("dentries", opt_dentries, MIN_DENTRIES, MAX_DENTRIES); @@ -154,13 +152,6 @@ { const pid_t pid = getpid(); - if (!set_dentries) { - if (opt_flags & OPT_FLAGS_MAXIMIZE) - opt_dentries = MAX_DENTRIES; - if (opt_flags & OPT_FLAGS_MINIMIZE) - opt_dentries = MIN_DENTRIES; - } - if (stress_temp_dir_mk(name, pid, instance) < 0) return EXIT_FAILURE; diff -Nru stress-ng-0.03.18/stress-epoll.c stress-ng-0.03.15/stress-epoll.c --- stress-ng-0.03.18/stress-epoll.c 2015-02-17 18:29:01.000000000 +0000 +++ stress-ng-0.03.15/stress-epoll.c 2015-02-09 23:44:46.000000000 +0000 @@ -24,9 +24,7 @@ */ #define _GNU_SOURCE -#include "stress-ng.h" - -#if defined(STRESS_EPOLL) +#if defined(__linux__) #include #include @@ -55,6 +53,8 @@ #include #endif +#include "stress-ng.h" + #define MAX_EPOLL_EVENTS (1024) #define MAX_SERVERS (4) diff -Nru stress-ng-0.03.18/stress-eventfd.c stress-ng-0.03.15/stress-eventfd.c --- stress-ng-0.03.18/stress-eventfd.c 2015-02-17 18:29:01.000000000 +0000 +++ stress-ng-0.03.15/stress-eventfd.c 2015-02-09 23:44:46.000000000 +0000 @@ -24,9 +24,7 @@ */ #define _GNU_SOURCE -#include "stress-ng.h" - -#if defined(STRESS_EVENTFD) +#if defined (__linux__) #include #include @@ -39,6 +37,8 @@ #include #include +#include "stress-ng.h" + /* * stress_eventfd * stress eventfd read/writes diff -Nru stress-ng-0.03.18/stress-fallocate.c stress-ng-0.03.15/stress-fallocate.c --- stress-ng-0.03.18/stress-fallocate.c 2015-02-17 18:29:01.000000000 +0000 +++ stress-ng-0.03.15/stress-fallocate.c 2015-02-09 23:44:46.000000000 +0000 @@ -24,10 +24,6 @@ */ #define _GNU_SOURCE -#include "stress-ng.h" - -#if defined(STRESS_FALLOCATE) - #include #include #include @@ -38,32 +34,9 @@ #include #include -static off_t opt_fallocate_bytes = DEFAULT_FALLOCATE_BYTES; -static bool set_fallocate_bytes = false; - -void stress_set_fallocate_bytes(const char *optarg) -{ - set_fallocate_bytes = true; - opt_fallocate_bytes = (off_t)get_uint64_byte(optarg); - check_range("fallocate-bytes", opt_fallocate_bytes, - MIN_FALLOCATE_BYTES, MAX_FALLOCATE_BYTES); -} - -#if defined(__linux__) -static const int modes[] = { -#if defined(FALLOC_FL_KEEP_SIZE) - FALLOC_FL_KEEP_SIZE, -#endif -#if defined(FALLOC_FL_KEEP_SIZE) && defined(FALLOC_FL_PUNCH_HOLE) - FALLOC_FL_KEEP_SIZE | FALLOC_FL_PUNCH_HOLE, -#endif -#if defined(FALLOC_FL_ZERO_RANGE) - FALLOC_FL_ZERO_RANGE, -#endif - 0 -}; -#endif +#include "stress-ng.h" +#if _XOPEN_SOURCE >= 600 || _POSIX_C_SOURCE >= 200112L /* * stress_fallocate * stress I/O via fallocate and ftruncate @@ -79,13 +52,6 @@ char filename[PATH_MAX]; uint64_t ftrunc_errs = 0; - if (!set_fallocate_bytes) { - if (opt_flags & OPT_FLAGS_MAXIMIZE) - opt_fallocate_bytes = MAX_FALLOCATE_BYTES; - if (opt_flags & OPT_FLAGS_MINIMIZE) - opt_fallocate_bytes = MIN_FALLOCATE_BYTES; - } - if (stress_temp_dir_mk(name, pid, instance) < 0) return EXIT_FAILURE; @@ -100,63 +66,32 @@ (void)unlink(filename); do { - (void)posix_fallocate(fd, (off_t)0, opt_fallocate_bytes); + (void)posix_fallocate(fd, (off_t)0, 4096 * 4096); if (!opt_do_run) break; - (void)fsync(fd); + fsync(fd); if (opt_flags & OPT_FLAGS_VERIFY) { struct stat buf; if (fstat(fd, &buf) < 0) pr_fail(stderr, "fstat on file failed"); - else if (buf.st_size != opt_fallocate_bytes) - pr_fail(stderr, "file size does not match size the expected file size\n"); + else if (buf.st_size != (off_t)4096 * 4096) + pr_fail(stderr, "file size does not match size the expected file size\n"); } if (ftruncate(fd, 0) < 0) ftrunc_errs++; if (!opt_do_run) break; - (void)fsync(fd); - + fsync(fd); if (opt_flags & OPT_FLAGS_VERIFY) { struct stat buf; if (fstat(fd, &buf) < 0) pr_fail(stderr, "fstat on file failed"); else if (buf.st_size != (off_t)0) - pr_fail(stderr, "file size does not match size the expected file size\n"); - } - - if (ftruncate(fd, opt_fallocate_bytes) < 0) - ftrunc_errs++; - (void)fsync(fd); - if (ftruncate(fd, 0) < 0) - ftrunc_errs++; - (void)fsync(fd); - -#if defined(__linux__) - if (SIZEOF_ARRAY(modes) > 1) { - /* - * non-portable Linux fallocate() - */ - int i; - (void)fallocate(fd, 0, (off_t)0, opt_fallocate_bytes); - if (!opt_do_run) - break; - (void)fsync(fd); - - for (i = 0; i < 64; i++) { - off_t offset = (mwc() % opt_fallocate_bytes) & ~0xfff; - int j = (mwc() >> 8) % SIZEOF_ARRAY(modes); - - (void)fallocate(fd, modes[j], offset, 64 * KB); - if (!opt_do_run) - break; - (void)fsync(fd); - } + pr_fail(stderr, "file size does not match size the expected file size\n"); } -#endif (*counter)++; } while (opt_do_run && (!max_ops || *counter < max_ops)); if (ftrunc_errs) diff -Nru stress-ng-0.03.18/stress-fifo.c stress-ng-0.03.15/stress-fifo.c --- stress-ng-0.03.18/stress-fifo.c 2015-02-17 18:29:01.000000000 +0000 +++ stress-ng-0.03.15/stress-fifo.c 2015-02-09 23:44:46.000000000 +0000 @@ -39,11 +39,9 @@ #include "stress-ng.h" static uint64_t opt_fifo_readers = DEFAULT_FIFO_READERS; -static bool set_fifo_readers = false; void stress_set_fifo_readers(const char *optarg) { - set_fifo_readers = true; opt_fifo_readers = get_uint64(optarg); check_range("fifo-readers", opt_fifo_readers, MIN_FIFO_READERS, MAX_FIFO_READERS); @@ -72,8 +70,8 @@ } /* - * stress_fifo_readers() - * read fifo + * + * */ void stress_fifo_reader(const char *name, const char *fifoname) { @@ -134,13 +132,6 @@ int ret = EXIT_FAILURE; const pid_t pid = getpid(); - if (!set_fifo_readers) { - if (opt_flags & OPT_FLAGS_MAXIMIZE) - opt_fifo_readers = MAX_FIFO_READERS; - if (opt_flags & OPT_FLAGS_MINIMIZE) - opt_fifo_readers = MIN_FIFO_READERS; - } - if (stress_temp_dir_mk(name, pid, instance) < 0) return EXIT_FAILURE; @@ -186,7 +177,7 @@ int status; (void)kill(pids[i], SIGKILL); - (void)waitpid(pids[i], &status, 0); + waitpid(pids[i], &status, 0); } } tidy: diff -Nru stress-ng-0.03.18/stress-flock.c stress-ng-0.03.15/stress-flock.c --- stress-ng-0.03.18/stress-flock.c 2015-02-17 18:29:01.000000000 +0000 +++ stress-ng-0.03.15/stress-flock.c 2015-02-09 23:44:46.000000000 +0000 @@ -33,7 +33,7 @@ #include #include #include -#if defined(_POSIX_PRIORITY_SCHEDULING) || defined(__linux__) +#if defined (_POSIX_PRIORITY_SCHEDULING) || defined (__linux__) #include #endif diff -Nru stress-ng-0.03.18/stress-fork.c stress-ng-0.03.15/stress-fork.c --- stress-ng-0.03.18/stress-fork.c 2015-02-17 18:29:01.000000000 +0000 +++ stress-ng-0.03.15/stress-fork.c 2015-02-09 23:44:46.000000000 +0000 @@ -34,11 +34,7 @@ #include "stress-ng.h" static uint64_t opt_fork_max = DEFAULT_FORKS; -static bool set_fork_max = false; -#if defined(STRESS_VFORK) static uint64_t opt_vfork_max = DEFAULT_VFORKS; -static bool set_vfork_max = false; -#endif /* * stress_set_fork_max() @@ -46,25 +42,21 @@ */ void stress_set_fork_max(const char *optarg) { - set_fork_max = true; opt_fork_max = get_uint64_byte(optarg); check_range("fork-max", opt_fork_max, MIN_FORKS, MAX_FORKS); } -#if defined(STRESS_VFORK) /* * stress_set_vfork_max() * set maximum number of vforks allowed */ void stress_set_vfork_max(const char *optarg) { - set_vfork_max = true; opt_vfork_max = get_uint64_byte(optarg); check_range("vfork-max", opt_vfork_max, MIN_VFORKS, MAX_VFORKS); } -#endif /* * stress_fork_fn() @@ -103,7 +95,7 @@ if (pids[i] > 0) { int status; /* Parent, wait for child */ - (void)waitpid(pids[i], &status, 0); + waitpid(pids[i], &status, 0); (*counter)++; } } @@ -128,19 +120,14 @@ const uint64_t max_ops, const char *name) { - if (!set_fork_max) { - if (opt_flags & OPT_FLAGS_MAXIMIZE) - opt_fork_max = MAX_FORKS; - if (opt_flags & OPT_FLAGS_MINIMIZE) - opt_fork_max = MIN_FORKS; - } - return stress_fork_fn(counter, instance, max_ops, name, fork, opt_fork_max); } -#if defined(STRESS_VFORK) +#if _BSD_SOURCE || \ + (_XOPEN_SOURCE >= 500 || _XOPEN_SOURCE && _XOPEN_SOURCE_EXTENDED) && \ + !(_POSIX_C_SOURCE >= 200809L || _XOPEN_SOURCE >= 700) /* * stress_vfork() * stress by vforking and exiting @@ -151,13 +138,6 @@ const uint64_t max_ops, const char *name) { - if (!set_vfork_max) { - if (opt_flags & OPT_FLAGS_MAXIMIZE) - opt_vfork_max = MAX_VFORKS; - if (opt_flags & OPT_FLAGS_MINIMIZE) - opt_vfork_max = MIN_VFORKS; - } - return stress_fork_fn(counter, instance, max_ops, name, vfork, opt_vfork_max); } diff -Nru stress-ng-0.03.18/stress-futex.c stress-ng-0.03.15/stress-futex.c --- stress-ng-0.03.18/stress-futex.c 2015-02-17 18:29:01.000000000 +0000 +++ stress-ng-0.03.15/stress-futex.c 2015-02-09 23:44:46.000000000 +0000 @@ -24,9 +24,7 @@ */ #define _GNU_SOURCE -#include "stress-ng.h" - -#if defined(STRESS_FUTEX) +#if defined (__linux__) #include #include @@ -43,6 +41,8 @@ #include #include +#include "stress-ng.h" + /* * futex wake() * wake n waiters on futex @@ -100,8 +100,8 @@ } while (opt_do_run && (!max_ops || *counter < max_ops)); /* Kill waiter process */ - (void)kill(pid, SIGKILL); - (void)waitpid(pid, &status, 0); + kill(pid, SIGKILL); + waitpid(pid, &status, 0); pr_dbg(stderr, "futex timeouts: %" PRIu64 "\n", *timeout); } else { diff -Nru stress-ng-0.03.18/stress-hdd.c stress-ng-0.03.15/stress-hdd.c --- stress-ng-0.03.18/stress-hdd.c 2015-02-17 18:29:01.000000000 +0000 +++ stress-ng-0.03.15/stress-hdd.c 2015-02-09 23:44:46.000000000 +0000 @@ -63,8 +63,6 @@ static uint64_t opt_hdd_bytes = DEFAULT_HDD_BYTES; static uint64_t opt_hdd_write_size = DEFAULT_HDD_WRITE_SIZE; -static bool set_hdd_bytes = false; -static bool set_hdd_write_size = false; static int opt_hdd_flags = 0; static int opt_hdd_oflags = 0; @@ -130,7 +128,6 @@ void stress_set_hdd_bytes(const char *optarg) { - set_hdd_bytes = true; opt_hdd_bytes = get_uint64_byte(optarg); check_range("hdd-bytes", opt_hdd_bytes, MIN_HDD_BYTES, MAX_HDD_BYTES); @@ -138,7 +135,6 @@ void stress_set_hdd_write_size(const char *optarg) { - set_hdd_write_size = true; opt_hdd_write_size = get_uint64_byte(optarg); check_range("hdd-write-size", opt_hdd_write_size, MIN_HDD_WRITE_SIZE, MAX_HDD_WRITE_SIZE); @@ -150,9 +146,9 @@ */ int stress_hdd_opts(char *opts) { - char *str, *token; + char *str, *token, *saveptr = NULL; - for (str = opts; (token = strtok(str, ",")) != NULL; str = NULL) { + for (str = opts; (token = strtok_r(str, ",", &saveptr)) != NULL; str = NULL) { int i; bool opt_ok = false; @@ -239,21 +235,6 @@ int flags = O_CREAT | O_RDWR | O_TRUNC | opt_hdd_oflags; int fadvise_flags = opt_hdd_flags & HDD_OPT_FADV_MASK; - - if (!set_hdd_bytes) { - if (opt_flags & OPT_FLAGS_MAXIMIZE) - opt_hdd_bytes = MAX_HDD_BYTES; - if (opt_flags & OPT_FLAGS_MINIMIZE) - opt_hdd_bytes = MIN_HDD_BYTES; - } - - if (!set_hdd_write_size) { - if (opt_flags & OPT_FLAGS_MAXIMIZE) - opt_hdd_write_size = MAX_HDD_WRITE_SIZE; - if (opt_flags & OPT_FLAGS_MINIMIZE) - opt_hdd_write_size = MIN_HDD_WRITE_SIZE; - } - if (stress_temp_dir_mk(name, pid, instance) < 0) return EXIT_FAILURE; diff -Nru stress-ng-0.03.18/stress-hsearch.c stress-ng-0.03.15/stress-hsearch.c --- stress-ng-0.03.18/stress-hsearch.c 2015-02-17 18:29:01.000000000 +0000 +++ stress-ng-0.03.15/stress-hsearch.c 2015-02-09 23:44:46.000000000 +0000 @@ -32,7 +32,6 @@ #include "stress-ng.h" static uint64_t opt_hsearch_size = DEFAULT_HSEARCH_SIZE; -static bool set_hsearch_size = false; /* * stress_set_hsearch_size() @@ -40,7 +39,6 @@ */ void stress_set_hsearch_size(const char *optarg) { - set_hsearch_size = true; opt_hsearch_size = get_uint64_byte(optarg); check_range("hsearch-size", opt_hsearch_size, MIN_TSEARCH_SIZE, MAX_TSEARCH_SIZE); @@ -56,21 +54,13 @@ const uint64_t max_ops, const char *name) { - size_t i, max = (size_t)opt_hsearch_size; + const size_t max = (size_t)opt_hsearch_size; + size_t i; int ret = EXIT_FAILURE; char **keys; (void)instance; - if (!set_hsearch_size) { - if (opt_flags & OPT_FLAGS_MAXIMIZE) - opt_hsearch_size = MAX_HSEARCH_SIZE; - if (opt_flags & OPT_FLAGS_MINIMIZE) - opt_hsearch_size = MIN_HSEARCH_SIZE; - } - - max = (size_t)opt_hsearch_size; - /* Make hash table with 25% slack */ if (!hcreate(max + (max / 4))) { pr_failed_err(name, "hcreate"); diff -Nru stress-ng-0.03.18/stress-inotify.c stress-ng-0.03.15/stress-inotify.c --- stress-ng-0.03.18/stress-inotify.c 2015-02-17 18:29:01.000000000 +0000 +++ stress-ng-0.03.15/stress-inotify.c 2015-02-09 23:44:46.000000000 +0000 @@ -26,9 +26,7 @@ */ #define _GNU_SOURCE -#include "stress-ng.h" - -#if defined(STRESS_INOTIFY) +#if defined(__linux__) #include #include @@ -46,6 +44,7 @@ #include #include +#include "stress-ng.h" #define DIR_FLAGS (S_IRWXU | S_IRWXG) #define FILE_FLAGS (S_IRUSR | S_IWUSR) diff -Nru stress-ng-0.03.18/stress-kcmp.c stress-ng-0.03.15/stress-kcmp.c --- stress-ng-0.03.18/stress-kcmp.c 2015-02-17 18:29:01.000000000 +0000 +++ stress-ng-0.03.15/stress-kcmp.c 1970-01-01 00:00:00.000000000 +0000 @@ -1,193 +0,0 @@ -/* - * Copyright (C) 2013-2015 Canonical, Ltd. - * - * 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - * This code is a complete clean re-write of the stress tool by - * Colin Ian King and attempts to be - * backwardly compatible with the stress tool by Amos Waterland - * but has more stress tests and more - * functionality. - * - */ -#define _GNU_SOURCE - -#include "stress-ng.h" - -#if defined(STRESS_KCMP) - -#include -#include -#include -#include -#include -#include -#include -#include - -/* Urgh, should be from linux/kcmp.h */ -enum { - KCMP_FILE, - KCMP_VM, - KCMP_FILES, - KCMP_FS, - KCMP_SIGHAND, - KCMP_IO, - KCMP_SYSVSEM, - KCMP_TYPES, -}; - -/* - * sys_kcmp() - * kcmp syscall - */ -static inline long sys_kcmp(int pid1, int pid2, int type, int fd1, int fd2) -{ -#if defined(__NR_kcmp) - errno = 0; - return syscall(__NR_kcmp, pid1, pid2, type, fd1, fd2); -#else - (void)pid1; - (void)pid2; - (void)type; - (void)fd1; - (void)fd2; - errno = ENOSYS; - return -1; -#endif -} - -#define KCMP(pid1, pid2, type, idx1, idx2) \ -{ \ - int rc = sys_kcmp(pid1, pid2, type, idx1, idx2);\ - \ - if (rc < 0) \ - pr_failed_err(name, "kcmp: " # type); \ -} - -#define KCMP_VERIFY(pid1, pid2, type, idx1, idx2, res) \ -{ \ - int rc = sys_kcmp(pid1, pid2, type, idx1, idx2);\ - \ - if (rc != res) { \ - if (rc < 0) { \ - pr_failed_err(name, "kcmp: " # type);\ - } else { \ - pr_fail(stderr, "kcmp " # type \ - " returned %d, expected: %d\n", \ - rc, ret); \ - } \ - } \ -} - -/* - * stress_kcmp - * stress sys_kcmp - */ -int stress_kcmp( - uint64_t *const counter, - const uint32_t instance, - const uint64_t max_ops, - const char *name) -{ - pid_t pid1; - int fd1; - int ret = EXIT_SUCCESS; - - (void)instance; - - if ((fd1 = open("/dev/null", O_WRONLY)) < 0) { - pr_failed_err(name, "open"); - return EXIT_FAILURE; - } - - pid1 = fork(); - if (pid1 < 0) { - pr_failed_dbg(name, "fork"); - (void)close(fd1); - return EXIT_FAILURE; - } else if (pid1 == 0) { - /* Child */ - for (;;) - pause(); - - /* will never get here */ - (void)close(fd1); - exit(EXIT_SUCCESS); - } else { - /* Parent */ - int fd2, status, pid2; - - pid2 = getpid(); - if ((fd2 = open("/dev/null", O_WRONLY)) < 0) { - pr_failed_err(name, "open"); - ret = EXIT_FAILURE; - goto reap; - } - - do { - KCMP(pid1, pid2, KCMP_FILE, fd1, fd2); - KCMP(pid1, pid1, KCMP_FILE, fd1, fd1); - KCMP(pid2, pid2, KCMP_FILE, fd1, fd1); - KCMP(pid2, pid2, KCMP_FILE, fd2, fd2); - - KCMP(pid1, pid2, KCMP_FILES, 0, 0); - KCMP(pid1, pid1, KCMP_FILES, 0, 0); - KCMP(pid2, pid2, KCMP_FILES, 0, 0); - - KCMP(pid1, pid2, KCMP_FS, 0, 0); - KCMP(pid1, pid1, KCMP_FS, 0, 0); - KCMP(pid2, pid2, KCMP_FS, 0, 0); - - KCMP(pid1, pid2, KCMP_IO, 0, 0); - KCMP(pid1, pid1, KCMP_IO, 0, 0); - KCMP(pid2, pid2, KCMP_IO, 0, 0); - - KCMP(pid1, pid2, KCMP_SIGHAND, 0, 0); - KCMP(pid1, pid1, KCMP_SIGHAND, 0, 0); - KCMP(pid2, pid2, KCMP_SIGHAND, 0, 0); - - KCMP(pid1, pid2, KCMP_SYSVSEM, 0, 0); - KCMP(pid1, pid1, KCMP_SYSVSEM, 0, 0); - KCMP(pid2, pid2, KCMP_SYSVSEM, 0, 0); - - KCMP(pid1, pid2, KCMP_VM, 0, 0); - KCMP(pid1, pid1, KCMP_VM, 0, 0); - KCMP(pid2, pid2, KCMP_VM, 0, 0); - - /* Same simple checks */ - if (opt_flags & OPT_FLAGS_VERIFY) { - KCMP_VERIFY(pid1, pid1, KCMP_FILE, fd1, fd1, 0); - KCMP_VERIFY(pid1, pid1, KCMP_FILES, 0, 0, 0); - KCMP_VERIFY(pid1, pid1, KCMP_FS, 0, 0, 0); - KCMP_VERIFY(pid1, pid1, KCMP_IO, 0, 0, 0); - KCMP_VERIFY(pid1, pid1, KCMP_SIGHAND, 0, 0, 0); - KCMP_VERIFY(pid1, pid1, KCMP_SYSVSEM, 0, 0, 0); - KCMP_VERIFY(pid1, pid1, KCMP_VM, 0, 0, 0); - KCMP_VERIFY(pid1, pid2, KCMP_SYSVSEM, 0, 0, 0); - } - (*counter)++; - } while (opt_do_run && (!max_ops || *counter < max_ops)); -reap: - if (fd2 >= 0) - (void)close(fd2); - (void)kill(pid1, SIGKILL); - (void)waitpid(pid1, &status, 0); - (void)close(fd1); - } - return ret; -} - -#endif diff -Nru stress-ng-0.03.18/stress-lease.c stress-ng-0.03.15/stress-lease.c --- stress-ng-0.03.18/stress-lease.c 2015-02-17 18:29:01.000000000 +0000 +++ stress-ng-0.03.15/stress-lease.c 2015-02-09 23:44:46.000000000 +0000 @@ -24,10 +24,6 @@ */ #define _GNU_SOURCE -#include "stress-ng.h" - -#if defined(STRESS_LEASE) - #include #include #include @@ -43,18 +39,21 @@ #include #endif +#include "stress-ng.h" + +#if defined(F_SETLEASE) && defined(F_WRLCK) && defined(F_UNLCK) + static uint64_t lease_sigio; static uint64_t opt_lease_breakers = DEFAULT_LEASE_BREAKERS; -static bool set_lease_breakers = false; void stress_set_lease_breakers(const char *optarg) { - set_lease_breakers = true; opt_lease_breakers = get_uint64(optarg); check_range("lease-breakers", opt_lease_breakers, MIN_LEASE_BREAKERS, MAX_LEASE_BREAKERS); } + /* * stress_lease_handler() * lease signal handler @@ -78,13 +77,6 @@ { pid_t pid; - if (!set_lease_breakers) { - if (opt_flags & OPT_FLAGS_MAXIMIZE) - opt_lease_breakers = MAX_LEASE_BREAKERS; - if (opt_flags & OPT_FLAGS_MINIMIZE) - opt_lease_breakers = MIN_LEASE_BREAKERS; - } - pid = fork(); if (pid < 0) { return -1; @@ -122,7 +114,7 @@ char filename[PATH_MAX]; struct sigaction new_action; int fd, status; - pid_t l_pids[MAX_LEASE_BREAKERS]; + pid_t l_pids[opt_lease_breakers]; pid_t pid = getpid(); uint64_t i; @@ -189,8 +181,8 @@ reap: for (i = 0; i < opt_lease_breakers; i++) { if (l_pids[i]) { - (void)kill(l_pids[i], SIGKILL); - (void)waitpid(l_pids[i], &status, 0); + kill(l_pids[i], SIGKILL); + waitpid(l_pids[i], &status, 0); } } diff -Nru stress-ng-0.03.18/stress-lockf.c stress-ng-0.03.15/stress-lockf.c --- stress-ng-0.03.18/stress-lockf.c 2015-02-17 18:29:01.000000000 +0000 +++ stress-ng-0.03.15/stress-lockf.c 2015-02-09 23:44:46.000000000 +0000 @@ -24,10 +24,6 @@ */ #define _GNU_SOURCE -#include "stress-ng.h" - -#if defined(STRESS_LOCKF) - #include #include #include @@ -38,6 +34,11 @@ #include #include +#include "stress-ng.h" + +#if _BSD_SOURCE || _SVID_SOURCE || _XOPEN_SOURCE >= 500 || \ + (_XOPEN_SOURCE && _XOPEN_SOURCE_EXTENDED) + /* * stress_lockf * stress file locking via lockf() diff -Nru stress-ng-0.03.18/stress-longjmp.c stress-ng-0.03.15/stress-longjmp.c --- stress-ng-0.03.18/stress-longjmp.c 2015-02-17 18:29:01.000000000 +0000 +++ stress-ng-0.03.15/stress-longjmp.c 1970-01-01 00:00:00.000000000 +0000 @@ -1,66 +0,0 @@ -/* - * Copyright (C) 2013-2015 Canonical, Ltd. - * - * 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - * This code is a complete clean re-write of the stress tool by - * Colin Ian King and attempts to be - * backwardly compatible with the stress tool by Amos Waterland - * but has more stress tests and more - * functionality. - * - */ -#define _GNU_SOURCE - -#include "stress-ng.h" - -#include -#include -#include -#include -#include -#include - -/* - * stress_jmp() - * stress system by setjmp/longjmp calls - */ -int stress_longjmp( - uint64_t *const counter, - const uint32_t instance, - const uint64_t max_ops, - const char *name) -{ - int ret; - static int c = 0; - static jmp_buf buf; - - (void)instance; - (void)name; - - ret = setjmp(buf); - - if (ret) { - c++; - if (c >= 1000) { - (*counter)++; - c = 0; - } - } - if (opt_do_run && (!max_ops || *counter < max_ops)) - longjmp(buf, 1); - - return EXIT_SUCCESS; -} diff -Nru stress-ng-0.03.18/stress-lsearch.c stress-ng-0.03.15/stress-lsearch.c --- stress-ng-0.03.18/stress-lsearch.c 2015-02-17 18:29:01.000000000 +0000 +++ stress-ng-0.03.15/stress-lsearch.c 2015-02-09 23:44:46.000000000 +0000 @@ -32,7 +32,6 @@ #include "stress-ng.h" static uint64_t opt_lsearch_size = DEFAULT_LSEARCH_SIZE; -static bool set_lsearch_size = false; /* * stress_set_lsearch_size() @@ -40,7 +39,6 @@ */ void stress_set_lsearch_size(const char *optarg) { - set_lsearch_size = true; opt_lsearch_size = get_uint64_byte(optarg); check_range("lsearch-size", opt_lsearch_size, MIN_TSEARCH_SIZE, MAX_TSEARCH_SIZE); @@ -66,18 +64,10 @@ const char *name) { int32_t *data, *root; - size_t i, max; + const size_t max = (size_t)opt_lsearch_size; + size_t i; (void)instance; - - if (!set_lsearch_size) { - if (opt_flags & OPT_FLAGS_MAXIMIZE) - opt_lsearch_size = MAX_LSEARCH_SIZE; - if (opt_flags & OPT_FLAGS_MINIMIZE) - opt_lsearch_size = MIN_LSEARCH_SIZE; - } - max = (size_t)opt_lsearch_size; - if ((data = calloc(max, sizeof(int32_t))) == NULL) { pr_failed_dbg(name, "malloc"); return EXIT_FAILURE; @@ -91,8 +81,8 @@ do { size_t n = 0; - /* Step #1, populate with data */ - for (i = 0; opt_do_run && i < max; i++) { + /* Step #1, populate tree */ + for (i = 0; i < max; i++) { data[i] = ((mwc() & 0xfff) << 20) ^ i; (void)lsearch(&data[i], root, &n, sizeof(int32_t), cmp); } diff -Nru stress-ng-0.03.18/stress-malloc.c stress-ng-0.03.15/stress-malloc.c --- stress-ng-0.03.18/stress-malloc.c 2015-02-17 18:29:01.000000000 +0000 +++ stress-ng-0.03.15/stress-malloc.c 2015-02-09 23:44:46.000000000 +0000 @@ -24,8 +24,6 @@ */ #define _GNU_SOURCE -#include "stress-ng.h" - #include #include #include @@ -37,47 +35,26 @@ #include #include #include -#if defined(STRESS_MALLOPT) -#include -#endif -static size_t opt_malloc_bytes = DEFAULT_MALLOC_BYTES; -static bool set_malloc_bytes = false; +#include "stress-ng.h" +static size_t opt_malloc_bytes = DEFAULT_MALLOC_BYTES; static size_t opt_malloc_max = DEFAULT_MALLOC_MAX; -static bool set_malloc_max = false; - -#if defined(STRESS_MALLOPT) -static int opt_malloc_threshold = DEFAULT_MALLOC_THRESHOLD; -static bool set_malloc_threshold = false; -#endif void stress_set_malloc_bytes(const char *optarg) { - set_malloc_bytes = true; opt_malloc_bytes = (size_t)get_uint64_byte(optarg); check_range("malloc-bytes", opt_malloc_bytes, - MIN_MALLOC_BYTES, MAX_MALLOC_BYTES); + MIN_MALLOC_BYTES, MAX_MALLOC_BYTES); } void stress_set_malloc_max(const char *optarg) { - set_malloc_max = true; opt_malloc_max = (size_t)get_uint64_byte(optarg); check_range("malloc-max", opt_malloc_max, - MIN_MALLOC_MAX, MAX_MALLOC_MAX); + MIN_MALLOC_MAX, MAX_MALLOC_MAX); } -#if defined(STRESS_MALLOPT) -void stress_set_malloc_threshold(const char *optarg) -{ - set_malloc_threshold = true; - opt_malloc_threshold = (size_t)get_uint64_byte(optarg); - check_range("malloc-threshold", opt_malloc_threshold, - MIN_MALLOC_THRESHOLD, MAX_MALLOC_THRESHOLD); -} -#endif - /* * stress_alloc_size() * get a new allocation size, ensuring @@ -104,25 +81,6 @@ pid_t pid; uint32_t restarts = 0, nomems = 0; - if (!set_malloc_bytes) { - if (opt_flags & OPT_FLAGS_MAXIMIZE) - opt_malloc_bytes = MAX_MALLOC_BYTES; - if (opt_flags & OPT_FLAGS_MINIMIZE) - opt_malloc_bytes = MIN_MALLOC_BYTES; - } - - if (!set_malloc_max) { - if (opt_flags & OPT_FLAGS_MAXIMIZE) - opt_malloc_max = MAX_MALLOC_MAX; - if (opt_flags & OPT_FLAGS_MINIMIZE) - opt_malloc_max = MIN_MALLOC_MAX; - } - -#if defined(STRESS_MALLOPT) - if (set_malloc_threshold) - mallopt(M_MMAP_THRESHOLD, opt_malloc_threshold); -#endif - again: pid = fork(); if (pid < 0) { @@ -138,7 +96,7 @@ name, errno, strerror(errno)); (void)kill(pid, SIGTERM); (void)kill(pid, SIGKILL); - (void)waitpid(pid, &status, 0); + waitpid(pid, &status, 0); } else if (WIFSIGNALED(status)) { pr_dbg(stderr, "%s: child died: %d (instance %d)\n", name, WTERMSIG(status), instance); diff -Nru stress-ng-0.03.18/stress-matrix.c stress-ng-0.03.15/stress-matrix.c --- stress-ng-0.03.18/stress-matrix.c 2015-02-18 16:06:42.000000000 +0000 +++ stress-ng-0.03.15/stress-matrix.c 1970-01-01 00:00:00.000000000 +0000 @@ -1,356 +0,0 @@ -/* - * Copyright (C) 2013-2015 Canonical, Ltd. - * - * 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - * This code is a complete clean re-write of the stress tool by - * Colin Ian King and attempts to be - * backwardly compatible with the stress tool by Amos Waterland - * but has more stress tests and more - * functionality. - * - */ -#define _GNU_SOURCE - -#include -#include -#include -#include -#include -#include "stress-ng.h" - -#define MATRIX_TYPE float - -/* - * the CPU stress test has different classes of cpu stressor - */ -typedef void (*stress_matrix_func)( - const size_t n, - MATRIX_TYPE a[n][n], - MATRIX_TYPE b[n][n], - MATRIX_TYPE r[n][n]); - -typedef struct { - const char *name; /* human readable form of stressor */ - const stress_matrix_func func; /* the stressor function */ -} stress_matrix_stressor_info_t; - -static stress_matrix_stressor_info_t *opt_matrix_stressor; -static stress_matrix_stressor_info_t matrix_methods[]; -static size_t opt_matrix_size = 128; -static bool set_matrix_size = false; - -void stress_set_matrix_size(const char *optarg) -{ - uint64_t size; - - set_matrix_size = true; - size = get_uint64_byte(optarg); - check_range("matrix-size", size, - MIN_MATRIX_SIZE, MAX_MATRIX_SIZE); - opt_matrix_size = (size_t)size; -} - -/* - * stress_matrix_prod(void) - * matrix product - */ -static void stress_matrix_prod( - const size_t n, - MATRIX_TYPE a[n][n], - MATRIX_TYPE b[n][n], - MATRIX_TYPE r[n][n]) -{ - size_t i, j, k; - - for (i = 0; i < n; i++) { - for (j = 0; j < n; j++) { - for (k = 0; k < n; k++) { - r[i][j] += a[i][k] * b[k][j]; - } - if (!opt_do_run) - return; - } - } -} - -/* - * stress_matrix_add(void) - * matrix addition - */ -static void stress_matrix_add( - const size_t n, - MATRIX_TYPE a[n][n], - MATRIX_TYPE b[n][n], - MATRIX_TYPE r[n][n]) -{ - size_t i, j; - - for (i = 0; i < n; i++) { - for (j = 0; j < n; j++) { - r[i][j] = a[i][j] + b[i][j]; - } - if (!opt_do_run) - return; - } -} - -/* - * stress_matrix_sub(void) - * matrix subtraction - */ -static void stress_matrix_sub( - const size_t n, - MATRIX_TYPE a[n][n], - MATRIX_TYPE b[n][n], - MATRIX_TYPE r[n][n]) -{ - size_t i, j; - - for (i = 0; i < n; i++) { - for (j = 0; j < n; j++) { - r[i][j] = a[i][j] - b[i][j]; - } - if (!opt_do_run) - return; - } -} - -/* - * stress_matrix_trans(void) - * matrix transpose - */ -static void stress_matrix_trans( - const size_t n, - MATRIX_TYPE a[n][n], - MATRIX_TYPE b[n][n], /* Ignored */ - MATRIX_TYPE r[n][n]) -{ - size_t i, j; - - (void)b; - - for (i = 0; i < n; i++) { - for (j = 0; j < n; j++) { - r[i][j] = a[j][i]; - } - if (!opt_do_run) - return; - } -} - -/* - * stress_matrix_mult(void) - * matrix scalar multiply - */ -static void stress_matrix_mult( - const size_t n, - MATRIX_TYPE a[n][n], - MATRIX_TYPE b[n][n], - MATRIX_TYPE r[n][n]) -{ - size_t i, j; - - (void)b; - MATRIX_TYPE v = b[0][0]; - - for (i = 0; i < n; i++) { - for (j = 0; j < n; j++) { - r[i][j] = v * a[i][j]; - } - if (!opt_do_run) - return; - } -} - -/* - * stress_matrix_div(void) - * matrix scalar divide - */ -static void stress_matrix_div( - const size_t n, - MATRIX_TYPE a[n][n], - MATRIX_TYPE b[n][n], - MATRIX_TYPE r[n][n]) -{ - size_t i, j; - - (void)b; - MATRIX_TYPE v = b[0][0]; - - for (i = 0; i < n; i++) { - for (j = 0; j < n; j++) { - r[i][j] = a[i][j] / v; - } - if (!opt_do_run) - return; - } -} - -/* - * stress_matrix_hadamard(void) - * matrix hadamard product - * (A o B)ij = AijBij - */ -static void stress_matrix_hadamard( - const size_t n, - MATRIX_TYPE a[n][n], - MATRIX_TYPE b[n][n], - MATRIX_TYPE r[n][n]) -{ - size_t i, j; - - for (i = 0; i < n; i++) { - for (j = 0; j < n; j++) { - r[i][j] = a[i][j] * b[i][j]; - } - if (!opt_do_run) - return; - } -} - -/* - * stress_matrix_frobenius(void) - * matrix frobenius product - * A : B = Sum(AijBij) - */ -static void stress_matrix_frobenius( - const size_t n, - MATRIX_TYPE a[n][n], - MATRIX_TYPE b[n][n], - MATRIX_TYPE r[n][n]) -{ - size_t i, j; - MATRIX_TYPE sum = 0.0; - - (void)r; - - for (i = 0; i < n; i++) { - for (j = 0; j < n; j++) { - sum += a[i][j] * b[i][j]; - } - if (!opt_do_run) - return; - } - double_put(sum); -} - -/* - * stress_matrix_all() - * iterate over all cpu stressors - */ -static void stress_matrix_all( - const size_t n, - MATRIX_TYPE a[n][n], - MATRIX_TYPE b[n][n], - MATRIX_TYPE r[n][n]) -{ - static int i = 1; /* Skip over stress_matrix_all */ - - matrix_methods[i++].func(n, a, b, r); - if (!matrix_methods[i].func) - i = 1; -} - -/* - * Table of cpu stress methods - */ -static stress_matrix_stressor_info_t matrix_methods[] = { - { "all", stress_matrix_all }, /* Special "alli" test */ - - { "add", stress_matrix_add }, - { "div", stress_matrix_div }, - { "frobenius", stress_matrix_frobenius }, - { "hadamard", stress_matrix_hadamard }, - { "mult", stress_matrix_mult }, - { "prod", stress_matrix_prod }, - { "sub", stress_matrix_sub }, - { "trans", stress_matrix_trans }, - { NULL, NULL } -}; - -/* - * stress_set_matrix_method() - * set the default matrix stress method - */ -int stress_set_matrix_method(const char *name) -{ - stress_matrix_stressor_info_t *info = matrix_methods; - - for (info = matrix_methods; info->func; info++) { - if (!strcmp(info->name, name)) { - opt_matrix_stressor = info; - return 0; - } - } - - fprintf(stderr, "matrix-method must be one of:"); - for (info = matrix_methods; info->func; info++) { - fprintf(stderr, " %s", info->name); - } - fprintf(stderr, "\n"); - - return -1; -} - -/* - * stress_matrix() - * stress CPU by doing floating point math ops - */ -int stress_matrix( - uint64_t *const counter, - const uint32_t instance, - const uint64_t max_ops, - const char *name) -{ - stress_matrix_func func = opt_matrix_stressor->func; - size_t i, j, n; - const MATRIX_TYPE v = 1 / (MATRIX_TYPE)((uint32_t)~0); - - (void)instance; - (void)name; - - if (!set_matrix_size) { - if (opt_flags & OPT_FLAGS_MAXIMIZE) - opt_matrix_size = MAX_MATRIX_SIZE; - if (opt_flags & OPT_FLAGS_MINIMIZE) - opt_matrix_size = MIN_MATRIX_SIZE; - } - n = opt_matrix_size; - - { - MATRIX_TYPE a[n][n], b[n][n], r[n][n]; - /* - * Initialise matrices - */ - for (i = 0; i < n; i++) { - for (j = 0; j < n; j++) { - a[i][j] = (MATRIX_TYPE)mwc() * v; - b[i][j] = (MATRIX_TYPE)mwc() * v; - r[i][j] = 0.0; - } - } - - /* - * Normal use case, 100% load, simple spinning on CPU - */ - do { - (void)func(n, a, b, r); - (*counter)++; - } while (opt_do_run && (!max_ops || *counter < max_ops)); - } - - return EXIT_SUCCESS; -} diff -Nru stress-ng-0.03.18/stress-mincore.c stress-ng-0.03.15/stress-mincore.c --- stress-ng-0.03.18/stress-mincore.c 2015-02-17 18:29:01.000000000 +0000 +++ stress-ng-0.03.15/stress-mincore.c 2015-02-09 23:44:46.000000000 +0000 @@ -24,10 +24,6 @@ */ #define _GNU_SOURCE -#include "stress-ng.h" - -#if defined(STRESS_MINCORE) - #include #include #include @@ -40,6 +36,10 @@ #include #include +#include "stress-ng.h" + +#if (_BSD_SOURCE || _SVID_SOURCE) && !defined(__gnu_hurd__) + #define VEC_MAX_SIZE (64) /* diff -Nru stress-ng-0.03.18/stress-mmap.c stress-ng-0.03.15/stress-mmap.c --- stress-ng-0.03.18/stress-mmap.c 2015-02-17 18:29:01.000000000 +0000 +++ stress-ng-0.03.15/stress-mmap.c 2015-02-09 23:44:46.000000000 +0000 @@ -37,11 +37,9 @@ #include "stress-ng.h" static size_t opt_mmap_bytes = DEFAULT_MMAP_BYTES; -static bool set_mmap_bytes = false; void stress_set_mmap_bytes(const char *optarg) { - set_mmap_bytes = true; opt_mmap_bytes = (size_t)get_uint64_byte(optarg); check_range("mmap-bytes", opt_mmap_bytes, MIN_MMAP_BYTES, MAX_MMAP_BYTES); @@ -116,7 +114,8 @@ { uint8_t *buf = NULL; const size_t page_size = stress_get_pagesize(); - size_t sz, pages4k; + const size_t sz = opt_mmap_bytes & ~(page_size - 1); + const size_t pages4k = sz / page_size; #if !defined(__gnu_hurd__) const int ms_flags = (opt_flags & OPT_FLAGS_MMAP_ASYNC) ? MS_ASYNC : MS_SYNC; @@ -125,19 +124,10 @@ int fd = -1, flags = MAP_PRIVATE | MAP_ANONYMOUS; char filename[PATH_MAX]; - (void)instance; #ifdef MAP_POPULATE flags |= MAP_POPULATE; #endif - - if (!set_mmap_bytes) { - if (opt_flags & OPT_FLAGS_MAXIMIZE) - opt_mmap_bytes = MAX_MMAP_BYTES; - if (opt_flags & OPT_FLAGS_MINIMIZE) - opt_mmap_bytes = MIN_MMAP_BYTES; - } - sz = opt_mmap_bytes & ~(page_size - 1); - pages4k = sz / page_size; + (void)instance; /* Make sure this is killable by OOM killer */ set_oom_adjustment(name, true); diff -Nru stress-ng-0.03.18/stress-mq.c stress-ng-0.03.15/stress-mq.c --- stress-ng-0.03.18/stress-mq.c 2015-02-17 18:29:01.000000000 +0000 +++ stress-ng-0.03.15/stress-mq.c 2015-02-09 23:44:46.000000000 +0000 @@ -24,9 +24,7 @@ */ #define _GNU_SOURCE -#include "stress-ng.h" - -#if defined(STRESS_MQ) +#if defined(__linux__) #include #include @@ -43,25 +41,26 @@ #include #include +#include "stress-ng.h" + typedef struct { uint64_t value; bool stop; } msg_t; static int opt_mq_size = DEFAULT_MQ_SIZE; -static bool set_mq_size = false; void stress_set_mq_size(const char *optarg) { uint64_t sz; - set_mq_size = true; sz = get_uint64_byte(optarg); - opt_mq_size = (int)sz; - check_range("mq-size", sz, + check_range("mq-size", opt_mq_size, MIN_MQ_SIZE, MAX_MQ_SIZE); + opt_mq_size = (int)sz; } + /* * stress_mq * stress POSIX message queues @@ -74,21 +73,13 @@ { pid_t pid = getpid(); mqd_t mq = -1; - int sz, max_sz; + int sz = opt_mq_size, max_sz; FILE *fp; struct mq_attr attr; char mq_name[64]; (void)instance; - if (!set_mq_size) { - if (opt_flags & OPT_FLAGS_MAXIMIZE) - opt_mq_size = MAX_MQ_SIZE; - if (opt_flags & OPT_FLAGS_MINIMIZE) - opt_mq_size = MIN_MQ_SIZE; - } - sz = opt_mq_size; - snprintf(mq_name, sizeof(mq_name), "/%s-%i-%" PRIu32, name, pid, instance); if ((fp = fopen("/proc/sys/fs/mqueue/msg_default", "r")) != NULL) { diff -Nru stress-ng-0.03.18/stress-mremap.c stress-ng-0.03.15/stress-mremap.c --- stress-ng-0.03.18/stress-mremap.c 2015-02-17 18:29:01.000000000 +0000 +++ stress-ng-0.03.15/stress-mremap.c 2015-02-09 23:44:46.000000000 +0000 @@ -24,9 +24,7 @@ */ #define _GNU_SOURCE -#include "stress-ng.h" - -#if defined(STRESS_MREMAP) +#if defined(__linux__) #include #include @@ -39,15 +37,15 @@ #include #include -static size_t opt_mremap_bytes = DEFAULT_MREMAP_BYTES; -static bool set_mremap_bytes = false; +#include "stress-ng.h" + +static size_t opt_mremap_bytes = DEFAULT_MMAP_BYTES; void stress_set_mremap_bytes(const char *optarg) { - set_mremap_bytes = true; opt_mremap_bytes = (size_t)get_uint64_byte(optarg); check_range("mmap-bytes", opt_mremap_bytes, - MIN_MREMAP_BYTES, MAX_MREMAP_BYTES); + MIN_MMAP_BYTES, MAX_MMAP_BYTES); } @@ -141,20 +139,14 @@ { uint8_t *buf = NULL; const size_t page_size = stress_get_pagesize(); - size_t sz, new_sz, old_sz; + const size_t sz = opt_mremap_bytes & ~(page_size - 1); + size_t new_sz = sz, old_sz; int flags = MAP_PRIVATE | MAP_ANONYMOUS; - (void)instance; #ifdef MAP_POPULATE flags |= MAP_POPULATE; #endif - if (!set_mremap_bytes) { - if (opt_flags & OPT_FLAGS_MAXIMIZE) - opt_mremap_bytes = MAX_MREMAP_BYTES; - if (opt_flags & OPT_FLAGS_MINIMIZE) - opt_mremap_bytes = MIN_MREMAP_BYTES; - } - new_sz = sz = opt_mremap_bytes & ~(page_size - 1); + (void)instance; /* Make sure this is killable by OOM killer */ set_oom_adjustment(name, true); diff -Nru stress-ng-0.03.18/stress-msg.c stress-ng-0.03.15/stress-msg.c --- stress-ng-0.03.18/stress-msg.c 2015-02-17 18:29:01.000000000 +0000 +++ stress-ng-0.03.15/stress-msg.c 2015-02-09 23:44:46.000000000 +0000 @@ -24,10 +24,6 @@ */ #define _GNU_SOURCE -#include "stress-ng.h" - -#if defined(STRESS_MSG) - #include #include #include @@ -42,6 +38,10 @@ #include #include +#include "stress-ng.h" + +#if !defined(__gnu_hurd__) + #define MAX_SIZE (8) #define MSG_STOP "STOPMSG" diff -Nru stress-ng-0.03.18/stress-ng.1 stress-ng-0.03.15/stress-ng.1 --- stress-ng-0.03.18/stress-ng.1 2015-02-17 18:29:01.000000000 +0000 +++ stress-ng-0.03.15/stress-ng.1 2015-02-09 23:44:46.000000000 +0000 @@ -69,9 +69,6 @@ .B \-\-affinity\-rand switch CPU affinity randomly rather than the default of sequentially. .TP -.B \-\-aggressive -enables more file, cache and memory aggressive options. This may slow tests down, increase latencies and reduce the number of bogo ops as well as changing the balance of user time vs system time used depending on the type of stressor being used. -.TP .B \-\-aio N start N processes that issue multiple small asynchronous I/O writes and reads on a relatively small temporary file. This will just hit the file system cache and soak up a lot of user and kernel time @@ -132,9 +129,6 @@ .B \-\-cache\-ops N stop cache thrash processes after N bogo cache thrash operations. .TP -.B \-\-cache\-prefetch -force read prefetch on next read address on architectures that support prefetching. -.TP .B \-\-chmod N start N processes that change the file mode bits via chmod(2) and fchmod(2) on the same file. The greater the value for N then the more contention on the single file. The stressor will work through all the combination of mode bits. .TP @@ -434,10 +428,7 @@ stop eventfd workers after N bogo operations. .TP .B \-F N, \-\-fallocate N -start N processes continually fallocating (preallocating file space) and ftuncating (file truncating) temporary files. If the file is larger than the free space, fallocate will produce an ENOSPC error which is ignored by this stressor. -.TP -.B \-\-fallocate\-bytes N -allocated file size, the default is 1 GB. One can specify the size in units of Bytes, KBytes, MBytes and GBytes using the suffix b, k, m or g. +start N processes continually fallocating (preallocating file space) and ftuncating (file truncating) temporary files. .TP .B \-\-fallocate\-ops N stop fallocate stress processes after N bogo fallocate operations. @@ -594,12 +585,6 @@ .B \-\-ionice\-level level specify ionice level (only on Linux). For idle, 0 is the only possible option. For besteffort or realtime values 0 (hightest priority) to 7 (lowest priority). See ionice(1) for more details. .TP -.B \-\-kcmp N -start N processes that use kcmp(2) to compare parent and child processes to determine if they share kernel resources (Linux only). -.TP -.B \-\-kcmp\-ops N -stop kcmp stressors after N bogo kcmp operations. -.TP .B \-k, \-\-keep\-name by default, stress-ng will attempt to change the name of the stress processes according to their functionality; this option disables this and keeps the process names to be the name of the parent process, that is, stress-ng. .TP @@ -633,21 +618,12 @@ .B \-\-lockf\-nonblock instead of using blocking F_LOCK lockf(3) commands, use non-blocking F_TLOCK commands and re-try if the lock failed. This creates extra system call overhead and CPU utilisation as the number of lockf stressors increases and hence increases locking contention. .TP -.B \-\-longjmp N -start N processes that exercise setjmp(3)/longjmp(3) by rapid looping on longjmp calls. -.TP -.B \-\-longjmp-ops N -stop longjmp stress processes after N bogo longjmp operations (1 bogo op is 1000 longjmp calls). -.TP .B \-\-lsearch N start N processes that linear search a unsorted array of 32 bit integers using lsearch(3). By default, there are 8192 elements in the array. This is a useful method to exercise sequential access of memory and processor cache. .TP .B \-\-lsearch\-ops N stop the lsearch processes after N bogo lsearch operations are completed. .TP -.B \-\-lsearch\-size N -specify the size (number of 32 bit integers) in the array to lsearch. Size can be from 1K to 4M. -.TP .B \-\-malloc N start N processes continuously calling malloc(3), calloc(3), realloc(3) and free(3). By default, up to 65536 allocations can be active at any point, but this can be altered with the \-\-malloc\-max option. Allocation, reallocation and freeing are chosen at random; 50% of the time memory is allocation (via malloc, calloc or realloc) and 50% of the time allocations are free'd. Allocation sizes are also random, with the maximum allocation size controlled by the \-\-malloc\-bytes option, the default size being 64K. The stressor is re-started if it is killed by the out of mememory (OOM) killer. .TP @@ -660,56 +636,8 @@ .B \-\-malloc\-ops N stop after N malloc bogo operations. One bogo operations relates to a successfull malloc(3), calloc(3) or realloc(3). .TP -.B \-\-malloc\-thresh N -specify the threshold where malloc uses mmap(2) instead of sbrk(2) to allocate more memory. This is only available on systems that provide the GNU C mallopt(3) tuning function. -.TP -.B \-\-matrix N -start N processes that perform various matrix operations on floating point values. By default, this will exercise all the matrix stress methods one by one. One can specify a specific matrix stress method with the \-\-matrix\-method option. -.TP -.B \-\-matrix\-ops N -stop matrix stress processes after N bogo operations. -.TP -.B \-\-matrix\-method method -specify a matrix stress method. Available matrix stress methods are described as follows: -.TS -expand; -lB2 lBw(\n[SZ]n) -l l. -Method Description -all T{ -iterate over all the below matrix stress methods -T} -add T{ -add two N x N matrices -T} -div T{ -divide an N x N matrix by a scalar -T} -hadamard T{ -Hadamard product of two N x N matrices -T} -frobenius T{ -Frobenius product of two N x N matrices -T} -mult T{ -multiply an N x N matrix by a scalar -T} -prod T{ -product of two N x N matrices -T} -sub T{ -subtract one N x N matrix from another N x N matrix -T} -trans T{ -transpose an N x N matrix -T} -.TE -.TP -.B \-\-matrix\-size N -specify the N x N size of the matrices. Smaller values result in a floating point compute throughput bound stressor, where as large values result in a cache and/or memory bandwidth bound stressor. -.TP -.B \-\-maximize -overrides the default stressor settings and instead sets these to the maximum settings allowed. These defaults can always be overridden by the per stressor settings options if required. +.B \-\-lsearch\-size N +specify the size (number of 32 bit integers) in the array to lsearch. Size can be from 1K to 4M. .TP .B \-\-metrics output number of bogo operations in total performed by the stress processes. Note that these are not a reliable metric of performance or throughput and have not @@ -780,9 +708,6 @@ .B \-\-mincore\-random instead of walking through pages sequentially, select pages at random. The chosen address is iterated over by shifting it right one place and checked by mincore until the address is less or equal to the page size. .TP -.B \-\-minimize -overrides the default stressor settings and instead sets these to the minimum settings allowed. These defaults can always be overridden by the per stressor settings options if required. -.TP .B \-\-mmap N start N processes continuously calling mmap(2)/munmap(2). The initial mapping is a large chunk (size specified by \-\-mmap\-bytes) followed by pseudo-random 4K unmappings, then pseudo-random 4K mappings, and then linear 4K unmappings. Note that this can cause systems to trip the kernel OOM killer on Linux systems if not enough physical memory and swap is not available. The MAP_POPULATE option is used to populate pages into memory on systems that support this. By default, anonymous mappings are used, however, the \-\-mmap\-file and \-\-mmap\-async options allow one to perform file based mappings if desired. .TP @@ -870,7 +795,7 @@ stop procfs reading after N bogo read operations. Note, since the number of entries may vary between kernels, this bogo ops metric is probably very misleading. .TP .B \-\-pthread N -start N workers that iteratively creates and terminates multiple pthreads (the default is 1024 pthreads per worker). In each iteration, each newly created pthread waits until the worker has created all the pthreads and then they all terminate together. +start N workers that iteratively creates and terminates multiple pthreads (the default is 16 pthreads 16 worker). In each iteration, each newly created pthread waits until the worker has created all the pthreads and then they all terminate together. .TP .B \-\-pthread\-ops N stop pthread workers after N bogo pthread create operations. @@ -891,7 +816,7 @@ do not show any output. .TP .B \-r N, \-\-random N -start N random stress processes. If N is 0, then the number of on-line processors is used for N. +start N random stress processes. .TP .B \-\-rdrand N start N processes that read the Intel hardware random number generator (Intel Ivybridge processors upwards). @@ -1017,9 +942,6 @@ .B \-\-stack N start N processes that rapidly cause and catch stack overflows by use of alloca(3). .TP -.B \-\-stack\-full -the default action is to touch the lowest page on each stack allocation. This option touches all the pages by filling the new stack allocation with zeros which forces physical pages to be allocated and hence is more aggressve. -.TP .B \-\-stack\-ops N stop stack stress processes after N bogo stack overflows. .TP @@ -1041,9 +963,6 @@ .B \-\-sysinfo\-ops N stop the sysinfo stressors after N bogo operations. .TP -.B \-\-syslog -log output (except for verbose \-v messages) to the syslog. -.TP .B \-t N, \-\-timeout N stop stress test after N seconds. One can also specify the units of time in seconds, minutes, hours, days or years with the suffix s, m, h, d or y. @@ -1205,7 +1124,7 @@ fill memory with a random pattern and then sequentially rotate 64 bits of memory right by one bit, then check the final load/rotate/stored values. T} swap T{ -fill memory in 64 byte chunks with random patterns. Then swap each 64 chunk with a randomly chosen chunk. Finally, reverse the swap to put the chunks back to their original place and check if the data is correct. This exercises adjacent and random memory load/stores. +fill memory in 64 byte chunks with random patters. Then swap each 64 chunk with a randomly chosen chunk. Finally, reverse the swap to put the chunks back to their original place and check if the data is correct. This exercises adjacent and random memory load/stores. T} move-inv T{ sequentially fill memory 64 bits of memory at a time with random values, and then check if the memory is set correctly. Next, sequentially invert each 64 bit pattern and again check if the memory is set as expected. @@ -1332,10 +1251,6 @@ run all the stressors in the io class one by one for 5 minutes each, with 8 instances of each stressor running concurrently and show overall time utilisation statistics at the end of the run. -.LP -stress\-ng \-\-all 0 \-\-maximize \-\-aggressive -.IP -run all the stressors (1 instance of each per CPU) similtaneously, maximize the settings (memory sizes, file allocations, etc.) and select the most demanding/aggressive options. .SH BUGS File bug reports at: https://launchpad.net/ubuntu/+source/stress-ng/+filebug diff -Nru stress-ng-0.03.18/stress-ng.c stress-ng-0.03.15/stress-ng.c --- stress-ng-0.03.18/stress-ng.c 2015-02-18 16:06:42.000000000 +0000 +++ stress-ng-0.03.15/stress-ng.c 2015-02-09 23:44:46.000000000 +0000 @@ -36,7 +36,6 @@ #include #include #include -#include #include #include @@ -49,11 +48,11 @@ static proc_info_t procs[STRESS_MAX]; /* Per stressor process information */ /* Various option settings and flags */ -int32_t opt_sequential = DEFAULT_SEQUENTIAL; /* Number of sequential iterations */ +uint64_t opt_sequential = DEFAULT_SEQUENTIAL; /* Number of sequential iterations */ static int64_t opt_backoff = DEFAULT_BACKOFF; /* child delay */ static uint32_t opt_class = 0; /* Which kind of class is specified */ uint64_t opt_timeout = 0; /* timeout in seconds */ -uint64_t opt_flags = PR_ERROR | PR_INFO | OPT_FLAGS_MMAP_MADVISE; +int32_t opt_flags = PR_ERROR | PR_INFO | OPT_FLAGS_MMAP_MADVISE; volatile bool opt_do_run = true; /* false to exit stressor */ volatile bool opt_sigint = false; /* true if stopped by SIGINT */ @@ -135,10 +134,10 @@ /* Human readable stress test names */ static const stress_t stressors[] = { -#if defined(STRESS_AFFINITY) +#if defined(__linux__) STRESSOR(affinity, AFFINITY, CLASS_SCHEDULER), #endif -#if defined(STRESS_AIO) +#if defined(__linux__) STRESSOR(aio, AIO, CLASS_IO | CLASS_INTERRUPT | CLASS_OS), #endif STRESSOR(bigheap, BIGHEAP, CLASS_OS | CLASS_VM), @@ -146,20 +145,20 @@ STRESSOR(bsearch, BSEARCH, CLASS_CPU_CACHE | CLASS_CPU | CLASS_MEMORY), STRESSOR(cache, CACHE, CLASS_CPU_CACHE), STRESSOR(chmod, CHMOD, CLASS_IO | CLASS_OS), -#if defined(STRESS_CLOCK) +#if _POSIX_C_SOURCE >= 199309L STRESSOR(clock, CLOCK, CLASS_INTERRUPT | CLASS_OS), #endif STRESSOR(cpu, CPU, CLASS_CPU), STRESSOR(dentry, DENTRY, CLASS_IO | CLASS_OS), STRESSOR(dir, DIR, CLASS_IO | CLASS_OS), STRESSOR(dup, DUP, CLASS_IO | CLASS_OS), -#if defined(STRESS_EPOLL) +#if defined(__linux__) STRESSOR(epoll, EPOLL, CLASS_NETWORK | CLASS_OS), #endif -#if defined(STRESS_EVENTFD) +#if defined(__linux__) STRESSOR(eventfd, EVENTFD, CLASS_IO | CLASS_SCHEDULER | CLASS_OS), #endif -#if defined(STRESS_FALLOCATE) +#if _XOPEN_SOURCE >= 600 || _POSIX_C_SOURCE >= 200112L STRESSOR(fallocate, FALLOCATE, CLASS_IO | CLASS_OS), #endif STRESSOR(fault, FAULT, CLASS_INTERRUPT | CLASS_SCHEDULER | CLASS_OS), @@ -167,43 +166,39 @@ STRESSOR(flock, FLOCK, CLASS_IO | CLASS_OS), STRESSOR(fork, FORK, CLASS_SCHEDULER | CLASS_OS), STRESSOR(fstat, FSTAT, CLASS_IO | CLASS_OS), -#if defined(STRESS_FUTEX) +#if defined(__linux__) STRESSOR(futex, FUTEX, CLASS_SCHEDULER | CLASS_OS), #endif STRESSOR(get, GET, CLASS_OS), STRESSOR(hdd, HDD, CLASS_IO | CLASS_OS), STRESSOR(hsearch, HSEARCH, CLASS_CPU_CACHE | CLASS_CPU | CLASS_MEMORY), STRESSOR(iosync, IOSYNC, CLASS_IO | CLASS_OS), -#if defined(STRESS_INOTIFY) +#if defined(__linux__) STRESSOR(inotify, INOTIFY, CLASS_SCHEDULER | CLASS_OS), #endif -#if defined(STRESS_KCMP) - STRESSOR(kcmp, KCMP, CLASS_OS), -#endif STRESSOR(kill, KILL, CLASS_INTERRUPT | CLASS_SCHEDULER | CLASS_OS), -#if defined(STRESS_LEASE) +#if defined(F_SETLEASE) && defined(F_WRLCK) && defined(F_UNLCK) STRESSOR(lease, LEASE, CLASS_IO | CLASS_OS), #endif STRESSOR(link, LINK, CLASS_IO | CLASS_OS), -#if defined(STRESS_LOCKF) +#if _BSD_SOURCE || _SVID_SOURCE || _XOPEN_SOURCE >= 500 || \ + (_XOPEN_SOURCE && _XOPEN_SOURCE_EXTENDED) STRESSOR(lockf, LOCKF, CLASS_IO | CLASS_OS), #endif - STRESSOR(longjmp, LONGJMP, CLASS_CPU), STRESSOR(lsearch, LSEARCH, CLASS_CPU_CACHE | CLASS_CPU | CLASS_MEMORY), STRESSOR(malloc, MALLOC, CLASS_CPU_CACHE | CLASS_MEMORY | CLASS_OS), - STRESSOR(matrix, MATRIX, CLASS_CPU | CLASS_CPU_CACHE | CLASS_MEMORY | CLASS_CPU), STRESSOR(memcpy, MEMCPY, CLASS_CPU_CACHE | CLASS_MEMORY), -#if defined(STRESS_MINCORE) +#if (_BSD_SOURCE || _SVID_SOURCE) && !defined(__gnu_hurd__) STRESSOR(mincore, MINCORE, CLASS_OS | CLASS_MEMORY), #endif STRESSOR(mmap, MMAP, CLASS_VM | CLASS_IO | CLASS_OS), -#if defined(STRESS_MREMAP) +#if defined(__linux__) STRESSOR(mremap, MREMAP, CLASS_VM | CLASS_OS), #endif -#if defined(STRESS_MSG) +#if !defined(__gnu_hurd__) STRESSOR(msg, MSG, CLASS_SCHEDULER | CLASS_OS), #endif -#if defined(STRESS_MQ) +#if defined(__linux__) STRESSOR(mq, MQ, CLASS_SCHEDULER | CLASS_OS), #endif STRESSOR(nice, NICE, CLASS_SCHEDULER | CLASS_OS), @@ -211,66 +206,68 @@ STRESSOR(open, OPEN, CLASS_IO | CLASS_OS), STRESSOR(pipe, PIPE, CLASS_IO | CLASS_MEMORY | CLASS_OS), STRESSOR(poll, POLL, CLASS_SCHEDULER | CLASS_OS), -#if defined(STRESS_PROCFS) +#if defined (__linux__) STRESSOR(procfs, PROCFS, CLASS_IO | CLASS_OS), #endif STRESSOR(pthread, PTHREAD, CLASS_SCHEDULER | CLASS_OS), STRESSOR(qsort, QSORT, CLASS_CPU_CACHE | CLASS_CPU | CLASS_MEMORY), -#if defined(STRESS_RDRAND) +#if defined(STRESS_X86) STRESSOR(rdrand, RDRAND, CLASS_CPU), #endif STRESSOR(rename, RENAME, CLASS_IO | CLASS_OS), STRESSOR(seek, SEEK, CLASS_IO | CLASS_OS), STRESSOR(sem_posix, SEMAPHORE_POSIX, CLASS_OS | CLASS_SCHEDULER), -#if defined(STRESS_SEMAPHORE_SYSV) +#if !defined(__gnu_hurd__) STRESSOR(sem_sysv, SEMAPHORE_SYSV, CLASS_OS | CLASS_SCHEDULER), #endif STRESSOR(shm_sysv, SHM_SYSV, CLASS_VM | CLASS_OS), -#if defined(STRESS_SENDFILE) +#if defined(__linux__) STRESSOR(sendfile, SENDFILE, CLASS_IO | CLASS_OS), #endif -#if defined(STRESS_SIGFD) +#if defined(__linux__) STRESSOR(sigfd, SIGFD, CLASS_INTERRUPT | CLASS_OS), #endif STRESSOR(sigfpe, SIGFPE, CLASS_OS), -#if defined(STRESS_SIGQUEUE) +#if _POSIX_C_SOURCE >= 199309L && !defined(__gnu_hurd__) STRESSOR(sigq, SIGQUEUE, CLASS_INTERRUPT | CLASS_OS), #endif STRESSOR(sigsegv, SIGSEGV, CLASS_OS), STRESSOR(socket, SOCKET, CLASS_NETWORK | CLASS_OS), -#if defined(STRESS_SPLICE) +#if defined(__linux__) STRESSOR(splice, SPLICE, CLASS_IO | CLASS_OS), #endif STRESSOR(stack, STACK, CLASS_CPU | CLASS_MEMORY), STRESSOR(switch, SWITCH, CLASS_SCHEDULER | CLASS_OS), STRESSOR(symlink, SYMLINK, CLASS_IO | CLASS_OS), STRESSOR(sysinfo, SYSINFO, CLASS_OS), -#if defined(STRESS_TIMER) +#if defined(__linux__) STRESSOR(timer, TIMER, CLASS_INTERRUPT | CLASS_OS), #endif STRESSOR(tsearch, TSEARCH, CLASS_CPU_CACHE | CLASS_CPU | CLASS_MEMORY), STRESSOR(udp, UDP, CLASS_IO | CLASS_OS), -#if defined(STRESS_URANDOM) +#if defined(__linux__) || defined(__gnu_hurd__) STRESSOR(urandom, URANDOM, CLASS_IO | CLASS_OS), #endif STRESSOR(utime, UTIME, CLASS_NETWORK | CLASS_OS), -#if defined(STRESS_VECMATH) +#if defined(STRESS_VECTOR) STRESSOR(vecmath, VECMATH, CLASS_CPU), #endif -#if defined(STRESS_VFORK) +#if _BSD_SOURCE || \ + (_XOPEN_SOURCE >= 500 || _XOPEN_SOURCE && _XOPEN_SOURCE_EXTENDED) && \ + !(_POSIX_C_SOURCE >= 200809L || _XOPEN_SOURCE >= 700) STRESSOR(vfork, VFORK, CLASS_SCHEDULER | CLASS_OS), #endif STRESSOR(vm, VM, CLASS_IO | CLASS_VM | CLASS_MEMORY | CLASS_OS), -#if defined(STRESS_VM_RW) +#if defined (__linux__) STRESSOR(vm_rw, VM_RW, CLASS_VM | CLASS_MEMORY | CLASS_OS), #endif -#if defined(STRESS_VM_SPLICE) +#if defined(__linux__) STRESSOR(vm_splice, VM_SPLICE, CLASS_VM | CLASS_IO | CLASS_OS), #endif -#if defined(STRESS_WAIT) +#if !defined(__gnu_hurd__) && !defined(__NetBSD__) STRESSOR(wait, WAIT, CLASS_SCHEDULER | CLASS_OS), #endif -#if defined(STRESS_YIELD) +#if defined (_POSIX_PRIORITY_SCHEDULING) STRESSOR(yield, YIELD, CLASS_SCHEDULER | CLASS_OS), #endif STRESSOR(zero, ZERO, CLASS_IO | CLASS_MEMORY | CLASS_OS), @@ -293,13 +290,12 @@ }; static const struct option long_options[] = { -#if defined(STRESS_AFFINITY) +#if defined(__linux__) { "affinity", 1, 0, OPT_AFFINITY }, { "affinity-ops",1, 0, OPT_AFFINITY_OPS }, { "affinity-rand",0, 0, OPT_AFFINITY_RAND }, #endif - { "aggressive", 0, 0, OPT_AGGRESSIVE }, -#if defined(STRESS_AIO) +#if defined(__linux__) { "aio", 1, 0, OPT_AIO }, { "aio-ops", 1, 0, OPT_AIO_OPS }, { "aio-requests",1, 0, OPT_AIO_REQUESTS }, @@ -317,13 +313,12 @@ { "bsearch-size",1, 0, OPT_BSEARCH_SIZE }, { "cache", 1, 0, OPT_CACHE }, { "cache-ops", 1, 0, OPT_CACHE_OPS }, - { "cache-prefetch",0, 0, OPT_CACHE_PREFETCH }, - { "cache-flush",0, 0, OPT_CACHE_FLUSH }, - { "cache-fence",0, 0, OPT_CACHE_FENCE }, { "chmod", 1, 0, OPT_CHMOD }, { "chmod-ops", 1, 0, OPT_CHMOD_OPS }, + { "cache-flush",0, 0, OPT_CACHE_FLUSH }, + { "cache-fence",0, 0, OPT_CACHE_FENCE }, { "class", 1, 0, OPT_CLASS }, -#if defined(STRESS_CLOCK) +#if _POSIX_C_SOURCE >= 199309L { "clock", 1, 0, OPT_CLOCK }, { "clock-ops", 1, 0, OPT_CLOCK_OPS }, #endif @@ -340,20 +335,19 @@ { "dry-run", 0, 0, OPT_DRY_RUN }, { "dup", 1, 0, OPT_DUP }, { "dup-ops", 1, 0, OPT_DUP_OPS }, -#if defined(EPOLL) +#if defined (__linux__) { "epoll", 1, 0, OPT_EPOLL }, { "epoll-ops", 1, 0, OPT_EPOLL_OPS }, { "epoll-port", 1, 0, OPT_EPOLL_PORT }, { "epoll-domain",1, 0, OPT_EPOLL_DOMAIN }, #endif -#if defined(STRESS_EVENTFD) +#if defined (__linux__) { "eventfd", 1, 0, OPT_EVENTFD }, { "eventfd-ops",1, 0, OPT_EVENTFD_OPS }, #endif -#if defined(STRESS_FALLOCATE) +#if _XOPEN_SOURCE >= 600 || _POSIX_C_SOURCE >= 200112L { "fallocate", 1, 0, OPT_FALLOCATE }, { "fallocate-ops",1, 0, OPT_FALLOCATE_OPS }, - { "fallocate-bytes",1, 0, OPT_FALLOCATE_BYTES }, #endif { "fault", 1, 0, OPT_FAULT }, { "fault-ops", 1, 0, OPT_FAULT_OPS }, @@ -368,7 +362,7 @@ { "fstat", 1, 0, OPT_FSTAT }, { "fstat-ops", 1, 0, OPT_FSTAT_OPS }, { "fstat-dir", 1, 0, OPT_FSTAT_DIR }, -#if defined(STRESS_FUTEX) +#if defined(__linux__) { "futex", 1, 0, OPT_FUTEX }, { "futex-ops", 1, 0, OPT_FUTEX_OPS }, #endif @@ -383,37 +377,32 @@ { "hsearch", 1, 0, OPT_HSEARCH }, { "hsearch-ops",1, 0, OPT_HSEARCH_OPS }, { "hsearch-size",1, 0, OPT_HSEARCH_SIZE }, -#if defined(STRESS_INOTIFY) +#if defined (__linux__) { "inotify", 1, 0, OPT_INOTIFY }, { "inotify-ops",1, 0, OPT_INOTIFY_OPS }, #endif { "io", 1, 0, OPT_IOSYNC }, { "io-ops", 1, 0, OPT_IOSYNC_OPS }, -#if defined(STRESS_IONICE) +#if defined (__linux__) { "ionice-class",1, 0, OPT_IONICE_CLASS }, { "ionice-level",1, 0, OPT_IONICE_LEVEL }, #endif -#if defined(STRESS_KCMP) - { "kcmp", 1, 0, OPT_KCMP }, - { "kcmp-ops", 1, 0, OPT_KCMP_OPS }, -#endif { "keep-name", 0, 0, OPT_KEEP_NAME }, { "kill", 1, 0, OPT_KILL }, { "kill-ops", 1, 0, OPT_KILL_OPS }, -#if defined(STRESS_LEASE) +#if defined(F_SETLEASE) && defined(F_WRLCK) && defined(F_UNLCK) { "lease", 1, 0, OPT_LEASE }, { "lease-ops", 1, 0, OPT_LEASE_OPS }, { "lease-breakers",1, 0, OPT_LEASE_BREAKERS }, #endif { "link", 1, 0, OPT_LINK }, { "link-ops", 1, 0, OPT_LINK_OPS }, -#if defined(STRESS_LOCKF) +#if _BSD_SOURCE || _SVID_SOURCE || _XOPEN_SOURCE >= 500 || \ + (_XOPEN_SOURCE && _XOPEN_SOURCE_EXTENDED) { "lockf", 1, 0, OPT_LOCKF }, { "lockf-ops", 1, 0, OPT_LOCKF_OPS }, { "lockf-nonblock", 0, 0, OPT_LOCKF_NONBLOCK }, #endif - { "longjmp", 1, 0, OPT_LONGJMP }, - { "longjmp-ops",1, 0, OPT_LONGJMP_OPS }, { "lsearch", 1, 0, OPT_LSEARCH }, { "lsearch-ops",1, 0, OPT_LSEARCH_OPS }, { "lsearch-size",1, 0, OPT_LSEARCH_SIZE }, @@ -421,42 +410,33 @@ { "malloc-bytes",1, 0, OPT_MALLOC_BYTES }, { "malloc-max", 1, 0, OPT_MALLOC_MAX }, { "malloc-ops", 1, 0, OPT_MALLOC_OPS }, -#if defined(STRESS_MALLOPT) - { "malloc-thresh",1, 0, OPT_MALLOC_THRESHOLD }, -#endif - { "matrix", 1, 0, OPT_MATRIX }, - { "matrix-ops", 1, 0, OPT_MATRIX_OPS }, - { "matrix-method",1, 0, OPT_MATRIX_METHOD }, - { "matrix-size",1, 0, OPT_MATRIX_SIZE }, - { "maximize", 0, 0, OPT_MAXIMIZE }, { "memcpy", 1, 0, OPT_MEMCPY }, { "memcpy", 1, 0, OPT_MEMCPY }, { "memcpy", 1, 0, OPT_MEMCPY }, { "memcpy-ops", 1, 0, OPT_MEMCPY_OPS }, { "metrics", 0, 0, OPT_METRICS }, { "metrics-brief",0, 0, OPT_METRICS_BRIEF }, -#if defined(STRESS_MINCORE) +#if (_BSD_SOURCE || _SVID_SOURCE) && !defined(__gnu_hurd__) { "mincore", 1, 0, OPT_MINCORE }, { "mincore-ops",1, 0, OPT_MINCORE_OPS }, { "mincore-random",0, 0, OPT_MINCORE_RAND }, #endif - { "minimize", 0, 0, OPT_MINIMIZE }, { "mmap", 1, 0, OPT_MMAP }, { "mmap-ops", 1, 0, OPT_MMAP_OPS }, { "mmap-async", 0, 0, OPT_MMAP_ASYNC }, { "mmap-bytes", 1, 0, OPT_MMAP_BYTES }, { "mmap-file", 0, 0, OPT_MMAP_FILE }, { "mmap-mprotect",0, 0, OPT_MMAP_MPROTECT }, -#if defined(STRESS_MREMAP) +#if defined(__linux__) { "mremap", 1, 0, OPT_MREMAP }, { "mremap-ops", 1, 0, OPT_MREMAP_OPS }, { "mremap-bytes",1, 0, OPT_MREMAP_BYTES }, #endif -#if defined(STRESS_MSG) +#if !defined(__gnu_hurd__) { "msg", 1, 0, OPT_MSG }, { "msg-ops", 1, 0, OPT_MSG_OPS }, #endif -#if defined(STRESS_MQ) +#if defined(__linux__) { "mq", 1, 0, OPT_MQ }, { "mq-ops", 1, 0, OPT_MQ_OPS }, { "mq-size", 1, 0, OPT_MQ_SIZE }, @@ -468,14 +448,14 @@ { "null-ops", 1, 0, OPT_NULL_OPS }, { "open", 1, 0, OPT_OPEN }, { "open-ops", 1, 0, OPT_OPEN_OPS }, -#if defined(STRESS_PAGE_IN) +#if (_BSD_SOURCE || _SVID_SOURCE) && !defined(__gnu_hurd__) { "page-in", 0, 0, OPT_PAGE_IN }, #endif { "pipe", 1, 0, OPT_PIPE }, { "pipe-ops", 1, 0, OPT_PIPE_OPS }, { "poll", 1, 0, OPT_POLL }, { "poll-ops", 1, 0, OPT_POLL_OPS }, -#if defined(STRESS_PROCFS) +#if defined (__linux__) { "procfs", 1, 0, OPT_PROCFS }, { "procfs-ops", 1, 0, OPT_PROCFS_OPS }, #endif @@ -487,7 +467,7 @@ { "qsort-size", 1, 0, OPT_QSORT_INTEGERS }, { "quiet", 0, 0, OPT_QUIET }, { "random", 1, 0, OPT_RANDOM }, -#if defined(STRESS_RDRAND) +#if defined(STRESS_X86) { "rdrand", 1, 0, OPT_RDRAND }, { "rdrand-ops", 1, 0, OPT_RDRAND_OPS }, #endif @@ -501,12 +481,12 @@ { "sem", 1, 0, OPT_SEMAPHORE_POSIX }, { "sem-ops", 1, 0, OPT_SEMAPHORE_POSIX_OPS }, { "sem-procs", 1, 0, OPT_SEMAPHORE_POSIX_PROCS }, -#if defined(STRESS_SEMAPHORE_SYSV) +#if !defined(__gnu_hurd__) { "sem-sysv", 1, 0, OPT_SEMAPHORE_SYSV }, { "sem-sysv-ops",1, 0, OPT_SEMAPHORE_SYSV_OPS }, { "sem-sysv-procs",1, 0, OPT_SEMAPHORE_SYSV_PROCS }, #endif -#if defined(STRESS_SENDFILE) +#if defined(__linux__) { "sendfile", 1, 0, OPT_SENDFILE }, { "sendfile-ops",1, 0, OPT_SENDFILE_OPS }, { "sendfile-size",1, 0, OPT_SENDFILE_SIZE }, @@ -516,7 +496,7 @@ { "shm-sysv-ops",1, 0, OPT_SHM_SYSV_OPS }, { "shm-sysv-bytes",1, 0, OPT_SHM_SYSV_BYTES }, { "shm-sysv-segs",1, 0, OPT_SHM_SYSV_SEGMENTS }, -#if defined(STRESS_SIGFD) +#if defined(__linux__) { "sigfd", 1, 0, OPT_SIGFD }, { "sigfd-ops", 1, 0, OPT_SIGFD_OPS }, #endif @@ -524,7 +504,7 @@ { "sigfpe-ops", 1, 0, OPT_SIGFPE_OPS }, { "sigsegv", 1, 0, OPT_SIGSEGV }, { "sigsegv-ops",1, 0, OPT_SIGSEGV_OPS }, -#if defined(SIG_QUEUE) +#if _POSIX_C_SOURCE >= 199309L && !defined(__gnu_hurd__) { "sigq", 1, 0, OPT_SIGQUEUE }, { "sigq-ops", 1, 0, OPT_SIGQUEUE_OPS }, #endif @@ -532,23 +512,21 @@ { "sock-domain",1, 0, OPT_SOCKET_DOMAIN }, { "sock-ops", 1, 0, OPT_SOCKET_OPS }, { "sock-port", 1, 0, OPT_SOCKET_PORT }, -#if defined(STRESS_SPLICE) +#if defined (__linux__) { "splice", 1, 0, OPT_SPLICE }, { "splice-bytes",1, 0, OPT_SPLICE_BYTES }, { "splice-ops", 1, 0, OPT_SPLICE_OPS }, #endif { "stack", 1, 0, OPT_STACK}, { "stack-ops", 1, 0, OPT_STACK_OPS }, - { "stack-fill", 0, 0, OPT_STACK_FILL }, { "switch", 1, 0, OPT_SWITCH }, { "switch-ops", 1, 0, OPT_SWITCH_OPS }, { "symlink", 1, 0, OPT_SYMLINK }, { "symlink-ops",1, 0, OPT_SYMLINK_OPS }, { "sysinfo", 1, 0, OPT_SYSINFO }, { "sysinfo-ops",1, 0, OPT_SYSINFO_OPS }, - { "syslog", 0, 0, OPT_SYSLOG }, { "timeout", 1, 0, OPT_TIMEOUT }, -#if defined(STRESS_TIMER) +#if defined (__linux__) { "timer", 1, 0, OPT_TIMER }, { "timer-ops", 1, 0, OPT_TIMER_OPS }, { "timer-freq", 1, 0, OPT_TIMER_FREQ }, @@ -564,18 +542,20 @@ { "utime", 1, 0, OPT_UTIME }, { "utime-ops", 1, 0, OPT_UTIME_OPS }, { "utime-fsync",0, 0, OPT_UTIME_FSYNC }, -#if defined(STRESS_URANDOM) +#if defined (__linux__) || defined(__gnu_hurd__) { "urandom", 1, 0, OPT_URANDOM }, { "urandom-ops",1, 0, OPT_URANDOM_OPS }, #endif -#if defined(STRESS_VECMATH) +#if defined(STRESS_VECTOR) { "vecmath", 1, 0, OPT_VECMATH }, { "vecmath-ops",1, 0, OPT_VECMATH_OPS }, #endif { "verbose", 0, 0, OPT_VERBOSE }, { "verify", 0, 0, OPT_VERIFY }, { "version", 0, 0, OPT_VERSION }, -#if defined(STRESS_VFORK) +#if _BSD_SOURCE || \ + (_XOPEN_SOURCE >= 500 || _XOPEN_SOURCE && _XOPEN_SOURCE_EXTENDED) && \ + !(_POSIX_C_SOURCE >= 200809L || _XOPEN_SOURCE >= 700) { "vfork", 1, 0, OPT_VFORK }, { "vfork-ops", 1, 0, OPT_VFORK_OPS }, { "vfork-max", 1, 0, OPT_VFORK_MAX }, @@ -592,21 +572,21 @@ #endif { "vm-ops", 1, 0, OPT_VM_OPS }, { "vm-method", 1, 0, OPT_VM_METHOD }, -#if defined(STRESS_VM_RW) +#if defined (__linux__) { "vm-rw", 1, 0, OPT_VM_RW }, { "vm-rw-bytes",1, 0, OPT_VM_RW_BYTES }, { "vm-rw-ops", 1, 0, OPT_VM_RW_OPS }, #endif -#if defined(STRESS_VM_SPLICE) +#if defined (__linux__) { "vm-splice", 1, 0, OPT_VM_SPLICE }, { "vm-splice-bytes",1, 0, OPT_VM_SPLICE_BYTES }, { "vm-splice-ops",1, 0, OPT_VM_SPLICE_OPS }, #endif -#if defined(STRESS_WAIT) +#if !defined(__gnu_hurd__) && !defined(__NetBSD__) { "wait", 1, 0, OPT_WAIT }, { "wait-ops", 1, 0, OPT_WAIT_OPS }, #endif -#if defined(STRESS_YIELD) +#if defined (_POSIX_PRIORITY_SCHEDULING) { "yield", 1, 0, OPT_YIELD }, { "yield-ops", 1, 0, OPT_YIELD_OPS }, #endif @@ -617,13 +597,12 @@ static const help_t help[] = { { "-h", "help", "show help" }, -#if defined(STRESS_AFFINITY) +#if defined (__linux__) { NULL, "affinity N", "start N workers that rapidly change CPU affinity" }, { NULL, "affinity-ops N", "stop when N affinity bogo operations completed" }, { NULL, "affinity-rand", "change affinity randomly rather than sequentially" }, #endif - { NULL, "aggressive", "enable all aggressive options" }, -#if defined(STRESS_AIO) +#if defined (__linux__) { NULL, "aio N", "start N workers that issue async I/O requests" }, { NULL, "aio-ops N", "stop when N bogo async I/O requests completed" }, { NULL, "aio-requests N", "number of async I/O requests per worker" }, @@ -640,14 +619,13 @@ { NULL, "bsearch-ops", "stop when N binary search bogo operations completed" }, { NULL, "bsearch-size", "number of 32 bit integers to bsearch" }, { "C N", "cache N", "start N CPU cache thrashing workers" }, - { NULL, "cache-ops N", "stop when N cache bogo operations completed" }, - { NULL, "cache-prefetch", "prefetch on memory reads/writes" }, + { NULL, "cache-ops N", "stop when N cache bogo operations completed (x86 only)" }, { NULL, "cache-flush", "flush cache after every memory write (x86 only)" }, - { NULL, "cache-fence", "serialize stores (x86 only)" }, + { NULL, "cache-fence", "serialize stores" }, { NULL, "class name", "specify a class of stressors, use with --sequential" }, { NULL, "chmod N", "start N workers thrashing chmod file mode bits " }, { NULL, "chmod-ops N", "stop chmod workers after N bogo operations" }, -#if defined(STRESS_CLOCK) +#if _POSIX_C_SOURCE >= 199309L { NULL, "clock N", "start N workers thrashing clocks and POSIX timers" }, { NULL, "clock-ops N", "stop clock workers after N bogo operations" }, #endif @@ -664,20 +642,19 @@ { "n", "dry-run", "do not run" }, { NULL, "dup N", "start N workers exercising dup/close" }, { NULL, "dup-ops N", "stop when N dup/close bogo operations completed" }, -#if defined(STRESS_EPOLL) +#if defined (__linux__) { NULL, "epoll N", "start N workers doing epoll handled socket activity" }, { NULL, "epoll-ops N", "stop when N epoll bogo operations completed" }, { NULL, "epoll-port P", "use socket ports P upwards" }, { NULL, "epoll-domain D", "specify socket domain, default is unix" }, #endif -#if defined(STRESS_EVENTFD) +#if defined (__linux__) { NULL, "eventfd N", "start N workers stressing eventfd read/writes" }, { NULL, "eventfd-ops N", "stop eventfd workers after N bogo operations" }, #endif -#if defined(STRESS_FALLOCATE) +#if _XOPEN_SOURCE >= 600 || _POSIX_C_SOURCE >= 200112L { NULL, "fallocate N", "start N workers fallocating 16MB files" }, { NULL, "fallocate-ops N", "stop when N fallocate bogo operations completed" }, - { NULL, "fallocate-bytes N", "specify size of file to allocate" }, #endif { NULL, "fault N", "start N workers producing page faults" }, { NULL, "fault-ops N", "stop when N page fault bogo operations completed" }, @@ -692,7 +669,7 @@ { NULL, "fstat N", "start N workers exercising fstat on files" }, { NULL, "fstat-ops N", "stop when N fstat bogo operations completed" }, { NULL, "fstat-dir path", "fstat files in the specified directory" }, -#if defined(STRESS_FUTEX) +#if defined (__linux__) { NULL, "futex N", "start N workers exercising a fast mutex" }, { NULL, "futex-ops N", "stop when N fast mutex bogo operations completed" }, #endif @@ -706,37 +683,32 @@ { NULL, "hsearch", "start N workers that exercise a hash table search" }, { NULL, "hsearch-ops", "stop when N hash search bogo operations completed" }, { NULL, "hsearch-size", "number of integers to insert into hash table" }, -#if defined(STRESS_INOTIFY) +#if defined (__linux__) { NULL, "inotify N", "start N workers exercising inotify events" }, { NULL, "inotify-ops N", "stop inotify workers after N bogo operations" }, #endif { "i N", "io N", "start N workers spinning on sync()" }, { NULL, "io-ops N", "stop when N io bogo operations completed" }, -#if defined(STRESS_IONICE) +#if defined (__linux__) { NULL, "ionice-class C", "specify ionice class (idle, besteffort, realtime)" }, { NULL, "ionice-level L", "specify ionice level (0 max, 7 min)" }, #endif -#if defined(STRESS_KCMP) - { NULL, "kcmp N", "start N workers exercising kcmp" }, - { NULL, "kcmp-ops N", "stop when N kcmp bogo operations completed" }, -#endif { "k", "keep-name", "keep stress process names to be 'stress-ng'" }, { NULL, "kill N", "start N workers killing with SIGUSR1" }, { NULL, "kill-ops N", "stop when N kill bogo operations completed" }, -#if defined(STRESS_LEASE) +#if defined(F_SETLEASE) && defined(F_WRLCK) && defined(F_UNLCK) { NULL, "lease N", "start N workers holding and breaking a lease" }, { NULL, "lease-ops N", "stop when N lease bogo operations completed" }, { NULL, "lease-breakers N", "number of lease breaking processes to start" }, #endif { NULL, "link N", "start N workers creating hard links" }, { NULL, "link-ops N", "stop when N link bogo operations completed" }, -#if defined(STRESS_LOCKF) +#if _BSD_SOURCE || _SVID_SOURCE || _XOPEN_SOURCE >= 500 || \ + (_XOPEN_SOURCE && _XOPEN_SOURCE_EXTENDED) { NULL, "lockf N", "start N workers locking a single file via lockf" }, { NULL, "lockf-ops N", "stop when N lockf bogo operations completed" }, { NULL, "lockf-nonblock", "don't block if lock cannot be obtained, re-try" }, #endif - { NULL, "longjmp N", "start N workers exercising setjmp/longjmp" }, - { NULL, "longjmp-ops N", "stop when N longjmp bogo operations completed" }, { NULL, "lsearch", "start N workers that exercise a linear search" }, { NULL, "lsearch-ops", "stop when N linear search bogo operations completed" }, { NULL, "lsearch-size", "number of 32 bit integers to lsearch" }, @@ -744,40 +716,29 @@ { NULL, "malloc-bytes N", "allocate up to N bytes per allocation" }, { NULL, "malloc-max N", "keep up to N allocations at a time" }, { NULL, "malloc-ops N", "stop when N malloc bogo operations completed" }, -#if defined(STRESS_MALLOPT) - { NULL, "malloc-thresh N", "threshold where malloc uses mmap instead of sbrk" }, -#endif - { NULL, "matrix N", "start N workers exercising matrix operations" }, - { NULL, "matrix-ops N", "stop when N maxtrix bogo operations completed" }, - { NULL, "matrix-method m", "specify matrix stress method m, default is all" }, - { NULL, "matrix-size N", "specify the size of the N x N matrix" }, - { NULL, "maximize", "enable maximum stress options" }, { "M", "metrics", "print pseudo metrics of activity" }, { NULL, "metrics-brief", "enable metrics and only show non-zero results" }, { NULL, "memcpy N", "start N workers performing memory copies" }, { NULL, "memcpy-ops N", "stop when N memcpy bogo operations completed" }, -#if defined(STRESS_MINCORE) +#if (_BSD_SOURCE || _SVID_SOURCE) && !defined(__gnu_hurd__) { NULL, "mincore N", "start N workers exercising mincore" }, { NULL, "mincore-ops N", "stop when N mimcore bogo operations completed" }, { NULL, "mincore-random", "randomly select pages rather than linear scan" }, #endif - { NULL, "minimize", "enable minimal stress options" }, { NULL, "mmap N", "start N workers stressing mmap and munmap" }, { NULL, "mmap-ops N", "stop when N mmap bogo operations completed" }, { NULL, "mmap-async", "using asynchronous msyncs for file based mmap" }, { NULL, "mmap-bytes N", "mmap and munmap N bytes for each stress iteration" }, { NULL, "mmap-file", "mmap onto a file using synchronous msyncs" }, { NULL, "mmap-mprotect", "enable mmap mprotect stressing" }, -#if defined(STRESS_MREMAP) +#if defined(__linux__) { NULL, "mremap N", "start N workers stressing mremap" }, { NULL, "mremap-ops N", "stop when N mremap bogo operations completed" }, { NULL, "mremap-bytes N", "mremap N bytes maximum for each stress iteration" }, #endif -#if defined(STRESS_MSG) { NULL, "msg N", "start N workers passing messages using System V messages" }, { NULL, "msg-ops N", "stop msg workers after N bogo messages completed" }, -#endif -#if defined(STRESS_MQ) +#if defined(__linux__) { NULL, "mq N", "start N workers passing messages using POSIX messages" }, { NULL, "mq-ops N", "stop mq workers after N bogo messages completed" }, { NULL, "mq-size N", "specify the size of the POSIX message queue" }, @@ -789,14 +750,14 @@ { NULL, "null-ops N", "stop when N /dev/null bogo write operations completed" }, { "o", "open N", "start N workers exercising open/close" }, { NULL, "open-ops N", "stop when N open/close bogo operations completed" }, -#if defined(STRESS_PAGE_IN) +#if (_BSD_SOURCE || _SVID_SOURCE) && !defined(__gnu_hurd__) { NULL, "page-in", "touch allocated pages that are not in core" }, #endif { "p N", "pipe N", "start N workers exercising pipe I/O" }, { NULL, "pipe-ops N", "stop when N pipe I/O bogo operations completed" }, { "P N", "poll N", "start N workers exercising zero timeout polling" }, { NULL, "poll-ops N", "stop when N poll bogo operations completed" }, -#if defined(STRESS_PROCFS) +#if defined (__linux__) { NULL, "procfs N", "start N workers reading portions of /proc" }, { NULL, "procfs-ops N", "stop procfs workers after N bogo read operations" }, #endif @@ -808,7 +769,7 @@ { NULL, "qsort-size N", "number of 32 bit integers to sort" }, { "q", "quiet", "quiet output" }, { "r", "random N", "start N random workers" }, -#if defined(STRESS_RDRAND) +#if defined(STRESS_X86) { NULL, "rdrand N", "start N workers exercising rdrand instruction (x86 only)" }, { NULL, "rdrand-ops N", "stop when N rdrand bogo operations completed" }, #endif @@ -822,12 +783,12 @@ { NULL, "sem N", "start N workers doing semaphore operations" }, { NULL, "sem-ops N", "stop when N semaphore bogo operations completed" }, { NULL, "sem-procs N", "number of processes to start per worker" }, -#if defined(STRESS_SEMAPHORE_SYSV) +#if !defined(__gnu_hurd__) { NULL, "sem-sysv N", "start N workers doing System V semaphore operations" }, { NULL, "sem-sysv-ops N", "stop when N System V semaphore bogo operations completed" }, { NULL, "sem-sysv-procs N", "number of processes to start per worker" }, #endif -#if defined(STRESS_SENDFILE) +#if defined (__linux__) { NULL, "sendfile N", "start N workers exercising sendfile" }, { NULL, "sendfile-ops N", "stop after N bogo sendfile operations" }, { NULL, "sendfile-size N", "size of data to be sent with sendfile" }, @@ -837,13 +798,13 @@ { NULL, "shm-sysv-ops N", "stop after N shared memory bogo operations" }, { NULL, "shm-sysv-bytes N", "allocate and free N bytes of shared memory per iteration" }, { NULL, "shm-sysv-segs N", "allocate N shared memory segments per iteration" }, -#if defined(STRESS_SIGFD) +#if defined (__linux__) { NULL, "sigfd N", "start N workers reading signals via signalfd reads " }, { NULL, "sigfd-ops N", "stop when N bogo signalfd reads completed" }, #endif { NULL, "sigfpe N", "start N workers generating floating point math faults" }, { NULL, "sigfpe-ops N", "stop when N bogo floating point math faults completed" }, -#if defined(STRESS_SIGQUEUE) +#if _POSIX_C_SOURCE >= 199309L { NULL, "sigq N", "start N workers sending sigqueue signals" }, { NULL, "sigq-ops N", "stop when N siqqueue bogo operations completed" }, #endif @@ -853,23 +814,21 @@ { NULL, "sock-ops N", "stop when N socket bogo operations completed" }, { NULL, "sock-port P", "use socket ports P to P + number of workers - 1" }, { NULL, "sock-domain D", "specify socket domain, default is ipv4" }, -#if defined(STRESS_SPLICE) +#if defined (__linux__) { NULL, "splice N", "start N workers reading/writing using splice" }, { NULL, "splice-ops N", "stop when N bogo splice operations completed" }, { NULL, "splice-bytes N", "number of bytes to transfer per splice call" }, #endif { NULL, "stack N", "start N workers generating stack overflows" }, { NULL, "stack-ops N", "stop when N bogo stack overflows completed" }, - { NULL, "stack-fill", "fill stack, touches all new pages " }, { "s N", "switch N", "start N workers doing rapid context switches" }, { NULL, "switch-ops N", "stop when N context switch bogo operations completed" }, { NULL, "symlink N", "start N workers creating symbolic links" }, { NULL, "symlink-ops N", "stop when N symbolic link bogo operations completed" }, { NULL, "sysinfo N", "start N workers reading system information" }, { NULL, "sysinfo-ops N", "stop when sysinfo bogo operations completed" }, - { NULL, "syslog", "log messages to the syslog" }, { "t N", "timeout N", "timeout after N seconds" }, -#if defined(STRESS_TIMER) +#if defined (__linux__) { "T N", "timer N", "start N workers producing timer events" }, { NULL, "timer-ops N", "stop when N timer bogo events completed" }, { NULL, "timer-freq F", "run timer(s) at F Hz, range 1000 to 1000000000" }, @@ -882,21 +841,23 @@ { NULL, "udp-ops N", "stop when N udp bogo operations completed" }, { NULL, "udp-port P", "use ports P to P + number of workers - 1" }, { NULL, "udo-domain D", "specify domain, default is ipv4" }, -#if defined(STRESS_URANDOM) +#if defined(__linux__) || defined(__gnu_hurd__) { "u N", "urandom N", "start N workers reading /dev/urandom" }, { NULL, "urandom-ops N", "stop when N urandom bogo read operations completed" }, #endif { NULL, "utime N", "start N workers updating file timestamps" }, { NULL, "utime-ops N", "stop after N utime bogo operations completed" }, { NULL, "utime-fsync", "force utime meta data sync to the file system" }, -#if defined(STRESS_VECMATH) +#if defined(STRESS_VECTOR) { NULL, "vecmath N", "start N workers performing vector math ops" }, { NULL, "vecmath-ops N", "stop after N vector math bogo operations completed" }, #endif { "v", "verbose", "verbose output" }, { NULL, "verify", "verify results (not available on all tests)" }, { "V", "version", "show version" }, -#if defined(STRESS_VFORK) +#if _BSD_SOURCE || \ + (_XOPEN_SOURCE >= 500 || _XOPEN_SOURCE && _XOPEN_SOURCE_EXTENDED) && \ + !(_POSIX_C_SOURCE >= 200809L || _XOPEN_SOURCE >= 700) { NULL, "vfork N", "start N workers spinning on vfork() and exit()" }, { NULL, "vfork-ops N", "stop when N vfork bogo operations completed" }, { NULL, "vfork-max P", "create P processes per iteration, default is 1" }, @@ -913,21 +874,21 @@ #ifdef MAP_POPULATE { NULL, "vm-populate", "populate (prefault) page tables for a mapping" }, #endif -#if defined(STRESS_VM_RW) +#if defined (__linux__) { NULL, "vm-rw N", "start N vm read/write process_vm* copy workers" }, { NULL, "vm-rw-bytes N", "transfer N bytes of memory per bogo operation" }, { NULL, "vm-rw-ops N", "stop after N vm process_vm* copy bogo operations" }, #endif -#if defined(STRESS_VM_SPLICE) +#if defined (__linux__) { NULL, "vm-splice N", "start N workers reading/writing using vmsplice" }, { NULL, "vm-splice-ops N", "stop when N bogo splice operations completed" }, { NULL, "vm-splice-bytes N", "number of bytes to transfer per vmsplice call" }, #endif -#if defined(STRESS_WAIT) +#if !defined(__gnu_hurd__) && !defined(__NetBSD__) { NULL, "wait N", "start N workers waiting on child being stop/resumed" }, { NULL, "wait-ops N", "stop when N bogo wait operations completed" }, #endif -#if defined(STRESS_YIELD) +#if defined(_POSIX_PRIORITY_SCHEDULING) { "y N", "yield N", "start N workers doing sched_yield() calls" }, { NULL, "yield-ops N", "stop when N bogo yield operations completed" }, #endif @@ -1032,7 +993,7 @@ if (help[i].opt_s) snprintf(opt_s, sizeof(opt_s), "-%s,", help[i].opt_s); - printf("%-6s--%-18s%s\n", opt_s, + printf(" %-6s--%-17s%s\n", opt_s, help[i].opt_l, help[i].description); } printf("\nExample: %s --cpu 8 --io 4 --vm 2 --vm-bytes 128M --fork 4 --timeout 10s\n\n" @@ -1044,7 +1005,7 @@ * opt_name() * find name associated with an option value */ -static const char *opt_name(const int opt_val) +static const char *opt_name(int opt_val) { int i; @@ -1069,22 +1030,21 @@ * kill_procs() * kill tasks using signal */ -static void kill_procs(const int sig) +static void kill_procs(int sig) { static int count = 0; - int i, signum = sig; + int i; /* multiple calls will always fallback to SIGKILL */ count++; if (count > 5) - signum = SIGKILL; + sig = SIGKILL; for (i = 0; i < STRESS_MAX; i++) { int j; - for (j = 0; j < procs[i].started_procs; j++) { if (procs[i].pids[j]) - (void)kill(procs[i].pids[j], signum); + (void)kill(procs[i].pids[j], sig); } } } @@ -1099,7 +1059,6 @@ for (i = 0; i < STRESS_MAX; i++) { int j; - for (j = 0; j < procs[i].started_procs; j++) { pid_t pid; redo: @@ -1278,55 +1237,13 @@ *duration += time_finish - time_start; } -/* - * show_hogs() - * show names of stressors that are going to be run - */ -static int show_hogs(void) -{ - char *newstr, *str = NULL; - ssize_t len = 0; - char buffer[64]; - bool previous = false; - int i; - - for (i = 0; i < STRESS_MAX; i++) { - if (opt_sequential || procs[i].num_procs) { - ssize_t buffer_len; - - buffer_len = snprintf(buffer, sizeof(buffer), "%s %" PRId32 " %s", - previous ? "," : "", - opt_sequential ? opt_sequential : procs[i].num_procs, - munge_underscore((char *)stressors[i].name)); - previous = true; - if (buffer_len >= 0) { - newstr = realloc(str, len + buffer_len + 1); - if (!newstr) { - pr_err(stderr, "Cannot allocate temporary buffer\n"); - free(str); - return -1; - } - str = newstr; - strncpy(str + len, buffer, buffer_len + 1); - } - len += buffer_len; - } - } - pr_inf(stdout, "dispatching hogs: %s\n", str ? str : ""); - free(str); - fflush(stdout); - - return 0; -} - - int main(int argc, char **argv) { double duration = 0.0; int32_t val, opt_random = 0, i, j; int32_t total_procs = 0, max_procs = 0; size_t len; - bool success = true; + bool success = true, previous = false; struct sigaction new_action; long int ticks_per_sec; struct rlimit limit; @@ -1338,7 +1255,6 @@ (void)stress_get_pagesize(); (void)stress_set_cpu_method("all"); (void)stress_set_vm_method("all"); - (void)stress_set_matrix_method("all"); if (stress_get_processors_online() < 0) { pr_err(stderr, "sysconf failed, number of cpus online unknown: errno=%d: (%s)\n", @@ -1380,7 +1296,7 @@ } switch (c) { -#if defined(STRESS_AIO) +#if defined(__linux__) case OPT_AIO_REQUESTS: stress_set_aio_requests(optarg); break; @@ -1394,14 +1310,11 @@ for (i = 0; i < STRESS_MAX; i++) procs[i].num_procs = val; break; -#if defined(STRESS_AFFINITY) +#if defined(__linux__) case OPT_AFFINITY_RAND: opt_flags |= OPT_FLAGS_AFFINITY_RAND; break; #endif - case OPT_AGGRESSIVE: - opt_flags |= OPT_FLAGS_AGGRESSIVE_MASK; - break; case OPT_BACKOFF: opt_backoff = opt_long("backoff", optarg); break; @@ -1414,9 +1327,6 @@ case OPT_BSEARCH_SIZE: stress_set_bsearch_size(optarg); break; - case OPT_CACHE_PREFETCH: - opt_flags |= OPT_FLAGS_CACHE_PREFETCH; - break; case OPT_CACHE_FLUSH: opt_flags |= OPT_FLAGS_CACHE_FLUSH; break; @@ -1452,7 +1362,7 @@ if (stress_set_dentry_order(optarg) < 0) exit(EXIT_FAILURE); break; -#if defined(EPOLL) +#if defined (__linux__) case OPT_EPOLL_DOMAIN: if (stress_set_epoll_domain(optarg) < 0) exit(EXIT_FAILURE); @@ -1461,11 +1371,6 @@ stress_set_epoll_port(optarg); break; #endif -#if defined(STRESS_FALLOCATE) - case OPT_FALLOCATE_BYTES: - stress_set_fallocate_bytes(optarg); - break; -#endif case OPT_FIFO_READERS: stress_set_fifo_readers(optarg); break; @@ -1491,7 +1396,7 @@ case OPT_HSEARCH_SIZE: stress_set_hsearch_size(optarg); break; -#if defined(STRESS_IONICE) +#if defined (__linux__) case OPT_IONICE_CLASS: opt_ionice_class = get_opt_ionice_class(optarg); break; @@ -1502,12 +1407,13 @@ case OPT_KEEP_NAME: opt_flags |= OPT_FLAGS_KEEP_NAME; break; -#if defined(STRESS_LEASE) +#if defined(F_SETLEASE) && defined(F_WRLCK) && defined(F_UNLCK) case OPT_LEASE_BREAKERS: stress_set_lease_breakers(optarg); break; #endif -#if defined(STRESS_LOCKF) +#if _BSD_SOURCE || _SVID_SOURCE || _XOPEN_SOURCE >= 500 || \ + (_XOPEN_SOURCE && _XOPEN_SOURCE_EXTENDED) case OPT_LOCKF_NONBLOCK: opt_flags |= OPT_FLAGS_LOCKF_NONBLK; break; @@ -1521,35 +1427,17 @@ case OPT_MALLOC_MAX: stress_set_malloc_max(optarg); break; -#if defined(STRESS_MALLOPT) - case OPT_MALLOC_THRESHOLD: - stress_set_malloc_threshold(optarg); - break; -#endif - case OPT_MATRIX_METHOD: - if (stress_set_matrix_method(optarg) < 0) - exit(EXIT_FAILURE); - break; - case OPT_MATRIX_SIZE: - stress_set_matrix_size(optarg); - break; - case OPT_MAXIMIZE: - opt_flags |= OPT_FLAGS_MAXIMIZE; - break; case OPT_METRICS: opt_flags |= OPT_FLAGS_METRICS; break; case OPT_METRICS_BRIEF: opt_flags |= (OPT_FLAGS_METRICS_BRIEF | OPT_FLAGS_METRICS); break; -#if defined(STRESS_MINCORE) +#if (_BSD_SOURCE || _SVID_SOURCE) && !defined(__gnu_hurd__) case OPT_MINCORE_RAND: opt_flags |= OPT_FLAGS_MINCORE_RAND; break; #endif - case OPT_MINIMIZE: - opt_flags |= OPT_FLAGS_MINIMIZE; - break; case OPT_MMAP_ASYNC: opt_flags |= (OPT_FLAGS_MMAP_FILE | OPT_FLAGS_MMAP_ASYNC); break; @@ -1562,12 +1450,12 @@ case OPT_MMAP_MPROTECT: opt_flags |= OPT_FLAGS_MMAP_MPROTECT; break; -#if defined(STRESS_MREMAP) +#if defined(__linux__) case OPT_MREMAP_BYTES: stress_set_mremap_bytes(optarg); break; #endif -#if defined(STRESS_MQ) +#if defined(__linux__) case OPT_MQ_SIZE: stress_set_mq_size(optarg); break; @@ -1575,8 +1463,7 @@ case OPT_NO_MADVISE: opt_flags &= ~OPT_FLAGS_MMAP_MADVISE; break; -#if defined(STRESS_PAGE_IN) - printf("PAGEIN!\n"); +#if (_BSD_SOURCE || _SVID_SOURCE) && !defined(__gnu_hurd__) case OPT_PAGE_IN: opt_flags |= OPT_FLAGS_MMAP_MINCORE; break; @@ -1596,9 +1483,7 @@ break; case OPT_RANDOM: opt_flags |= OPT_FLAGS_RANDOM; - opt_random = get_uint64(optarg); - if (opt_random <= 0) - opt_random = stress_get_processors_online(); + opt_random = opt_long("-r", optarg); check_value("random", opt_random); break; case OPT_SCHED: @@ -1613,18 +1498,18 @@ case OPT_SEMAPHORE_POSIX_PROCS: stress_set_semaphore_posix_procs(optarg); break; -#if defined(STRESS_SEMAPHORE_SYSV) +#if !defined(__gnu_hurd__) case OPT_SEMAPHORE_SYSV_PROCS: stress_set_semaphore_sysv_procs(optarg); break; #endif -#if defined(STRESS_SENDFILE) +#if defined (__linux__) case OPT_SENDFILE_SIZE: stress_set_sendfile_size(optarg); break; #endif case OPT_SEQUENTIAL: - opt_sequential = get_uint64(optarg); + opt_sequential = get_uint64_byte(optarg); if (opt_sequential <= 0) opt_sequential = stress_get_processors_online(); check_range("sequential", opt_sequential, @@ -1643,21 +1528,15 @@ case OPT_SOCKET_PORT: stress_set_socket_port(optarg); break; -#if defined(STRESS_SPLICE) +#if defined (__linux__) case OPT_SPLICE_BYTES: stress_set_splice_bytes(optarg); break; #endif - case OPT_STACK_FILL: - opt_flags |= OPT_FLAGS_STACK_FILL; - break; - case OPT_SYSLOG: - opt_flags |= OPT_FLAGS_SYSLOG; - break; case OPT_TIMEOUT: opt_timeout = get_uint64_time(optarg); break; -#if defined(STRESS_TIMER) +#if defined (__linux__) case OPT_TIMER_FREQ: stress_set_timer_freq(optarg); break; @@ -1681,7 +1560,9 @@ case OPT_VERBOSE: opt_flags |= PR_ALL; break; -#if defined(STRESS_VFORK) +#if _BSD_SOURCE || \ + (_XOPEN_SOURCE >= 500 || _XOPEN_SOURCE && _XOPEN_SOURCE_EXTENDED) && \ + !(_POSIX_C_SOURCE >= 200809L || _XOPEN_SOURCE >= 700) case OPT_VFORK_MAX: stress_set_vfork_max(optarg); break; @@ -1715,12 +1596,12 @@ stress_set_vm_flags(MAP_POPULATE); break; #endif -#if defined(STRESS_VM_RW) +#if defined (__linux__) case OPT_VM_RW_BYTES: stress_set_vm_rw_bytes(optarg); break; #endif -#if defined(STRESS_VM_SPLICE) +#if defined (__linux__) case OPT_VM_SPLICE_BYTES: stress_set_vm_splice_bytes(optarg); break; @@ -1731,9 +1612,6 @@ } } - if (opt_flags & OPT_SYSLOG) - openlog("stress-ng", 0, LOG_USER); - if (opt_class && !opt_sequential) { fprintf(stderr, "class option is only used with sequential option\n"); exit(EXIT_FAILURE); @@ -1741,18 +1619,6 @@ pr_dbg(stderr, "%ld processors online\n", stress_get_processors_online()); - if ((opt_flags & OPT_FLAGS_MINMAX_MASK) == OPT_FLAGS_MINMAX_MASK) { - fprintf(stderr, "maximize and minimize cannot be used together\n"); - exit(EXIT_FAILURE); - } - -#if defined(STRESS_RDRAND) - id = stressor_id_find(STRESS_RDRAND); - if ((procs[id].num_procs) && - (stress_rdrand_supported() < 0)) - procs[id].num_procs = 0; -#endif - if (opt_flags & OPT_FLAGS_RANDOM) { int32_t n = opt_random; @@ -1814,7 +1680,7 @@ max_procs = opt_sequential; } else { if (!total_procs) { - pr_err(stderr, "No stress workers\n"); + pr_err(stderr, "No stress workers specified\n"); free_procs(); exit(EXIT_FAILURE); } @@ -1849,11 +1715,17 @@ stress_adjust_ptread_max(max); } - if (show_hogs() < 0) { - free_procs(); - exit(EXIT_FAILURE); + pr_inf(stdout, "dispatching hogs:"); + for (i = 0; i < STRESS_MAX; i++) { + if (procs[i].num_procs) { + fprintf(stdout, "%s %" PRId32 " %s", + previous ? "," : "", + procs[i].num_procs, stressors[i].name); + previous = true; + } } - + fprintf(stdout, "\n"); + fflush(stdout); len = sizeof(shared_t) + (sizeof(proc_stats_t) * STRESS_MAX * max_procs); shared = mmap(NULL, len, PROT_READ | PROT_WRITE, MAP_SHARED | MAP_ANON, -1, 0); @@ -1870,7 +1742,7 @@ if (procs[id].num_procs || opt_sequential) stress_semaphore_posix_init(); -#if defined(STRESS_SEMAPHORE_SYSV) +#if !defined(__gnu_hurd__) id = stressor_id_find(STRESS_SEMAPHORE_SYSV); if (procs[id].num_procs || opt_sequential) stress_semaphore_sysv_init(); @@ -1940,7 +1812,7 @@ free_procs(); stress_semaphore_posix_destroy(); -#if defined(STRESS_SEMAPHORE_SYSV) +#if !defined(__gnu_hurd__) stress_semaphore_sysv_destroy(); #endif (void)munmap(shared, len); @@ -1974,8 +1846,5 @@ (float)buf.tms_cstime) / (float)ticks_per_sec) / total_cpu_time); } - if (opt_flags & OPT_SYSLOG) - closelog(); - exit(EXIT_SUCCESS); } diff -Nru stress-ng-0.03.18/stress-ng.h stress-ng-0.03.15/stress-ng.h --- stress-ng-0.03.18/stress-ng.h 2015-02-17 18:29:01.000000000 +0000 +++ stress-ng-0.03.15/stress-ng.h 2015-02-09 23:44:46.000000000 +0000 @@ -39,11 +39,7 @@ #include #include #include -#if defined (__linux__) -#include -#endif #include -#include #define _GNU_SOURCE /* GNU HURD */ @@ -60,59 +56,33 @@ #define SOCKET_BUF (8192) /* Socket I/O buffer size */ #define UDP_BUF (1024) /* UDP I/O buffer size */ -/* debug output bitmasks */ -#define PR_ERROR 0x0000000001ULL /* Print errors */ -#define PR_INFO 0x0000000002ULL /* Print info */ -#define PR_DEBUG 0x0000000004ULL /* Print debug */ -#define PR_FAIL 0x0000000008ULL /* Print test failure message */ -#define PR_ALL (PR_ERROR | PR_INFO | PR_DEBUG | PR_FAIL) - /* Option bit masks */ -#define OPT_FLAGS_AFFINITY_RAND 0x0000000010ULL /* Change affinity randomly */ -#define OPT_FLAGS_DRY_RUN 0x0000000020ULL /* Don't actually run */ -#define OPT_FLAGS_METRICS 0x0000000040ULL /* Dump metrics at end */ -#define OPT_FLAGS_VM_KEEP 0x0000000080ULL /* Don't keep re-allocating */ -#define OPT_FLAGS_RANDOM 0x0000000100ULL /* Randomize */ -#define OPT_FLAGS_SET 0x0000000200ULL /* Set if user specifies stress procs */ -#define OPT_FLAGS_KEEP_NAME 0x0000000400ULL /* Keep stress names to stress-ng */ -#define OPT_FLAGS_UTIME_FSYNC 0x0000000800ULL /* fsync after utime modification */ -#define OPT_FLAGS_METRICS_BRIEF 0x0000001000ULL /* dump brief metrics */ -#define OPT_FLAGS_VERIFY 0x0000002000ULL /* verify mode */ -#define OPT_FLAGS_MMAP_MADVISE 0x0000004000ULL /* enable random madvise settings */ -#define OPT_FLAGS_MMAP_MINCORE 0x0000008000ULL /* mincore force pages into mem */ -#define OPT_FLAGS_TIMES 0x0000010000ULL /* user/system time summary */ -#define OPT_FLAGS_CACHE_PREFETCH 0x0000020000ULL /* cache prefetch */ -#define OPT_FLAGS_CACHE_FLUSH 0x0000040000ULL /* cache flush */ -#define OPT_FLAGS_CACHE_FENCE 0x0000080000ULL /* cache fence */ -#define OPT_FLAGS_CACHE_MASK (OPT_FLAGS_CACHE_FLUSH | \ - OPT_FLAGS_CACHE_FENCE | \ - OPT_FLAGS_CACHE_PREFETCH) -#define OPT_FLAGS_MMAP_FILE 0x0000100000ULL /* mmap onto a file */ -#define OPT_FLAGS_MMAP_ASYNC 0x0000200000ULL /* mmap file asynchronous I/O */ -#define OPT_FLAGS_MMAP_MPROTECT 0x0000400000ULL /* mmap mprotect enabled */ -#define OPT_FLAGS_LOCKF_NONBLK 0x0000800000ULL /* Non-blocking lockf */ -#define OPT_FLAGS_MINCORE_RAND 0x0001000000ULL /* mincore randomize */ -#define OPT_FLAGS_BRK_NOTOUCH 0x0002000000ULL /* brk, don't touch page */ -#define OPT_FLAGS_HDD_SYNC 0x0004000000ULL /* HDD O_SYNC */ -#define OPT_FLAGS_HDD_DSYNC 0x0008000000ULL /* HDD O_DYNC */ -#define OPT_FLAGS_HDD_DIRECT 0x0010000000ULL /* HDD O_DIRECT */ -#define OPT_FLAGS_HDD_NOATIME 0x0020000000ULL /* HDD O_NOATIME */ -#define OPT_FLAGS_STACK_FILL 0x0040000000ULL /* Fill stack */ -#define OPT_FLAGS_MINIMIZE 0x0080000000ULL /* Minimize */ -#define OPT_FLAGS_MAXIMIZE 0x0100000000ULL /* Maximize */ -#define OPT_FLAGS_MINMAX_MASK (OPT_FLAGS_MINIMIZE | OPT_FLAGS_MAXIMIZE) -#define OPT_FLAGS_SYSLOG 0x0200000000ULL /* log test progress to syslog */ - -#define OPT_FLAGS_AGGRESSIVE_MASK \ - (OPT_FLAGS_AFFINITY_RAND | OPT_FLAGS_UTIME_FSYNC | \ - OPT_FLAGS_MMAP_MADVISE | OPT_FLAGS_MMAP_MINCORE | \ - OPT_FLAGS_CACHE_FLUSH | OPT_FLAGS_CACHE_FENCE | \ - OPT_FLAGS_MMAP_FILE | OPT_FLAGS_MMAP_ASYNC | \ - OPT_FLAGS_MMAP_MPROTECT | OPT_FLAGS_LOCKF_NONBLK |\ - OPT_FLAGS_MINCORE_RAND | OPT_FLAGS_HDD_SYNC | \ - OPT_FLAGS_HDD_DSYNC | OPT_FLAGS_HDD_DIRECT | \ - OPT_FLAGS_STACK_FILL | OPT_FLAGS_CACHE_PREFETCH) - +#define OPT_FLAGS_AFFINITY_RAND 0x00000001 /* Change affinity randomly */ +#define OPT_FLAGS_DRY_RUN 0x00000002 /* Don't actually run */ +#define OPT_FLAGS_METRICS 0x00000004 /* Dump metrics at end */ +#define OPT_FLAGS_VM_KEEP 0x00000008 /* Don't keep re-allocating */ +#define OPT_FLAGS_RANDOM 0x00000010 /* Randomize */ +#define OPT_FLAGS_SET 0x00000020 /* Set if user specifies stress procs */ +#define OPT_FLAGS_KEEP_NAME 0x00000040 /* Keep stress names to stress-ng */ +#define OPT_FLAGS_UTIME_FSYNC 0x00000080 /* fsync after utime modification */ +#define OPT_FLAGS_METRICS_BRIEF 0x00000100 /* dump brief metrics */ +#define OPT_FLAGS_VERIFY 0x00000200 /* verify mode */ +#define OPT_FLAGS_MMAP_MADVISE 0x00000400 /* enable random madvise settings */ +#define OPT_FLAGS_MMAP_MINCORE 0x00000800 /* mincore force pages into mem */ +#define OPT_FLAGS_TIMES 0x00001000 /* user/system time summary */ +#define OPT_FLAGS_CACHE_FLUSH 0x00004000 /* cache flush */ +#define OPT_FLAGS_CACHE_FENCE 0x00008000 /* cache fence */ +#define OPT_FLAGS_CACHE_MASK (OPT_FLAGS_CACHE_FLUSH | OPT_FLAGS_CACHE_FENCE) +#define OPT_FLAGS_MMAP_FILE 0x00010000 /* mmap onto a file */ +#define OPT_FLAGS_MMAP_ASYNC 0x00020000 /* mmap onto a file */ +#define OPT_FLAGS_MMAP_MPROTECT 0x00040000 /* mmap mprotect enabled */ +#define OPT_FLAGS_LOCKF_NONBLK 0x00080000 /* Non-blocking lockf */ +#define OPT_FLAGS_MINCORE_RAND 0x00100000 /* mincore randomize */ +#define OPT_FLAGS_BRK_NOTOUCH 0x00200000 /* brk, don't touch page */ +#define OPT_FLAGS_HDD_SYNC 0x00400000 /* HDD O_SYNC */ +#define OPT_FLAGS_HDD_DSYNC 0x00800000 /* HDD O_DYNC */ +#define OPT_FLAGS_HDD_DIRECT 0x01000000 /* HDD O_DIRECT */ +#define OPT_FLAGS_HDD_NOATIME 0x02000000 /* HDD O_NOATIME */ /* Stressor classes */ #define CLASS_CPU 0x00000001 /* CPU only */ @@ -125,13 +95,20 @@ #define CLASS_INTERRUPT 0x00000080 /* interrupt floods */ #define CLASS_OS 0x00000100 /* generic OS tests */ +/* debug output bitmasks */ +#define PR_ERROR 0x10000000 /* Print errors */ +#define PR_INFO 0x20000000 /* Print info */ +#define PR_DEBUG 0x40000000 /* Print debug */ +#define PR_FAIL 0x80000000 /* Print test failure message */ +#define PR_ALL (PR_ERROR | PR_INFO | PR_DEBUG | PR_FAIL) + /* Large prime to stride around large VM regions */ #define PRIME_64 (0x8f0000000017116dULL) /* Logging helpers */ -extern int print(FILE *fp, const uint64_t flag, +extern int print(FILE *fp, const int flag, const char *const fmt, ...) __attribute__((format(printf, 3, 4))); -extern void pr_failed(const uint64_t flag, const char *name, const char *what, const int err); +extern void pr_failed(const int flag, const char *name, const char *what); #define pr_dbg(fp, fmt, args...) print(fp, PR_DEBUG, fmt, ## args) #define pr_inf(fp, fmt, args...) print(fp, PR_INFO, fmt, ## args) @@ -139,9 +116,8 @@ #define pr_fail(fp, fmt, args...) print(fp, PR_FAIL, fmt, ## args) #define pr_tidy(fp, fmt, args...) print(fp, opt_sigint ? PR_INFO : PR_DEBUG, fmt, ## args) -#define pr_failed_err(name, what) pr_failed(PR_FAIL | PR_ERROR, name, what, errno) -#define pr_failed_errno(name, what, e) pr_failed(PR_FAIL | PR_ERROR, name, what, e) -#define pr_failed_dbg(name, what) pr_failed(PR_DEBUG, name, what, errno) +#define pr_failed_err(name, what) pr_failed(PR_ERROR, name, what) +#define pr_failed_dbg(name, what) pr_failed(PR_DEBUG, name, what) #define ABORT_FAILURES (5) @@ -169,7 +145,7 @@ #define DEFAULT_BSEARCH_SIZE (64 * KB) #define MIN_DENTRIES (1) -#define MAX_DENTRIES (1000000) +#define MAX_DENTRIES (100000000) #define DEFAULT_DENTRIES (2048) #define MIN_EPOLL_PORT (1024) @@ -184,10 +160,6 @@ #define MAX_HDD_WRITE_SIZE (4 * MB) #define DEFAULT_HDD_WRITE_SIZE (64 * 1024) -#define MIN_FALLOCATE_BYTES (1 * MB) -#define MAX_FALLOCATE_BYTES (2 * GB) -#define DEFAULT_FALLOCATE_BYTES (1 * GB) - #define MIN_FIFO_READERS (1) #define MAX_FIFO_READERS (64) #define DEFAULT_FIFO_READERS (4) @@ -213,11 +185,11 @@ #define DEFAULT_HSEARCH_SIZE (8 * KB) #define MIN_LEASE_BREAKERS (1) -#define MAX_LEASE_BREAKERS (64) +#define MAX_LEASE_BREAKERS (16) #define DEFAULT_LEASE_BREAKERS (1) #define MIN_LSEARCH_SIZE (1 * KB) -#define MAX_LSEARCH_SIZE (1 * MB) +#define MAX_LSEARCH_SIZE (4 * MB) #define DEFAULT_LSEARCH_SIZE (8 * KB) #define MIN_MALLOC_BYTES (1 * KB) @@ -228,14 +200,6 @@ #define MAX_MALLOC_MAX (256 * 1024) #define DEFAULT_MALLOC_MAX (64 * KB) -#define MIN_MALLOC_THRESHOLD (1) -#define MAX_MALLOC_THRESHOLD (256 * MB) -#define DEFAULT_MALLOC_THRESHOLD (128 * KB) - -#define MIN_MATRIX_SIZE (16) -#define MAX_MATRIX_SIZE (4096) -#define DEFAULT_MATRIX_SIZE (256) - #define MIN_MMAP_BYTES (4 * KB) #define MAX_MMAP_BYTES (1 * GB) #define DEFAULT_MMAP_BYTES (256 * MB) @@ -246,10 +210,10 @@ #define MIN_PTHREAD (1) #define MAX_PTHREAD (30000) -#define DEFAULT_PTHREAD (1024) +#define DEFAULT_PTHREAD (16) #define MIN_QSORT_SIZE (1 * KB) -#define MAX_QSORT_SIZE (4 * MB) +#define MAX_QSORT_SIZE (64 * MB) #define DEFAULT_QSORT_SIZE (256 * KB) #define MIN_SENDFILE_SIZE (1 * KB) @@ -339,7 +303,7 @@ #define STRESS_X86 1 #endif -#if defined(__GNUC__) && defined(__GNUC_MINOR__) && \ +#if defined(__GNUC__) && defined (__GNUC_MINOR__) && \ (__GNUC__ >= 4) && (__GNUC_MINOR__ >= 6) #define STRESS_VECTOR 1 #endif @@ -353,23 +317,6 @@ #define STRESS_INT128 1 #endif -#if defined(__linux__) -#define STRESS_IONICE -#endif - -#if (_BSD_SOURCE || _SVID_SOURCE) && !defined(__gnu_hurd__) -#define STRESS_PAGE_IN -#endif - -#if defined(__linux__) -#define STRESS_IOPRIO -#endif - -#if defined(__GNUC__) && defined(__linux__) -#define STRESS_MALLOPT -#endif - - /* stress process prototype */ typedef int (*stress_func)(uint64_t *const counter, const uint32_t instance, const uint64_t max_ops, const char *name); @@ -423,14 +370,11 @@ /* Stress tests */ typedef enum { - STRESS_START = -1, #if defined(__linux__) - __STRESS_AFFINITY, -#define STRESS_AFFINITY __STRESS_AFFINITY + STRESS_AFFINITY = 0, #endif #if defined(__linux__) - __STRESS_AIO, -#define STRESS_AIO __STRESS_AIO + STRESS_AIO, #endif STRESS_BRK, STRESS_BSEARCH, @@ -438,24 +382,20 @@ STRESS_CACHE, STRESS_CHMOD, #if _POSIX_C_SOURCE >= 199309L - __STRESS_CLOCK, -#define STRESS_CLOCK __STRESS_CLOCK + STRESS_CLOCK, #endif STRESS_CPU, STRESS_DENTRY, STRESS_DIR, STRESS_DUP, #if defined(__linux__) - __STRESS_EPOLL, -#define STRESS_EPOLL __STRESS_EPOLL + STRESS_EPOLL, #endif #if defined(__linux__) - __STRESS_EVENTFD, -#define STRESS_EVENTFD __STRESS_EVENTFD + STRESS_EVENTFD, #endif #if _XOPEN_SOURCE >= 600 || _POSIX_C_SOURCE >= 200112L - __STRESS_FALLOCATE, -#define STRESS_FALLOCATE __STRESS_FALLOCATE + STRESS_FALLOCATE, #endif STRESS_FAULT, STRESS_FIFO, @@ -463,53 +403,39 @@ STRESS_FORK, STRESS_FSTAT, #if defined(__linux__) - __STRESS_FUTEX, -#define STRESS_FUTEX __STRESS_FUTEX + STRESS_FUTEX, #endif STRESS_GET, STRESS_HDD, STRESS_HSEARCH, #if defined(__linux__) - __STRESS_INOTIFY, -#define STRESS_INOTIFY __STRESS_INOTIFY + STRESS_INOTIFY, #endif STRESS_IOSYNC, -#if defined(__linux__) && defined(__NR_kcmp) - __STRESS_KCMP, -#define STRESS_KCMP __STRESS_KCMP -#endif STRESS_KILL, #if defined(F_SETLEASE) && defined(F_WRLCK) && defined(F_UNLCK) - __STRESS_LEASE, -#define STRESS_LEASE __STRESS_LEASE + STRESS_LEASE, #endif STRESS_LINK, #if _BSD_SOURCE || _SVID_SOURCE || _XOPEN_SOURCE >= 500 || \ (_XOPEN_SOURCE && _XOPEN_SOURCE_EXTENDED) - __STRESS_LOCKF, -#define STRESS_LOCKF __STRESS_LOCKF + STRESS_LOCKF, #endif - STRESS_LONGJMP, STRESS_LSEARCH, STRESS_MALLOC, - STRESS_MATRIX, STRESS_MEMCPY, #if (_BSD_SOURCE || _SVID_SOURCE) && !defined(__gnu_hurd__) - __STRESS_MINCORE, -#define STRESS_MINCORE __STRESS_MINCORE + STRESS_MINCORE, #endif STRESS_MMAP, #if defined(__linux__) - __STRESS_MREMAP, -#define STRESS_MREMAP __STRESS_MREMAP + STRESS_MREMAP, #endif #if !defined(__gnu_hurd__) - __STRESS_MSG, -#define STRESS_MSG __STRESS_MSG + STRESS_MSG, #endif #if defined(__linux__) - __STRESS_MQ, -#define STRESS_MQ __STRESS_MQ + STRESS_MQ, #endif STRESS_NICE, STRESS_NULL, @@ -517,84 +443,68 @@ STRESS_PIPE, STRESS_POLL, #if defined(__linux__) - __STRESS_PROCFS, -#define STRESS_PROCFS __STRESS_PROCFS + STRESS_PROCFS, #endif STRESS_PTHREAD, STRESS_QSORT, -#if defined(STRESS_X86) && !defined(__OpenBSD__) - __STRESS_RDRAND, -#define STRESS_RDRAND __STRESS_RDRAND +#if defined(STRESS_X86) + STRESS_RDRAND, #endif STRESS_RENAME, STRESS_SEEK, STRESS_SEMAPHORE_POSIX, #if !defined(__gnu_hurd__) - __STRESS_SEMAPHORE_SYSV, -#define STRESS_SEMAPHORE_SYSV __STRESS_SEMAPHORE_SYSV + STRESS_SEMAPHORE_SYSV, #endif #if defined(__linux__) - __STRESS_SENDFILE, -#define STRESS_SENDFILE __STRESS_SENDFILE + STRESS_SENDFILE, #endif STRESS_SHM_SYSV, #if defined(__linux__) - __STRESS_SIGFD, -#define STRESS_SIGFD __STRESS_SIGFD + STRESS_SIGFD, #endif STRESS_SIGFPE, #if _POSIX_C_SOURCE >= 199309L && !defined(__gnu_hurd__) - __STRESS_SIGQUEUE, -#define STRESS_SIGQUEUE __STRESS_SIGQUEUE + STRESS_SIGQUEUE, #endif STRESS_SIGSEGV, STRESS_SOCKET, #if defined(__linux__) - __STRESS_SPLICE, -#define STRESS_SPLICE __STRESS_SPLICE + STRESS_SPLICE, #endif STRESS_STACK, STRESS_SWITCH, STRESS_SYMLINK, STRESS_SYSINFO, #if defined(__linux__) - __STRESS_TIMER, -#define STRESS_TIMER __STRESS_TIMER + STRESS_TIMER, #endif STRESS_TSEARCH, STRESS_UDP, #if defined(__linux__) || defined(__gnu_hurd__) - __STRESS_URANDOM, -#define STRESS_URANDOM __STRESS_URANDOM + STRESS_URANDOM, #endif STRESS_UTIME, #if defined(STRESS_VECTOR) - __STRESS_VECMATH, -#define STRESS_VECMATH __STRESS_VECMATH + STRESS_VECMATH, #endif #if _BSD_SOURCE || \ (_XOPEN_SOURCE >= 500 || _XOPEN_SOURCE && _XOPEN_SOURCE_EXTENDED) && \ !(_POSIX_C_SOURCE >= 200809L || _XOPEN_SOURCE >= 700) - __STRESS_VFORK, -#define STRESS_VFORK __STRESS_VFORK + STRESS_VFORK, #endif STRESS_VM, -#if defined(__linux__) && \ - defined(__NR_process_vm_readv) && defined(__NR_process_vm_writev) - __STRESS_VM_RW, -#define STRESS_VM_RW __STRESS_VM_RW +#if defined(__linux__) + STRESS_VM_RW, #endif #if defined(__linux__) - __STRESS_VM_SPLICE, -#define STRESS_VM_SPLICE __STRESS_VM_SPLICE + STRESS_VM_SPLICE, #endif #if !defined(__gnu_hurd__) && !defined(__NetBSD__) - __STRESS_WAIT, -#define STRESS_WAIT __STRESS_WAIT + STRESS_WAIT, #endif -#if defined(_POSIX_PRIORITY_SCHEDULING) - __STRESS_YIELD, -#define STRESS_YIELD __STRESS_YIELD +#if defined (_POSIX_PRIORITY_SCHEDULING) + STRESS_YIELD, #endif STRESS_ZERO, /* STRESS_MAX must be last one */ @@ -613,7 +523,7 @@ OPT_HDD = 'd', OPT_DENTRY = 'D', OPT_FORK = 'f', -#if defined(STRESS_FALLOCATE) +#if _XOPEN_SOURCE >= 600 || _POSIX_C_SOURCE >= 200112L OPT_FALLOCATE = 'F', #endif OPT_IOSYNC = 'i', @@ -632,10 +542,10 @@ OPT_SWITCH = 's', OPT_SOCKET = 'S', OPT_TIMEOUT = 't', -#if defined(STRESS_TIMER) +#if defined (__linux__) OPT_TIMER = 'T', #endif -#if defined(STRESS_URANDOM) +#if defined (__linux__) || defined(__gnu_hurd__) OPT_URANDOM = 'u', #endif OPT_VERBOSE = 'v', @@ -644,22 +554,17 @@ /* Long options only */ - OPT_LONG_OPS_START = 0x7f, - -#if defined(STRESS_AFFINITY) - OPT_AFFINITY, +#if defined(__linux__) + OPT_AFFINITY = 0x80, OPT_AFFINITY_OPS, OPT_AFFINITY_RAND, #endif - OPT_AGGRESSIVE, - -#if defined(STRESS_AIO) +#if defined (__linux__) OPT_AIO, OPT_AIO_OPS, OPT_AIO_REQUESTS, #endif - OPT_BRK, OPT_BRK_OPS, OPT_BRK_NOTOUCH, @@ -673,14 +578,13 @@ OPT_CLASS, OPT_CACHE_OPS, - OPT_CACHE_PREFETCH, OPT_CACHE_FLUSH, OPT_CACHE_FENCE, OPT_CHMOD, OPT_CHMOD_OPS, -#if defined(STRESS_CLOCK) +#if _POSIX_C_SOURCE >= 199309L OPT_CLOCK, OPT_CLOCK_OPS, #endif @@ -698,7 +602,7 @@ OPT_DUP, OPT_DUP_OPS, -#if defined(STRESS_EPOLL) +#if defined(__linux__) OPT_EPOLL, OPT_EPOLL_OPS, OPT_EPOLL_PORT, @@ -710,14 +614,13 @@ OPT_HDD_OPS, OPT_HDD_OPTS, -#if defined(STRESS_EVENTFD) +#if defined(__linux__) OPT_EVENTFD, OPT_EVENTFD_OPS, #endif -#if defined(STRESS_FALLOCATE) +#if _XOPEN_SOURCE >= 600 || _POSIX_C_SOURCE >= 200112L OPT_FALLOCATE_OPS, - OPT_FALLOCATE_BYTES, #endif OPT_FAULT, OPT_FAULT_OPS, @@ -746,27 +649,22 @@ OPT_HSEARCH_OPS, OPT_HSEARCH_SIZE, -#if defined(STRESS_INOTIFY) +#if defined (__linux__) OPT_INOTIFY, OPT_INOTIFY_OPS, #endif -#if defined(STRESS_IONICE) +#if defined (__linux__) OPT_IONICE_CLASS, OPT_IONICE_LEVEL, #endif OPT_IOSYNC_OPS, -#if defined(STRESS_KCMP) - OPT_KCMP, - OPT_KCMP_OPS, -#endif - OPT_KILL, OPT_KILL_OPS, -#if defined(STRESS_LEASE) +#if defined(F_SETLEASE) && defined(F_WRLCK) && defined(F_UNLCK) OPT_LEASE, OPT_LEASE_OPS, OPT_LEASE_BREAKERS, @@ -775,15 +673,13 @@ OPT_LINK, OPT_LINK_OPS, -#if defined(STRESS_LOCKF) +#if _BSD_SOURCE || _SVID_SOURCE || _XOPEN_SOURCE >= 500 || \ + (_XOPEN_SOURCE && _XOPEN_SOURCE_EXTENDED) OPT_LOCKF, OPT_LOCKF_OPS, OPT_LOCKF_NONBLOCK, #endif - OPT_LONGJMP, - OPT_LONGJMP_OPS, - OPT_LSEARCH, OPT_LSEARCH_OPS, OPT_LSEARCH_SIZE, @@ -792,30 +688,18 @@ OPT_MALLOC_OPS, OPT_MALLOC_BYTES, OPT_MALLOC_MAX, -#if defined(STRESS_MALLOPT) - OPT_MALLOC_THRESHOLD, -#endif - - OPT_MATRIX, - OPT_MATRIX_OPS, - OPT_MATRIX_SIZE, - OPT_MATRIX_METHOD, - - OPT_MAXIMIZE, OPT_MEMCPY, OPT_MEMCPY_OPS, OPT_METRICS_BRIEF, -#if defined(STRESS_MINCORE) +#if (_BSD_SOURCE || _SVID_SOURCE) && !defined(__gnu_hurd__) OPT_MINCORE, OPT_MINCORE_OPS, OPT_MINCORE_RAND, #endif - OPT_MINIMIZE, - OPT_MMAP, OPT_MMAP_OPS, OPT_MMAP_BYTES, @@ -823,7 +707,7 @@ OPT_MMAP_ASYNC, OPT_MMAP_MPROTECT, -#if defined(STRESS_MREMAP) +#if defined(__linux__) OPT_MREMAP, OPT_MREMAP_OPS, OPT_MREMAP_BYTES, @@ -832,7 +716,7 @@ OPT_MSG, OPT_MSG_OPS, -#if defined(STRESS_MQ) +#if defined(__linux__) OPT_MQ, OPT_MQ_OPS, OPT_MQ_SIZE, @@ -848,7 +732,7 @@ OPT_OPEN_OPS, -#if defined(STRESS_PAGE_IN) +#if (_BSD_SOURCE || _SVID_SOURCE) && !defined(__gnu_hurd__) OPT_PAGE_IN, #endif @@ -856,10 +740,8 @@ OPT_POLL_OPS, -#if defined(STRESS_PROCFS) OPT_PROCFS, OPT_PROCFS_OPS, -#endif OPT_PTHREAD, OPT_PTHREAD_OPS, @@ -869,10 +751,8 @@ OPT_QSORT_OPS, OPT_QSORT_INTEGERS, -#if defined(STRESS_RDRAND) OPT_RDRAND, OPT_RDRAND_OPS, -#endif OPT_RENAME_OPS, @@ -883,17 +763,15 @@ OPT_SEEK_OPS, OPT_SEEK_SIZE, -#if defined(STRESS_SENDFILE) OPT_SENDFILE, OPT_SENDFILE_OPS, OPT_SENDFILE_SIZE, -#endif OPT_SEMAPHORE_POSIX, OPT_SEMAPHORE_POSIX_OPS, OPT_SEMAPHORE_POSIX_PROCS, -#if defined(STRESS_SEMAPHORE_SYSV) +#if !defined(__gnu_hurd__) OPT_SEMAPHORE_SYSV, OPT_SEMAPHORE_SYSV_OPS, OPT_SEMAPHORE_SYSV_PROCS, @@ -906,10 +784,8 @@ OPT_SEQUENTIAL, -#if defined(STRESS_SIGFD) OPT_SIGFD, OPT_SIGFD_OPS, -#endif OPT_SIGFPE, OPT_SIGFPE_OPS, @@ -917,7 +793,7 @@ OPT_SIGSEGV, OPT_SIGSEGV_OPS, -#if defined(STRESS_SIGQUEUE) +#if _POSIX_C_SOURCE >= 199309L OPT_SIGQUEUE, OPT_SIGQUEUE_OPS, #endif @@ -928,7 +804,7 @@ OPT_SWITCH_OPS, -#if defined(STRESS_SPLICE) +#if defined(__linux__) OPT_SPLICE, OPT_SPLICE_OPS, OPT_SPLICE_BYTES, @@ -936,7 +812,6 @@ OPT_STACK, OPT_STACK_OPS, - OPT_STACK_FILL, OPT_SYMLINK, OPT_SYMLINK_OPS, @@ -944,9 +819,7 @@ OPT_SYSINFO, OPT_SYSINFO_OPS, - OPT_SYSLOG, - -#if defined(STRESS_TIMER) +#if defined (__linux__) OPT_TIMER_OPS, OPT_TIMER_FREQ, #endif @@ -962,21 +835,23 @@ OPT_UDP_PORT, OPT_UDP_DOMAIN, -#if defined(STRESS_URANDOM) +#if defined (__linux__) || defined(__gnu_hurd__) OPT_URANDOM_OPS, #endif OPT_UTIME, OPT_UTIME_OPS, OPT_UTIME_FSYNC, -#if defined(STRESS_VECMATH) +#if defined(STRESS_VECTOR) OPT_VECMATH, OPT_VECMATH_OPS, #endif OPT_VERIFY, -#if defined(STRESS_VFORK) +#if _BSD_SOURCE || \ + (_XOPEN_SOURCE >= 500 || _XOPEN_SOURCE && _XOPEN_SOURCE_EXTENDED) && \ + !(_POSIX_C_SOURCE >= 200809L || _XOPEN_SOURCE >= 700) OPT_VFORK, OPT_VFORK_OPS, OPT_VFORK_MAX, @@ -994,24 +869,24 @@ OPT_VM_OPS, OPT_VM_METHOD, -#if defined(STRESS_VM_RW) +#if defined(__linux__) OPT_VM_RW, OPT_VM_RW_OPS, OPT_VM_RW_BYTES, #endif -#if defined(STRESS_VM_SPLICE) +#if defined(__linux__) OPT_VM_SPLICE, OPT_VM_SPLICE_OPS, OPT_VM_SPLICE_BYTES, #endif -#if defined(STRESS_WAIT) +#if !defined(__gnu_hurd__) && !defined(__NetBSD__) OPT_WAIT, OPT_WAIT_OPS, #endif -#if defined(STRESS_YIELD) +#if defined (_POSIX_PRIORITY_SCHEDULING) OPT_YIELD_OPS, #endif @@ -1045,8 +920,8 @@ extern const char *app_name; /* Name of application */ extern shared_t *shared; /* shared memory */ extern uint64_t opt_timeout; /* timeout in seconds */ -extern uint64_t opt_flags; /* option flags */ -extern int32_t opt_sequential; /* Number of sequential iterations */ +extern int32_t opt_flags; /* option flags */ +extern uint64_t opt_sequential; /* Number of sequential iterations */ extern volatile bool opt_do_run; /* false to exit stressor */ extern volatile bool opt_sigint; /* true if stopped by SIGINT */ extern mwc_t __mwc; /* internal mwc random state */ @@ -1082,8 +957,8 @@ #else -#define clflush(ptr) do { } while (0) /* No-op */ -#define mfence() do { } while (0) /* No-op */ +#define clflush(ptr) /* No-op */ +#define mfence() /* No-op */ #endif @@ -1108,9 +983,10 @@ extern double time_now(void); /* Misc settings helpers */ -extern void set_oom_adjustment(const char *name, const bool killable); +extern void set_oom_adjustment(const char *name, bool killable); extern void set_sched(const int sched, const int sched_priority); extern void set_iopriority(const int class, const int level); +extern void set_oom_adjustment(const char *name, bool killable); extern void set_coredump(const char *name); extern void set_proc_name(const char *name); @@ -1136,8 +1012,8 @@ extern void set_max_limits(void); /* Memory tweaking */ -extern int madvise_random(void *addr, const size_t length); -extern int mincore_touch_pages(void *buf, const size_t buf_len); +extern int madvise_random(void *addr, size_t length); +extern int mincore_touch_pages(void *buf, size_t buf_len); /* Mounts */ extern int mount_add(char *mnts[], const int max, int *n, const char *name); @@ -1169,7 +1045,6 @@ extern int stress_set_dentry_order(const char *optarg); extern void stress_set_epoll_port(const char *optarg); extern int stress_set_epoll_domain(const char *optarg); -extern void stress_set_fallocate_bytes(const char *optarg); extern void stress_set_fifo_readers(const char *optarg); extern void stress_set_fork_max(const char *optarg); extern void stress_set_fstat_dir(const char *optarg); @@ -1181,15 +1056,11 @@ extern void stress_set_lsearch_size(const char *optarg); extern void stress_set_malloc_bytes(const char *optarg); extern void stress_set_malloc_max(const char *optarg); -extern void stress_set_malloc_threshold(const char *optarg); -extern int stress_set_matrix_method(const char *name); -extern void stress_set_matrix_size(const char *optarg); extern void stress_set_mmap_bytes(const char *optarg); extern void stress_set_mremap_bytes(const char *optarg); extern void stress_set_mq_size(const char *optarg); extern void stress_set_pthread_max(const char *optarg); extern void stress_set_qsort_size(const void *optarg); -extern int stress_rdrand_supported(void); extern void stress_set_seek_size(const char *optarg); extern void stress_set_sendfile_size(const char *optarg); extern void stress_set_semaphore_posix_procs(const char *optarg); @@ -1242,15 +1113,12 @@ STRESS(stress_get); STRESS(stress_inotify); STRESS(stress_iosync); -STRESS(stress_kcmp); STRESS(stress_kill); STRESS(stress_lease); STRESS(stress_link); STRESS(stress_lockf); -STRESS(stress_longjmp); STRESS(stress_lsearch); STRESS(stress_malloc); -STRESS(stress_matrix); STRESS(stress_memcpy); STRESS(stress_mincore); STRESS(stress_mmap); diff -Nru stress-ng-0.03.18/stress-pipe.c stress-ng-0.03.15/stress-pipe.c --- stress-ng-0.03.18/stress-pipe.c 2015-02-17 18:29:01.000000000 +0000 +++ stress-ng-0.03.15/stress-pipe.c 2015-02-09 23:44:46.000000000 +0000 @@ -129,7 +129,7 @@ if (write(pipefds[1], buf, sizeof(buf)) <= 0) pr_failed_dbg(name, "termination write"); (void)kill(pid, SIGKILL); - (void)waitpid(pid, &status, 0); + waitpid(pid, &status, 0); } return EXIT_SUCCESS; } diff -Nru stress-ng-0.03.18/stress-procfs.c stress-ng-0.03.15/stress-procfs.c --- stress-ng-0.03.18/stress-procfs.c 2015-02-17 18:29:01.000000000 +0000 +++ stress-ng-0.03.15/stress-procfs.c 2015-02-09 23:44:46.000000000 +0000 @@ -24,10 +24,6 @@ */ #define _GNU_SOURCE -#include "stress-ng.h" - -#if defined(STRESS_PROCFS) - #include #include #include @@ -37,8 +33,11 @@ #include #include +#include "stress-ng.h" + #define PROC_BUF_SZ (4096) +#if defined(__linux__) /* * stress_proc_read() * read a proc file diff -Nru stress-ng-0.03.18/stress-pthread.c stress-ng-0.03.15/stress-pthread.c --- stress-ng-0.03.18/stress-pthread.c 2015-02-17 18:29:01.000000000 +0000 +++ stress-ng-0.03.15/stress-pthread.c 2015-02-09 23:44:46.000000000 +0000 @@ -37,7 +37,6 @@ #include "stress-ng.h" static uint64_t opt_pthread_max = DEFAULT_PTHREAD; -static bool set_pthread_max = false; static pthread_cond_t cond = PTHREAD_COND_INITIALIZER; static pthread_mutex_t mutex = PTHREAD_MUTEX_INITIALIZER; static bool thread_terminate; @@ -46,7 +45,6 @@ void stress_set_pthread_max(const char *optarg) { - set_pthread_max = true; opt_pthread_max = get_uint64_byte(optarg); check_range("pthread-max", opt_pthread_max, MIN_PTHREAD, MAX_PTHREAD); @@ -71,7 +69,6 @@ uint8_t stack[SIGSTKSZ]; stack_t ss; static void *nowt = NULL; - int ret; (void)ctxt; @@ -98,15 +95,13 @@ /* * Bump count of running threads */ - ret = pthread_mutex_lock(&mutex); - if (ret) { - pr_failed_errno("pthread", "mutex lock", ret); + if (pthread_mutex_lock(&mutex)) { + pr_failed_err("pthread", "mutex lock"); goto die; } pthread_count++; - ret = pthread_mutex_unlock(&mutex); - if (ret) { - pr_failed_errno("pthread", "mutex unlock", ret); + if (pthread_mutex_unlock(&mutex)) { + pr_failed_err("pthread", "mutex unlock"); goto die; } @@ -114,21 +109,19 @@ * Wait for controlling thread to * indicate it is time to die */ - ret = pthread_mutex_lock(&mutex); - if (ret) { - pr_failed_errno("pthread", "mutex unlock", ret); + if (pthread_mutex_lock(&mutex)) { + pr_failed_err("pthread", "mutex unlock"); goto die; } while (!thread_terminate) { - ret = pthread_cond_wait(&cond, &mutex); - if (ret) { - pr_failed_errno("pthread", "pthread condition wait", ret); + if (pthread_cond_wait(&cond, &mutex)) { + pr_failed_err("pthread", "pthread condition wait"); break; } } - ret = pthread_mutex_unlock(&mutex); - if (ret) - pr_failed_errno("pthread", "mutex unlock", ret); + if (pthread_mutex_unlock(&mutex)) { + pr_failed_err("pthread", "mutex unlock"); + } die: return &nowt; } @@ -149,31 +142,22 @@ (void)instance; - if (!set_pthread_max) { - if (opt_flags & OPT_FLAGS_MAXIMIZE) - opt_pthread_max = MAX_PTHREAD; - if (opt_flags & OPT_FLAGS_MINIMIZE) - opt_pthread_max = MIN_PTHREAD; - } - sigfillset(&set); do { uint64_t i, j; - int ret; thread_terminate = false; pthread_count = 0; for (i = 0; (i < opt_pthread_max) && (!max_ops || *counter < max_ops); i++) { - ret = pthread_create(&pthreads[i], NULL, stress_pthread_func, NULL); - if (ret) { + if (pthread_create(&pthreads[i], NULL, stress_pthread_func, NULL)) { /* Out of resources, don't try any more */ - if (ret == EAGAIN) { + if (errno == EAGAIN) { limited++; break; } /* Something really unexpected */ - pr_failed_errno(name, "pthread create", ret); + pr_failed_err(name, "pthread create"); ok = false; break; } @@ -190,16 +174,14 @@ for (j = 0; j < 1000; j++) { bool all_running = false; - ret = pthread_mutex_lock(&mutex); - if (ret) { - pr_failed_errno(name, "mutex lock", ret); + if (pthread_mutex_lock(&mutex)) { + pr_failed_err(name, "mutex lock"); ok = false; goto reap; } all_running = (pthread_count == i); - ret = pthread_mutex_unlock(&mutex); - if (ret) { - pr_failed_errno(name, "mutex unlock", ret); + if (pthread_mutex_unlock(&mutex)) { + pr_failed_err(name, "mutex unlock"); ok = false; goto reap; } @@ -208,29 +190,25 @@ break; } - ret = pthread_mutex_lock(&mutex); - if (ret) { - pr_failed_errno(name, "mutex lock", ret); + if (pthread_mutex_lock(&mutex)) { + pr_failed_err(name, "mutex lock"); ok = false; goto reap; } thread_terminate = true; - ret = pthread_cond_broadcast(&cond); - if (ret) { - pr_failed_errno(name, "pthread condition broadcast", ret); + if (pthread_cond_broadcast(&cond)) { + pr_failed_err(name, "pthread condition broadcast"); ok = false; /* fall through and unlock */ } - ret = pthread_mutex_unlock(&mutex); - if (ret) { - pr_failed_errno(name, "mutex unlock", ret); + if (pthread_mutex_unlock(&mutex)) { + pr_failed_err(name, "mutex unlock"); ok = false; } reap: for (j = 0; j < i; j++) { - ret = pthread_join(pthreads[j], NULL); - if (ret) { - pr_failed_errno(name, "pthread join", ret); + if (pthread_join(pthreads[j], NULL)) { + pr_failed_err(name, "pthread join"); ok = false; } } diff -Nru stress-ng-0.03.18/stress-qsort.c stress-ng-0.03.15/stress-qsort.c --- stress-ng-0.03.18/stress-qsort.c 2015-02-17 18:29:01.000000000 +0000 +++ stress-ng-0.03.15/stress-qsort.c 2015-02-09 23:44:46.000000000 +0000 @@ -31,11 +31,9 @@ #include "stress-ng.h" static uint64_t opt_qsort_size = DEFAULT_QSORT_SIZE; -static bool set_qsort_size = false; void stress_set_qsort_size(const void *optarg) { - set_qsort_size = true; opt_qsort_size = get_uint64_byte(optarg); check_range("qsort-size", opt_qsort_size, MIN_QSORT_SIZE, MAX_QSORT_SIZE); @@ -91,18 +89,10 @@ const char *name) { int32_t *data, *ptr; - size_t n, i; + const size_t n = (size_t)opt_qsort_size; + size_t i; (void)instance; - - if (!set_qsort_size) { - if (opt_flags & OPT_FLAGS_MAXIMIZE) - opt_qsort_size = MAX_QSORT_SIZE; - if (opt_flags & OPT_FLAGS_MINIMIZE) - opt_qsort_size = MIN_QSORT_SIZE; - } - n = (size_t)opt_qsort_size; - if ((data = malloc(sizeof(int32_t) * n)) == NULL) { pr_failed_dbg(name, "malloc"); return EXIT_FAILURE; diff -Nru stress-ng-0.03.18/stress-rdrand.c stress-ng-0.03.15/stress-rdrand.c --- stress-ng-0.03.18/stress-rdrand.c 2015-02-17 18:29:01.000000000 +0000 +++ stress-ng-0.03.15/stress-rdrand.c 2015-02-09 23:44:46.000000000 +0000 @@ -24,8 +24,6 @@ */ #define _GNU_SOURCE -#include "stress-ng.h" - #include #include #include @@ -33,39 +31,13 @@ #include #include -#if defined(STRESS_RDRAND) +#include "stress-ng.h" -static bool rdrand_supported = false; +#if defined(STRESS_X86) && !defined(__OpenBSD__) #include /* - * stress_rdrand_supported() - * check if rdrand is supported - */ -int stress_rdrand_supported(void) -{ - uint32_t eax, ebx, ecx, edx; - - /* Intel CPU? */ - __cpuid(0, eax, ebx, ecx, edx); - if (!((memcmp(&ebx, "Genu", 4) == 0) && - (memcmp(&edx, "ineI", 4) == 0) && - (memcmp(&ecx, "ntel", 4) == 0))) { - pr_inf(stderr, "rdrand stressor will be skipped, not a recognised Intel CPU.\n"); - return -1; - } - /* ..and supports rdrand? */ - __cpuid(1, eax, ebx, ecx, edx); - if (!(ecx & 0x40000000)) { - pr_inf(stderr, "rdrand stressor will be skipped, CPU does not support the rdrand instruction.\n"); - return -1; - } - rdrand_supported = true; - return 0; -} - -/* * rdrand64() * read 64 bit random value */ @@ -130,31 +102,37 @@ const uint64_t max_ops, const char *name) { + uint32_t eax, ebx, ecx, edx; + (void)instance; - if (rdrand_supported) { - do { - RDRAND64(); - (*counter)++; - } while (opt_do_run && (!max_ops || *counter < max_ops)); + /* Intel CPU? */ + __cpuid(0, eax, ebx, ecx, edx); + if (!((memcmp(&ebx, "Genu", 4) == 0) && + (memcmp(&edx, "ineI", 4) == 0) && + (memcmp(&ecx, "ntel", 4) == 0))) { + pr_err(stderr, "%s: rdrand test aborted, not a recognised Intel CPU.\n", name); + return EXIT_FAILURE; + } + /* ..and supports rdrand? */ + __cpuid(1, eax, ebx, ecx, edx); + if (!(ecx & 0x40000000)) { + pr_err(stderr, "%s: rdrand test aborted, CPU does not support rdrand instruction.\n", name); + return EXIT_FAILURE; } + + do { + RDRAND64(); + (*counter)++; + } while (opt_do_run && (!max_ops || *counter < max_ops)); + pr_dbg(stderr, "%s: %" PRIu64 " random bits read\n", name, (*counter) * 64 * 32); + return EXIT_SUCCESS; } #else - -/* - * stress_rdrand_supported() - * check if rdrand is supported - */ -int stress_rdrand_supported(void) -{ - pr_inf(stderr, "rdrand stressor will be skipped, CPU does not support the rdrand instruction.\n"); - return -1; -} - /* * stress_rdrand() * no-op for non-intel @@ -168,7 +146,8 @@ (void)counter; (void)instance; (void)max_ops; - (void)name; + + pr_dbg(stderr, "%s: rdrand instruction not supported on this architecture\n", name); return EXIT_SUCCESS; } diff -Nru stress-ng-0.03.18/stress-seek.c stress-ng-0.03.15/stress-seek.c --- stress-ng-0.03.18/stress-seek.c 2015-02-17 18:29:01.000000000 +0000 +++ stress-ng-0.03.15/stress-seek.c 2015-02-09 23:44:46.000000000 +0000 @@ -35,11 +35,9 @@ #include "stress-ng.h" static uint64_t opt_seek_size = DEFAULT_SEEK_SIZE; -static bool set_seek_size = false; void stress_set_seek_size(const char *optarg) { - set_seek_size = true; opt_seek_size = get_uint64_byte(optarg); check_range("seek-size", opt_seek_size, MIN_SEEK_SIZE, MAX_SEEK_SIZE); @@ -55,19 +53,12 @@ const uint64_t max_ops, const char *name) { - uint64_t len, i; + uint64_t i; const pid_t pid = getpid(); int fd, rc = EXIT_FAILURE; char filename[PATH_MAX]; uint8_t buf[512]; - - if (!set_seek_size) { - if (opt_flags & OPT_FLAGS_MAXIMIZE) - opt_seek_size = MAX_SEEK_SIZE; - if (opt_flags & OPT_FLAGS_MINIMIZE) - opt_seek_size = MIN_SEEK_SIZE; - } - len = opt_seek_size - sizeof(buf); + uint64_t len = opt_seek_size - sizeof(buf); if (stress_temp_dir_mk(name, pid, instance) < 0) return EXIT_FAILURE; diff -Nru stress-ng-0.03.18/stress-sem.c stress-ng-0.03.15/stress-sem.c --- stress-ng-0.03.18/stress-sem.c 2015-02-17 18:29:01.000000000 +0000 +++ stress-ng-0.03.15/stress-sem.c 2015-02-09 23:44:46.000000000 +0000 @@ -37,11 +37,9 @@ #include "stress-ng.h" static uint64_t opt_semaphore_posix_procs = DEFAULT_SEMAPHORE_PROCS; -static bool set_semaphore_posix_procs = false; void stress_set_semaphore_posix_procs(const char *optarg) { - set_semaphore_posix_procs = true; opt_semaphore_posix_procs = get_uint64_byte(optarg); check_range("sem-procs", opt_semaphore_posix_procs, MIN_SEMAPHORE_PROCS, MAX_SEMAPHORE_PROCS); @@ -145,13 +143,6 @@ (void)instance; - if (!set_semaphore_posix_procs) { - if (opt_flags & OPT_FLAGS_MAXIMIZE) - opt_semaphore_posix_procs = MAX_SEMAPHORE_PROCS; - if (opt_flags & OPT_FLAGS_MINIMIZE) - opt_semaphore_posix_procs = MIN_SEMAPHORE_PROCS; - } - if (!shared->sem_posix_init) { pr_err(stderr, "%s: aborting, semaphore not initialised\n", name); return EXIT_FAILURE; @@ -171,7 +162,7 @@ int status; (void)kill(pids[i], SIGKILL); - (void)waitpid(pids[i], &status, 0); + waitpid(pids[i], &status, 0); } } diff -Nru stress-ng-0.03.18/stress-sem-sysv.c stress-ng-0.03.15/stress-sem-sysv.c --- stress-ng-0.03.18/stress-sem-sysv.c 2015-02-17 18:29:01.000000000 +0000 +++ stress-ng-0.03.15/stress-sem-sysv.c 2015-02-09 23:44:46.000000000 +0000 @@ -24,9 +24,7 @@ */ #define _GNU_SOURCE -#include "stress-ng.h" - -#if defined(STRESS_SEMAPHORE_SYSV) +#if !defined(__gnu_hurd__) #include #include @@ -39,19 +37,12 @@ #include #include -static uint64_t opt_semaphore_sysv_procs = DEFAULT_SEMAPHORE_PROCS; -static bool set_semaphore_sysv_procs = false; +#include "stress-ng.h" -typedef union _semun { - int val; /* Value for SETVAL */ - struct semid_ds *buf; /* Buffer for IPC_STAT, IPC_SET */ - unsigned short *array; /* Array for GETALL, SETALL */ - struct seminfo *__buf; /* Buffer for IPC_INFO (Linux-specific) */ -} semun_t; +static uint64_t opt_semaphore_sysv_procs = DEFAULT_SEMAPHORE_PROCS; void stress_set_semaphore_sysv_procs(const char *optarg) { - set_semaphore_sysv_procs = true; opt_semaphore_sysv_procs = get_uint64_byte(optarg); check_range("sem-procs", opt_semaphore_sysv_procs, MIN_SEMAPHORE_PROCS, MAX_SEMAPHORE_PROCS); @@ -75,10 +66,8 @@ } if (shared->sem_sysv_id >= 0) { - semun_t arg; - - arg.val = 1; - if (semctl(shared->sem_sysv_id, 0, SETVAL, arg) == 0) { + unsigned short semval = 1; + if (semctl(shared->sem_sysv_id, 0, SETVAL, semval) == 0) { shared->sem_sysv_init = true; return; } @@ -184,13 +173,6 @@ (void)instance; - if (!set_semaphore_sysv_procs) { - if (opt_flags & OPT_FLAGS_MAXIMIZE) - opt_semaphore_sysv_procs = MAX_SEMAPHORE_PROCS; - if (opt_flags & OPT_FLAGS_MINIMIZE) - opt_semaphore_sysv_procs = MIN_SEMAPHORE_PROCS; - } - if (!shared->sem_sysv_init) { pr_err(stderr, "%s: aborting, semaphore not initialised\n", name); return EXIT_FAILURE; @@ -209,7 +191,7 @@ int status; (void)kill(pids[i], SIGKILL); - (void)waitpid(pids[i], &status, 0); + waitpid(pids[i], &status, 0); } } diff -Nru stress-ng-0.03.18/stress-sendfile.c stress-ng-0.03.15/stress-sendfile.c --- stress-ng-0.03.18/stress-sendfile.c 2015-02-17 18:29:01.000000000 +0000 +++ stress-ng-0.03.15/stress-sendfile.c 2015-02-09 23:44:46.000000000 +0000 @@ -24,9 +24,7 @@ */ #define _GNU_SOURCE -#include "stress-ng.h" - -#if defined(STRESS_SENDFILE) +#if defined (__linux__) #include #include @@ -38,13 +36,12 @@ #include #include +#include "stress-ng.h" static int64_t opt_sendfile_size = DEFAULT_SENDFILE_SIZE; -static bool set_sendfile_size = false; void stress_set_sendfile_size(const char *optarg) { - set_sendfile_size = true; opt_sendfile_size = get_uint64_byte(optarg); check_range("sendfile-size", opt_sendfile_size, MIN_SENDFILE_SIZE, MAX_SENDFILE_SIZE); @@ -62,17 +59,9 @@ { char filename[PATH_MAX]; int fdin, fdout, ret = EXIT_SUCCESS; - size_t sz; + size_t sz = (size_t)opt_sendfile_size; const pid_t pid = getpid(); - if (!set_sendfile_size) { - if (opt_flags & OPT_FLAGS_MAXIMIZE) - opt_sendfile_size = MAX_SENDFILE_SIZE; - if (opt_flags & OPT_FLAGS_MINIMIZE) - opt_sendfile_size = MIN_SENDFILE_SIZE; - } - sz = (size_t)opt_sendfile_size; - if (stress_temp_dir_mk(name, pid, instance) < 0) return EXIT_FAILURE; diff -Nru stress-ng-0.03.18/stress-shm-sysv.c stress-ng-0.03.15/stress-shm-sysv.c --- stress-ng-0.03.18/stress-shm-sysv.c 2015-02-17 18:29:01.000000000 +0000 +++ stress-ng-0.03.15/stress-shm-sysv.c 2015-02-09 23:44:46.000000000 +0000 @@ -42,13 +42,10 @@ static size_t opt_shm_sysv_bytes = DEFAULT_SHM_SYSV_BYTES; static size_t opt_shm_sysv_segments = DEFAULT_SHM_SYSV_SEGMENTS; -static bool set_shm_sysv_bytes = false; -static bool set_shm_sysv_segments = false; void stress_set_shm_sysv_bytes(const char *optarg) { - set_shm_sysv_bytes = true; opt_shm_sysv_bytes = (size_t)get_uint64_byte(optarg); check_range("shm-sysv-bytes", opt_shm_sysv_bytes, MIN_SHM_SYSV_BYTES, MAX_SHM_SYSV_BYTES); @@ -56,7 +53,6 @@ void stress_set_shm_sysv_segments(const char *optarg) { - opt_shm_sysv_segments = true; opt_shm_sysv_segments = (size_t)get_uint64_byte(optarg); check_range("shm-sysv-segments", opt_shm_sysv_segments, MIN_SHM_SYSV_SEGMENTS, MAX_SHM_SYSV_SEGMENTS); @@ -96,40 +92,26 @@ const char *name) { const size_t page_size = stress_get_pagesize(); - size_t orig_sz, sz = opt_shm_sysv_bytes & ~(page_size - 1); - void *addrs[MAX_SHM_SYSV_SEGMENTS]; - key_t keys[MAX_SHM_SYSV_SEGMENTS]; - int shm_ids[MAX_SHM_SYSV_SEGMENTS]; + size_t sz = opt_shm_sysv_bytes & ~(page_size - 1); + const size_t orig_sz = sz; + void *addrs[opt_shm_sysv_segments]; + key_t keys[opt_shm_sysv_segments]; + int shm_ids[opt_shm_sysv_segments]; int rc = EXIT_SUCCESS; bool ok = true; - ssize_t i; (void)instance; - if (!set_shm_sysv_bytes) { - if (opt_flags & OPT_FLAGS_MAXIMIZE) - opt_shm_sysv_bytes = MAX_SHM_SYSV_BYTES; - if (opt_flags & OPT_FLAGS_MINIMIZE) - opt_shm_sysv_bytes = MIN_SHM_SYSV_BYTES; - } - - if (!set_shm_sysv_segments) { - if (opt_flags & OPT_FLAGS_MAXIMIZE) - opt_shm_sysv_segments = MAX_SHM_SYSV_SEGMENTS; - if (opt_flags & OPT_FLAGS_MINIMIZE) - opt_shm_sysv_segments = MIN_SHM_SYSV_SEGMENTS; - } - orig_sz = sz = opt_shm_sysv_bytes & ~(page_size - 1); - memset(addrs, 0, sizeof(addrs)); memset(keys, 0, sizeof(keys)); - for (i = 0; i < (ssize_t)opt_shm_sysv_segments; i++) - shm_ids[i] = -1; + memset(shm_ids, 0, sizeof(shm_ids)); /* Make sure this is killable by OOM killer */ set_oom_adjustment(name, true); do { + ssize_t i; + for (i = 0; i < (ssize_t)opt_shm_sysv_segments; i++) { int shm_id, count = 0; void *addr; @@ -223,7 +205,7 @@ } } addrs[i] = NULL; - shm_ids[i] = -1; + shm_ids[i] = 0; keys[i] = 0; } } while (ok && opt_do_run && (!max_ops || *counter < max_ops)); diff -Nru stress-ng-0.03.18/stress-sigfd.c stress-ng-0.03.15/stress-sigfd.c --- stress-ng-0.03.18/stress-sigfd.c 2015-02-17 18:29:01.000000000 +0000 +++ stress-ng-0.03.15/stress-sigfd.c 2015-02-09 23:44:46.000000000 +0000 @@ -24,9 +24,7 @@ */ #define _GNU_SOURCE -#include "stress-ng.h" - -#if defined(STRESS_SIGFD) +#if defined(__linux__) #include #include @@ -37,6 +35,8 @@ #include #include +#include "stress-ng.h" + /* * stress_sigfd * stress signalfd reads diff -Nru stress-ng-0.03.18/stress-sigq.c stress-ng-0.03.15/stress-sigq.c --- stress-ng-0.03.18/stress-sigq.c 2015-02-17 18:29:01.000000000 +0000 +++ stress-ng-0.03.15/stress-sigq.c 2015-02-09 23:44:46.000000000 +0000 @@ -24,10 +24,6 @@ */ #define _GNU_SOURCE -#include "stress-ng.h" - -#if defined(STRESS_SIGQUEUE) - #include #include #include @@ -36,6 +32,9 @@ #include #include +#include "stress-ng.h" + +#if _POSIX_C_SOURCE >= 199309L && !defined(__gnu_hurd__) static void stress_sigqhandler(int dummy) { (void)dummy; diff -Nru stress-ng-0.03.18/stress-splice.c stress-ng-0.03.15/stress-splice.c --- stress-ng-0.03.18/stress-splice.c 2015-02-17 18:29:01.000000000 +0000 +++ stress-ng-0.03.15/stress-splice.c 2015-02-09 23:44:46.000000000 +0000 @@ -24,10 +24,6 @@ */ #define _GNU_SOURCE -#include "stress-ng.h" - -#if defined(STRESS_SPLICE) - #include #include #include @@ -36,12 +32,14 @@ #include #include +#include "stress-ng.h" + +#if defined (__linux__) + static size_t opt_splice_bytes = DEFAULT_SPLICE_BYTES; -static bool set_splice_bytes = false; void stress_set_splice_bytes(const char *optarg) { - set_splice_bytes = true; opt_splice_bytes = (size_t)get_uint64_byte(optarg); check_range("splice-bytes", opt_splice_bytes, MIN_SPLICE_BYTES, MAX_SPLICE_BYTES); @@ -59,13 +57,6 @@ { int fd_in, fd_out, fds[2]; - if (!set_splice_bytes) { - if (opt_flags & OPT_FLAGS_MAXIMIZE) - opt_splice_bytes = MAX_SPLICE_BYTES; - if (opt_flags & OPT_FLAGS_MINIMIZE) - opt_splice_bytes = MIN_SPLICE_BYTES; - } - (void)instance; if (pipe(fds) < 0) { diff -Nru stress-ng-0.03.18/stress-stack.c stress-ng-0.03.15/stress-stack.c --- stress-ng-0.03.18/stress-stack.c 2015-02-17 18:29:01.000000000 +0000 +++ stress-ng-0.03.15/stress-stack.c 2015-02-09 23:44:46.000000000 +0000 @@ -102,7 +102,7 @@ name, errno, strerror(errno)); (void)kill(pid, SIGTERM); (void)kill(pid, SIGKILL); - (void)waitpid(pid, &status, 0); + waitpid(pid, &status, 0); } else if (WIFSIGNALED(status)) { pr_dbg(stderr, "%s: child died: %d (instance %d)\n", name, WTERMSIG(status), instance); @@ -164,10 +164,7 @@ char *ptr = alloca(256 * KB); /* need this else gcc optimises out the alloca */ - if (opt_flags & OPT_STACK_FILL) - memset(ptr, 0, 256 * KB); - else - *ptr = 0; + *ptr = 0; /* Force gcc to actually do the alloca */ uint64_put((uint64_t)(last_ptr - ptr)); diff -Nru stress-ng-0.03.18/stress-sysinfo.c stress-ng-0.03.15/stress-sysinfo.c --- stress-ng-0.03.18/stress-sysinfo.c 2015-02-17 18:29:01.000000000 +0000 +++ stress-ng-0.03.15/stress-sysinfo.c 2015-02-09 23:44:46.000000000 +0000 @@ -28,7 +28,7 @@ #include #include #include -#if defined(__linux__) +#if defined (__linux__) #include #include #endif @@ -66,14 +66,14 @@ do { struct tms tms_buf; clock_t clk; -#if defined(__linux__) +#if defined (__linux__) int ret; struct sysinfo sysinfo_buf; struct statfs statfs_buf; int i; #endif -#if defined(__linux__) +#if defined (__linux__) ret = sysinfo(&sysinfo_buf); if ((ret < 0) && (opt_flags & OPT_FLAGS_VERIFY)) { pr_fail(stderr, "%s: sysinfo failed: errno=%d (%s)\n", diff -Nru stress-ng-0.03.18/stress-timer.c stress-ng-0.03.15/stress-timer.c --- stress-ng-0.03.18/stress-timer.c 2015-02-17 18:29:01.000000000 +0000 +++ stress-ng-0.03.15/stress-timer.c 2015-02-09 23:44:46.000000000 +0000 @@ -24,20 +24,18 @@ */ #define _GNU_SOURCE -#include "stress-ng.h" - -#if defined(STRESS_TIMER) - #include #include #include #include #include +#include "stress-ng.h" + +#if defined (__linux__) static volatile uint64_t timer_counter = 0; static timer_t timerid; static uint64_t opt_timer_freq; -static bool set_timer_freq = false; /* * stress_set_timer_freq() @@ -45,7 +43,6 @@ */ void stress_set_timer_freq(const char *optarg) { - set_timer_freq = true; opt_timer_freq = get_uint64(optarg); check_range("timer-freq", opt_timer_freq, MIN_TIMER_FREQ, MAX_TIMER_FREQ); @@ -86,18 +83,10 @@ struct sigaction new_action; struct sigevent sev; struct itimerspec timer; - double rate_ns; + const double rate_ns = opt_timer_freq ? 1000000000 / opt_timer_freq : 1000000000; (void)instance; - if (!set_timer_freq) { - if (opt_flags & OPT_FLAGS_MAXIMIZE) - opt_timer_freq = MAX_TIMER_FREQ; - if (opt_flags & OPT_FLAGS_MINIMIZE) - opt_timer_freq = MIN_TIMER_FREQ; - } - rate_ns = opt_timer_freq ? 1000000000 / opt_timer_freq : 1000000000; - new_action.sa_flags = 0; new_action.sa_handler = stress_timer_handler; sigemptyset(&new_action.sa_mask); diff -Nru stress-ng-0.03.18/stress-tsearch.c stress-ng-0.03.15/stress-tsearch.c --- stress-ng-0.03.18/stress-tsearch.c 2015-02-17 18:29:01.000000000 +0000 +++ stress-ng-0.03.15/stress-tsearch.c 2015-02-09 23:44:46.000000000 +0000 @@ -32,7 +32,6 @@ #include "stress-ng.h" static uint64_t opt_tsearch_size = DEFAULT_TSEARCH_SIZE; -static bool set_tsearch_size = false; /* * stress_set_tsearch_size() @@ -40,7 +39,6 @@ */ void stress_set_tsearch_size(const char *optarg) { - set_tsearch_size = true; opt_tsearch_size = get_uint64_byte(optarg); check_range("tsearch-size", opt_tsearch_size, MIN_TSEARCH_SIZE, MAX_TSEARCH_SIZE); @@ -74,18 +72,10 @@ const char *name) { int32_t *data; - size_t i, n; + const size_t n = (size_t)opt_tsearch_size; + size_t i; (void)instance; - - if (!set_tsearch_size) { - if (opt_flags & OPT_FLAGS_MAXIMIZE) - opt_tsearch_size = MAX_TSEARCH_SIZE; - if (opt_flags & OPT_FLAGS_MINIMIZE) - opt_tsearch_size = MIN_TSEARCH_SIZE; - } - n = (size_t)opt_tsearch_size; - if ((data = malloc(sizeof(int32_t) * n)) == NULL) { pr_failed_dbg(name, "malloc"); return EXIT_FAILURE; diff -Nru stress-ng-0.03.18/stress-urandom.c stress-ng-0.03.15/stress-urandom.c --- stress-ng-0.03.18/stress-urandom.c 2015-02-17 18:29:01.000000000 +0000 +++ stress-ng-0.03.15/stress-urandom.c 2015-02-09 23:44:46.000000000 +0000 @@ -24,10 +24,6 @@ */ #define _GNU_SOURCE -#include "stress-ng.h" - -#if defined(STRESS_URANDOM) - #include #include #include @@ -36,6 +32,9 @@ #include #include +#include "stress-ng.h" + +#if defined (__linux__) || defined(__gnu_hurd__) /* * stress_urandom * stress reading of /dev/urandom diff -Nru stress-ng-0.03.18/stress-utime.c stress-ng-0.03.15/stress-utime.c --- stress-ng-0.03.18/stress-utime.c 2015-02-17 18:29:01.000000000 +0000 +++ stress-ng-0.03.15/stress-utime.c 2015-02-09 23:44:46.000000000 +0000 @@ -35,6 +35,7 @@ #include #include + #include "stress-ng.h" /* diff -Nru stress-ng-0.03.18/stress-vecmath.c stress-ng-0.03.15/stress-vecmath.c --- stress-ng-0.03.18/stress-vecmath.c 2015-02-17 18:29:01.000000000 +0000 +++ stress-ng-0.03.15/stress-vecmath.c 2015-02-09 23:44:46.000000000 +0000 @@ -24,15 +24,15 @@ */ #define _GNU_SOURCE -#include "stress-ng.h" - -#if defined(STRESS_VECMATH) - #include #include #include #include +#include "stress-ng.h" + +#if defined(STRESS_VECTOR) + typedef int8_t vint8_t __attribute__ ((vector_size (16))); typedef int16_t vint16_t __attribute__ ((vector_size (16))); typedef int32_t vint32_t __attribute__ ((vector_size (16))); @@ -47,9 +47,6 @@ a = ~a; \ a *= s; \ a ^= c; \ - a <<= 1; \ - b >>= 1; \ - b += c; \ /* * stress_vecmath() diff -Nru stress-ng-0.03.18/stress-vm.c stress-ng-0.03.15/stress-vm.c --- stress-ng-0.03.18/stress-vm.c 2015-02-17 18:29:01.000000000 +0000 +++ stress-ng-0.03.15/stress-vm.c 2015-02-09 23:44:46.000000000 +0000 @@ -49,7 +49,6 @@ static uint64_t opt_vm_hang = DEFAULT_VM_HANG; static size_t opt_vm_bytes = DEFAULT_VM_BYTES; -static bool set_vm_bytes = false; static int opt_vm_flags = 0; /* VM mmap flags */ static stress_vm_stressor_info_t *opt_vm_stressor; @@ -64,7 +63,6 @@ void stress_set_vm_bytes(const char *optarg) { - set_vm_bytes = true; opt_vm_bytes = (size_t)get_uint64_byte(optarg); check_range("vm-bytes", opt_vm_bytes, MIN_VM_BYTES, MAX_VM_BYTES); @@ -1820,18 +1818,9 @@ const bool keep = (opt_flags & OPT_FLAGS_VM_KEEP); const stress_vm_func func = opt_vm_stressor->func; const size_t page_size = stress_get_pagesize(); - size_t buf_sz; + const size_t buf_sz = opt_vm_bytes & ~(page_size - 1); (void)instance; - - if (!set_vm_bytes) { - if (opt_flags & OPT_FLAGS_MAXIMIZE) - opt_vm_bytes = MAX_VM_BYTES; - if (opt_flags & OPT_FLAGS_MINIMIZE) - opt_vm_bytes = MIN_VM_BYTES; - } - buf_sz = opt_vm_bytes & ~(page_size - 1); - again: if (!opt_do_run) return EXIT_SUCCESS; @@ -1848,7 +1837,7 @@ pr_dbg(stderr, "%s: waitpid(): errno=%d (%s)\n", name, errno, strerror(errno)); (void)kill(pid, SIGTERM); (void)kill(pid, SIGKILL); - (void)waitpid(pid, &status, 0); + waitpid(pid, &status, 0); } else if (WIFSIGNALED(status)) { pr_dbg(stderr, "%s: child died: %d (instance %d)\n", name, WTERMSIG(status), instance); diff -Nru stress-ng-0.03.18/stress-vm-rw.c stress-ng-0.03.15/stress-vm-rw.c --- stress-ng-0.03.18/stress-vm-rw.c 2015-02-17 18:29:01.000000000 +0000 +++ stress-ng-0.03.15/stress-vm-rw.c 2015-02-09 23:44:46.000000000 +0000 @@ -24,10 +24,6 @@ */ #define _GNU_SOURCE -#include "stress-ng.h" - -#if defined(STRESS_VM_RW) - #include #include #include @@ -36,20 +32,21 @@ #include #include #include -#include #include +#if defined(__linux__) + +#include "stress-ng.h" + typedef struct { void *addr; /* Buffer to read/write to */ uint8_t val; /* Value to check */ } addr_msg_t; static size_t opt_vm_rw_bytes = DEFAULT_VM_RW_BYTES; -static bool set_vm_rw_bytes = false; void stress_set_vm_rw_bytes(const char *optarg) { - set_vm_rw_bytes = true; opt_vm_rw_bytes = (size_t)get_uint64_byte(optarg); check_range("vm-rw-bytes", opt_vm_rw_bytes, MIN_VM_RW_BYTES, MAX_VM_RW_BYTES); @@ -68,18 +65,10 @@ pid_t pid; int pipe_wr[2], pipe_rd[2]; const size_t page_size = stress_get_pagesize(); - size_t sz; + const size_t sz = opt_vm_rw_bytes & ~(page_size - 1); (void)instance; - if (!set_vm_rw_bytes) { - if (opt_flags & OPT_FLAGS_MAXIMIZE) - opt_vm_rw_bytes = MAX_VM_RW_BYTES; - if (opt_flags & OPT_FLAGS_MINIMIZE) - opt_vm_rw_bytes = MIN_VM_RW_BYTES; - } - sz = opt_vm_rw_bytes & ~(page_size - 1); - if (pipe(pipe_wr) < 0) { pr_failed_dbg(name, "pipe"); return EXIT_FAILURE; diff -Nru stress-ng-0.03.18/stress-vm-splice.c stress-ng-0.03.15/stress-vm-splice.c --- stress-ng-0.03.18/stress-vm-splice.c 2015-02-17 18:29:01.000000000 +0000 +++ stress-ng-0.03.15/stress-vm-splice.c 2015-02-09 23:44:46.000000000 +0000 @@ -24,10 +24,6 @@ */ #define _GNU_SOURCE -#include "stress-ng.h" - -#if defined(STRESS_VM_SPLICE) - #include #include #include @@ -37,12 +33,14 @@ #include #include +#include "stress-ng.h" + +#if defined (__linux__) + static size_t opt_vm_splice_bytes = DEFAULT_VM_SPLICE_BYTES; -static bool set_vm_splice_bytes = false; void stress_set_vm_splice_bytes(const char *optarg) { - set_vm_splice_bytes = true; opt_vm_splice_bytes = (size_t)get_uint64_byte(optarg); check_range("vm-splice-bytes", opt_vm_splice_bytes, MIN_VM_SPLICE_BYTES, MAX_VM_SPLICE_BYTES); @@ -61,18 +59,10 @@ int fd, fds[2]; uint8_t *buf; const size_t page_size = stress_get_pagesize(); - size_t sz; + const size_t sz = opt_vm_splice_bytes & ~(page_size - 1); (void)instance; - if (!set_vm_splice_bytes) { - if (opt_flags & OPT_FLAGS_MAXIMIZE) - opt_vm_splice_bytes = MAX_VM_SPLICE_BYTES; - if (opt_flags & OPT_FLAGS_MINIMIZE) - opt_vm_splice_bytes = MIN_VM_SPLICE_BYTES; - } - sz = opt_vm_splice_bytes & ~(page_size - 1); - buf = mmap(NULL, sz, PROT_READ | PROT_WRITE, MAP_ANONYMOUS | MAP_PRIVATE, -1, 0); if (buf == MAP_FAILED) { pr_failed_dbg(name, "mmap"); diff -Nru stress-ng-0.03.18/stress-wait.c stress-ng-0.03.15/stress-wait.c --- stress-ng-0.03.18/stress-wait.c 2015-02-17 18:29:01.000000000 +0000 +++ stress-ng-0.03.15/stress-wait.c 2015-02-09 23:44:46.000000000 +0000 @@ -24,10 +24,6 @@ */ #define _GNU_SOURCE -#include "stress-ng.h" - -#if defined(STRESS_WAIT) - #include #include #include @@ -38,6 +34,10 @@ #include #include +#include "stress-ng.h" + +#if !defined(__gnu_hurd__) && !defined(__NetBSD__) + #define ABORT_TIMEOUT (2.0) /* @@ -154,7 +154,7 @@ } do { - (void)waitpid(pid_r, &status, WCONTINUED); + waitpid(pid_r, &status, WCONTINUED); if (!opt_do_run) break; if (WIFCONTINUED(status)) @@ -166,7 +166,7 @@ { siginfo_t info; - (void)waitid(P_PID, pid_r, &info, WCONTINUED); + waitid(P_PID, pid_r, &info, WCONTINUED); if (!opt_do_run) break; if (WIFCONTINUED(status)) diff -Nru stress-ng-0.03.18/stress-yield.c stress-ng-0.03.15/stress-yield.c --- stress-ng-0.03.18/stress-yield.c 2015-02-17 18:29:01.000000000 +0000 +++ stress-ng-0.03.15/stress-yield.c 2015-02-09 23:44:46.000000000 +0000 @@ -24,15 +24,14 @@ */ #define _GNU_SOURCE -#include "stress-ng.h" - -#if defined(STRESS_YIELD) - #include #include #include #include + +#if defined(_POSIX_PRIORITY_SCHEDULING) #include +#include "stress-ng.h" /* * stress on sched_yield() diff -Nru stress-ng-0.03.18/syscalls.txt stress-ng-0.03.15/syscalls.txt --- stress-ng-0.03.18/syscalls.txt 2015-02-17 18:29:01.000000000 +0000 +++ stress-ng-0.03.15/syscalls.txt 2015-02-09 23:44:46.000000000 +0000 @@ -15,7 +15,6 @@ epoll_ctl_add epoll epoll_wait epoll eventfd eventfd -fallocate fallocate fchmod chmod fcntl open, lockf flock flock @@ -48,7 +47,6 @@ inotify_add_watch inotify inotify_init inotify inotify_rm_watch inotify -kcmp kcmp kill kill listen sock mkdir dir @@ -75,7 +73,6 @@ nanosleep timer open dentry open open -pause kcmp pipe pipe pipe switch poll poll