import rteval-loads-1.4-13.el8

This commit is contained in:
CentOS Sources 2021-10-06 14:29:16 -04:00 committed by Stepan Oksanichenko
parent 6cdba5f692
commit c31b07cdde
31 changed files with 31 additions and 2497 deletions

2
.gitignore vendored
View File

@ -1,2 +1,2 @@
SOURCES/linux-5.7.tar.xz SOURCES/linux-5.7.tar.xz
SOURCES/stress-ng-0.11.10.tar.xz SOURCES/stress-ng-0.12.06.tar.xz

View File

@ -1,2 +1,2 @@
07e40057b78f1c9dd2b042056325d99fcf9f8a08 SOURCES/linux-5.7.tar.xz 07e40057b78f1c9dd2b042056325d99fcf9f8a08 SOURCES/linux-5.7.tar.xz
40fef9cd9129d41165c4beb0308e6d66cd4c006c SOURCES/stress-ng-0.11.10.tar.xz 0437f8abe3edb10b44e2205ad1e9c0187c6e7860 SOURCES/stress-ng-0.12.06.tar.xz

View File

@ -1,350 +0,0 @@
From 0a38b72d2ffb722f08c26dd734baef54ff788fde Mon Sep 17 00:00:00 2001
From: Colin Ian King <colin.king@canonical.com>
Date: Fri, 15 May 2020 23:23:43 +0100
Subject: [PATCH 01/28] stress-hdd: use preadv, preadv2, pwritev, pwritev2
Exercise iovec family of read/write system calls to get more
kernel coverage
Signed-off-by: Colin Ian King <colin.king@canonical.com>
---
Makefile.config | 24 ++++++++++++++++++++
stress-hdd.c | 47 +++++++++++++++++++++++++++++++++++++--
test/test-preadv.c | 52 ++++++++++++++++++++++++++++++++++++++++++++
test/test-preadv2.c | 52 ++++++++++++++++++++++++++++++++++++++++++++
test/test-pwritev.c | 14 +++++++++++-
test/test-pwritev2.c | 50 ++++++++++++++++++++++++++++++++++++++++++
6 files changed, 236 insertions(+), 3 deletions(-)
create mode 100644 test/test-preadv.c
create mode 100644 test/test-preadv2.c
create mode 100644 test/test-pwritev2.c
diff --git a/Makefile.config b/Makefile.config
index 0d306e1fbd32..826cf29e8158 100644
--- a/Makefile.config
+++ b/Makefile.config
@@ -2233,6 +2233,22 @@ $(info autoconfig: using prctl)
endif
endif
+ifndef $(HAVE_PREADV)
+HAVE_PREADV = $(shell $(MAKE) -f Makefile.config --no-print-directory $(HAVE_NOT) TEST_PROG=test-preadv have_test_prog)
+ifeq ($(HAVE_PREADV),1)
+ CONFIG_CFLAGS += -DHAVE_PREADV
+$(info autoconfig: using preadv)
+endif
+endif
+
+ifndef $(HAVE_PREADV2)
+HAVE_PREADV2 = $(shell $(MAKE) -f Makefile.config --no-print-directory $(HAVE_NOT) TEST_PROG=test-preadv2 have_test_prog)
+ifeq ($(HAVE_PREADV2),1)
+ CONFIG_CFLAGS += -DHAVE_PREADV2
+$(info autoconfig: using preadv2)
+endif
+endif
+
ifndef $(HAVE_PRLIMIT)
HAVE_PRLIMIT = $(shell $(MAKE) -f Makefile.config --no-print-directory $(HAVE_NOT) TEST_PROG=test-prlimit have_test_prog)
ifeq ($(HAVE_PRLIMIT),1)
@@ -2297,6 +2313,14 @@ $(info autoconfig: using pwritev)
endif
endif
+ifndef $(HAVE_PWRITEV2)
+HAVE_PWRITEV2 = $(shell $(MAKE) -f Makefile.config --no-print-directory $(HAVE_NOT) TEST_PROG=test-pwritev2 have_test_prog)
+ifeq ($(HAVE_PWRITEV2),1)
+ CONFIG_CFLAGS += -DHAVE_PWRITEV2
+$(info autoconfig: using pwritev2)
+endif
+endif
+
ifndef $(HAVE_RECVMMSG)
HAVE_RECVMMSG = $(shell $(MAKE) -f Makefile.config --no-print-directory $(HAVE_NOT) TEST_PROG=test-recvmmsg have_test_prog)
ifeq ($(HAVE_RECVMMSG),1)
diff --git a/stress-hdd.c b/stress-hdd.c
index 9bdf881e0f2e..a9a9dad53352 100644
--- a/stress-hdd.c
+++ b/stress-hdd.c
@@ -180,6 +180,9 @@ static ssize_t stress_hdd_write(
size_t i;
uint8_t *data = buf;
const uint64_t sz = hdd_write_size / HDD_IO_VEC_MAX;
+ off_t offset;
+
+ (void)offset;
for (i = 0; i < HDD_IO_VEC_MAX; i++) {
iov[i].iov_base = (void *)data;
@@ -187,7 +190,27 @@ static ssize_t stress_hdd_write(
data += sz;
}
- ret = writev(fd, iov, HDD_IO_VEC_MAX);
+ switch (stress_mwc8() & 3) {
+#if defined(HAVE_PWRITEV2)
+ case 0:
+ /* 25% */
+ ret = pwritev2(fd, iov, HDD_IO_VEC_MAX, -1, 0);
+ break;
+#endif
+#if defined(HAVE_PWRITEV)
+ case 1:
+ /* 25% */
+ offset = lseek(fd, SEEK_CUR, 0);
+ if (offset != (off_t)-1) {
+ ret = pwritev(fd, iov, HDD_IO_VEC_MAX, offset);
+ break;
+ }
+ CASE_FALLTHROUGH;
+#endif
+ default:
+ ret = writev(fd, iov, HDD_IO_VEC_MAX);
+ break;
+ }
} else {
ret = write(fd, buf, count);
}
@@ -229,6 +252,9 @@ static ssize_t stress_hdd_read(
size_t i;
uint8_t *data = buf;
const uint64_t sz = hdd_write_size / HDD_IO_VEC_MAX;
+ off_t offset;
+
+ (void)offset;
for (i = 0; i < HDD_IO_VEC_MAX; i++) {
iov[i].iov_base = (void *)data;
@@ -236,7 +262,24 @@ static ssize_t stress_hdd_read(
data += sz;
}
- return readv(fd, iov, HDD_IO_VEC_MAX);
+ switch (stress_mwc8() & 3) {
+#if defined(HAVE_PREADV2)
+ case 0:
+ /* 25% */
+ return preadv2(fd, iov, HDD_IO_VEC_MAX, -1, 0);
+#endif
+#if defined(HAVE_PREADV)
+ case 1:
+ /* 25% */
+ offset = lseek(fd, SEEK_CUR, 0);
+ if (offset != (off_t)-1)
+ return preadv(fd, iov, HDD_IO_VEC_MAX, offset);
+ CASE_FALLTHROUGH;
+#endif
+ default:
+ /* 50% */
+ return readv(fd, iov, HDD_IO_VEC_MAX);
+ }
} else {
return read(fd, buf, count);
}
diff --git a/test/test-preadv.c b/test/test-preadv.c
new file mode 100644
index 000000000000..6bcfea842a2d
--- /dev/null
+++ b/test/test-preadv.c
@@ -0,0 +1,52 @@
+/*
+ * Copyright (C) 2013-2020 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 <colin.king@canonical.com> and attempts to be
+ * backwardly compatible with the stress tool by Amos Waterland
+ * <apw@rossby.metr.ou.edu> but has more stress tests and more
+ * functionality.
+ *
+ */
+#define _GNU_SOURCE
+
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <fcntl.h>
+#include <sys/uio.h>
+#include <unistd.h>
+
+#define IO_LEN (64)
+
+int main(void)
+{
+ struct iovec iov[1];
+ char data[IO_LEN];
+ int fd, rc;
+
+ fd = open("/dev/zero", O_RDONLY);
+ if (fd < 0)
+ return -1;
+
+ iov[0].iov_base = data;
+ iov[0].iov_len = (size_t)IO_LEN;
+
+ rc = preadv(fd, iov, 1, 0);
+ (void)close(fd);
+
+ return rc;
+}
diff --git a/test/test-preadv2.c b/test/test-preadv2.c
new file mode 100644
index 000000000000..2f87933d2a02
--- /dev/null
+++ b/test/test-preadv2.c
@@ -0,0 +1,52 @@
+/*
+ * Copyright (C) 2013-2020 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 <colin.king@canonical.com> and attempts to be
+ * backwardly compatible with the stress tool by Amos Waterland
+ * <apw@rossby.metr.ou.edu> but has more stress tests and more
+ * functionality.
+ *
+ */
+#define _GNU_SOURCE
+
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <fcntl.h>
+#include <sys/uio.h>
+#include <unistd.h>
+
+#define IO_LEN (64)
+
+int main(void)
+{
+ struct iovec iov[1];
+ char data[IO_LEN];
+ int fd, rc;
+
+ fd = open("/dev/zero", O_RDONLY);
+ if (fd < 0)
+ return -1;
+
+ iov[0].iov_base = data;
+ iov[0].iov_len = (size_t)IO_LEN;
+
+ rc = preadv2(fd, iov, 1, -1, 0);
+ (void)close(fd);
+
+ return rc;
+}
diff --git a/test/test-pwritev.c b/test/test-pwritev.c
index 153f3ff9de09..64d38f403534 100644
--- a/test/test-pwritev.c
+++ b/test/test-pwritev.c
@@ -24,15 +24,27 @@
*/
#define _GNU_SOURCE
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <fcntl.h>
#include <sys/uio.h>
+#include <unistd.h>
int main(void)
{
struct iovec iov;
char buffer[] = "hello world\n";
+ int fd, rc;
+
+ fd = open("/dev/zero", O_WRONLY);
+ if (fd < 0)
+ return -1;
iov.iov_base = buffer;
iov.iov_len = sizeof(buffer);
- return pwritev(1, &iov, 1, 0);
+ rc = pwritev(fd, &iov, 1, 0);
+ (void)close(fd);
+
+ return rc;
}
diff --git a/test/test-pwritev2.c b/test/test-pwritev2.c
new file mode 100644
index 000000000000..1c7d5f52d477
--- /dev/null
+++ b/test/test-pwritev2.c
@@ -0,0 +1,50 @@
+/*
+ * Copyright (C) 2013-2020 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 <colin.king@canonical.com> and attempts to be
+ * backwardly compatible with the stress tool by Amos Waterland
+ * <apw@rossby.metr.ou.edu> but has more stress tests and more
+ * functionality.
+ *
+ */
+#define _GNU_SOURCE
+
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <fcntl.h>
+#include <sys/uio.h>
+#include <unistd.h>
+
+int main(void)
+{
+ struct iovec iov;
+ char buffer[] = "hello world\n";
+ int fd, rc;
+
+ fd = open("/dev/zero", O_WRONLY);
+ if (fd < 0)
+ return -1;
+
+ iov.iov_base = buffer;
+ iov.iov_len = sizeof(buffer);
+
+ rc = pwritev2(fd, &iov, 1, -1, 0);
+ (void)close(fd);
+
+ return rc;
+}
--
2.21.3

View File

@ -1,39 +0,0 @@
From 4a46facac166e695fce4de75a04bdbac64b671ed Mon Sep 17 00:00:00 2001
From: Colin Ian King <colin.king@canonical.com>
Date: Fri, 15 May 2020 23:25:17 +0100
Subject: [PATCH 02/28] syscalls: update preadv/preadv2 and pwritev entries
Signed-off-by: Colin Ian King <colin.king@canonical.com>
---
syscalls.txt | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)
diff --git a/syscalls.txt b/syscalls.txt
index ca40053ecf84..2ca93c4d8509 100644
--- a/syscalls.txt
+++ b/syscalls.txt
@@ -227,8 +227,8 @@ posix_fallocate fallocate
ppoll poll
prctl process name setting
pread readahead
-preadv
-preadv2
+preadv hdd
+preadv2 hdd
prlimit get
/proc proc
process_vm_readv vm_rw
@@ -236,8 +236,8 @@ process_vm_writev vm_rw
pselect6 poll
ptrace ptrace
pwrite readahead, aio
-pwritev ioprio
-pwritev2
+pwritev hdd, ioprio
+pwritev2 hdd
quotactl quota
read pipe, zero, ..
readahead readahead
--
2.21.3

View File

@ -1,73 +0,0 @@
From f4fd8ae1f02e76ff7e7020cab9b5204baf91ec81 Mon Sep 17 00:00:00 2001
From: Colin Ian King <colin.king@canonical.com>
Date: Sun, 17 May 2020 18:37:59 +0100
Subject: [PATCH 03/28] stress-sock: add a few more ioctls to exercise
improve kernel socket ioctl coverage by adding a few more ioctls
Signed-off-by: Colin Ian King <colin.king@canonical.com>
---
stress-sock.c | 40 ++++++++++++++++++++++++++++++++++++++++
1 file changed, 40 insertions(+)
diff --git a/stress-sock.c b/stress-sock.c
index 031e84d98244..beafc46e2469 100644
--- a/stress-sock.c
+++ b/stress-sock.c
@@ -151,6 +151,44 @@ static int stress_set_socket_domain(const char *name)
return ret;
}
+static void stress_sock_ioctl(const int fd)
+{
+#if defined(FIOGETOWN)
+ {
+ int ret, own;
+
+ ret = ioctl(fd, FIOGETOWN, &own);
+ (void)ret;
+ }
+#endif
+#if defined(SIOCGPGRP)
+ {
+ int ret, own;
+
+ ret = ioctl(fd, SIOCGPGRP, &own);
+ (void)ret;
+ }
+#endif
+#if defined(SIOCGIFCONF)
+ {
+ int ret;
+ struct ifconf ifc;
+
+ ret = ioctl(fd, SIOCGIFCONF, &ifc);
+ (void)ret;
+ }
+#endif
+#if defined(SIOCGSTAMP)
+ {
+ int ret;
+ struct timeval tv;
+
+ ret = ioctl(fd, SIOCGSTAMP, &tv);
+ (void)ret;
+ }
+#endif
+}
+
/*
* stress_sock_client()
* client reader
@@ -324,6 +362,8 @@ retry:
break;
}
} while (keep_stressing());
+
+ stress_sock_ioctl(fd);
#if defined(AF_INET) && \
defined(IPPROTO_IP) && \
defined(IP_MTU)
--
2.21.3

View File

@ -1,265 +0,0 @@
From 02fe57f97b44220c55c599aaa700607664c37382 Mon Sep 17 00:00:00 2001
From: Colin Ian King <colin.king@canonical.com>
Date: Mon, 18 May 2020 00:01:27 +0100
Subject: [PATCH 04/28] stress-sem-sysv: exercise some invalid options to get
more kernel coverage
Exercise some of the invalid argument checking to exercise more kernel
paths.
Signed-off-by: Colin Ian King <colin.king@canonical.com>
---
stress-sem-sysv.c | 122 +++++++++++++++++++++++++++++++++++++++-------
1 file changed, 105 insertions(+), 17 deletions(-)
diff --git a/stress-sem-sysv.c b/stress-sem-sysv.c
index 8c5fd1c95640..3c62d065b4de 100644
--- a/stress-sem-sysv.c
+++ b/stress-sem-sysv.c
@@ -139,12 +139,13 @@ static void stress_semaphore_sysv_get_procinfo(bool *get_procinfo)
* stress_semaphore_sysv_thrash()
* exercise the semaphore
*/
-static void stress_semaphore_sysv_thrash(const stress_args_t *args)
+static int stress_semaphore_sysv_thrash(const stress_args_t *args)
{
const int sem_id = g_shared->sem_sysv.sem_id;
+ int rc = EXIT_SUCCESS;
do {
- int i;
+ int i, ret;
#if defined(__linux__)
bool get_procinfo = true;
#endif
@@ -155,7 +156,7 @@ static void stress_semaphore_sysv_thrash(const stress_args_t *args)
if (clock_gettime(CLOCK_REALTIME, &timeout) < 0) {
pr_fail("%s: clock_gettime failed, errno=%d (%s)\n",
args->name, errno, strerror(errno));
- return;
+ return EXIT_NO_RESOURCE;
}
timeout.tv_sec++;
#endif
@@ -184,15 +185,19 @@ static void stress_semaphore_sysv_thrash(const stress_args_t *args)
#endif
if (errno == EAGAIN)
goto timed_out;
- if (errno != EINTR)
+ if (errno != EINTR) {
pr_fail("%s: semop wait failed, errno=%d (%s)\n",
args->name, errno, strerror(errno));
+ rc = EXIT_FAILURE;
+ }
break;
}
if (semop(sem_id, &semsignal, 1) < 0) {
- if (errno != EINTR)
+ if (errno != EINTR) {
pr_fail("%s: semop signal failed, errno=%d (%s)\n",
args->name, errno, strerror(errno));
+ rc = EXIT_FAILURE;
+ }
break;
}
timed_out:
@@ -208,9 +213,11 @@ timed_out:
memset(&ds, 0, sizeof(ds));
s.buf = &ds;
- if (semctl(sem_id, 0, IPC_STAT, &s) < 0)
+ if (semctl(sem_id, 0, IPC_STAT, &s) < 0) {
pr_fail("%s: semctl IPC_STAT failed, errno=%d (%s)\n",
args->name, errno, strerror(errno));
+ rc = EXIT_FAILURE;
+ }
#if defined(GETALL)
/* Avoid zero array size allocation */
@@ -221,11 +228,13 @@ timed_out:
if (semctl(sem_id, 0, GETALL, s) < 0) {
pr_fail("%s: semctl GETALL failed, errno=%d (%s)\n",
args->name, errno, strerror(errno));
+ rc = EXIT_FAILURE;
}
#if defined(SETALL)
if (semctl(sem_id, 0, SETALL, s) < 0) {
pr_fail("%s: semctl SETALL failed, errno=%d (%s)\n",
args->name, errno, strerror(errno));
+ rc = EXIT_FAILURE;
}
#endif
free(s.array);
@@ -239,9 +248,11 @@ timed_out:
stress_semun_t s;
s.buf = &ds;
- if (semctl(sem_id, 0, SEM_STAT, &s) < 0)
+ if (semctl(sem_id, 0, SEM_STAT, &s) < 0) {
pr_fail("%s: semctl SET_STAT failed, errno=%d (%s)\n",
args->name, errno, strerror(errno));
+ rc = EXIT_FAILURE;
+ }
}
#endif
#if defined(IPC_INFO) && defined(__linux__)
@@ -250,9 +261,11 @@ timed_out:
stress_semun_t s;
s.__buf = &si;
- if (semctl(sem_id, 0, IPC_INFO, &s) < 0)
+ if (semctl(sem_id, 0, IPC_INFO, &s) < 0) {
pr_fail("%s: semctl IPC_INFO failed, errno=%d (%s)\n",
args->name, errno, strerror(errno));
+ rc = EXIT_FAILURE;
+ }
}
#endif
#if defined(SEM_INFO) && defined(__linux__)
@@ -261,32 +274,103 @@ timed_out:
stress_semun_t s;
s.__buf = &si;
- if (semctl(sem_id, 0, SEM_INFO, &s) < 0)
+ if (semctl(sem_id, 0, SEM_INFO, &s) < 0) {
pr_fail("%s: semctl SEM_INFO failed, errno=%d (%s)\n",
args->name, errno, strerror(errno));
+ rc = EXIT_FAILURE;
+ }
}
#endif
#if defined(GETVAL)
- if (semctl(sem_id, 0, GETVAL) < 0)
+ if (semctl(sem_id, 0, GETVAL) < 0) {
pr_fail("%s: semctl GETVAL failed, errno=%d (%s)\n",
args->name, errno, strerror(errno));
+ rc = EXIT_FAILURE;
+ }
#endif
#if defined(GETPID)
- if (semctl(sem_id, 0, GETPID) < 0)
+ if (semctl(sem_id, 0, GETPID) < 0) {
pr_fail("%s: semctl GETPID failed, errno=%d (%s)\n",
args->name, errno, strerror(errno));
+ rc = EXIT_FAILURE;
+ }
#endif
#if defined(GETNCNT)
- if (semctl(sem_id, 0, GETNCNT) < 0)
+ if (semctl(sem_id, 0, GETNCNT) < 0) {
pr_fail("%s: semctl GETNCNT failed, errno=%d (%s)\n",
args->name, errno, strerror(errno));
+ rc = EXIT_FAILURE;
+ }
#endif
#if defined(GETZCNT)
- if (semctl(sem_id, 0, GETZCNT) < 0)
+ if (semctl(sem_id, 0, GETZCNT) < 0) {
pr_fail("%s: semctl GETZCNT failed, errno=%d (%s)\n",
args->name, errno, strerror(errno));
+ rc = EXIT_FAILURE;
+ }
+#endif
+ /*
+ * Now exercise invalid options and arguments
+ */
+ ret = semctl(sem_id, -1, SETVAL, 0);
+ if ((ret == 0) || ((ret < 0) && (errno != EINVAL))) {
+ pr_fail("%s: semctl SETVAL with semnum = -1 did not fail with EINVAL as expected, errno=%d (%s)\n",
+ args->name, errno, strerror(errno));
+ rc = EXIT_FAILURE;
+ }
+#if defined(GETVAL)
+ ret = semctl(sem_id, -1, GETVAL);
+ if ((ret == 0) || ((ret < 0) && (errno != EINVAL))) {
+ pr_fail("%s: semctl GETVAL with semnum = -1 did not fail with EINVAL as expected, errno=%d (%s)\n",
+ args->name, errno, strerror(errno));
+ rc = EXIT_FAILURE;
+ }
+#endif
+#if defined(HAVE_SEMTIMEDOP) && \
+ defined(HAVE_CLOCK_GETTIME)
+ {
+ /*
+ * Exercise illegal timeout
+ */
+ struct sembuf semwait;
+
+ timeout.tv_sec = -1;
+ timeout.tv_nsec = -1;
+ semwait.sem_num = 0;
+ semwait.sem_op = -1;
+ semwait.sem_flg = SEM_UNDO;
+
+ ret = semtimedop(sem_id, &semwait, 1, &timeout);
+ if ((ret == 0) || ((ret < 0) && (errno != EINVAL))) {
+ pr_fail("%s: semtimedop with invalid timeout did not fail with EINVAL as expected, errno=%d (%s)\n",
+ args->name, errno, strerror(errno));
+ rc = EXIT_FAILURE;
+ }
+ }
#endif
- } while (keep_stressing());
+ /*
+ * Exercise illegal semwait
+ */
+ {
+ struct sembuf semwait;
+
+ semwait.sem_num = -1;
+ semwait.sem_op = -1;
+ semwait.sem_flg = SEM_UNDO;
+
+ ret = semop(sem_id, &semwait, 1);
+ if ((ret == 0) || ((ret < 0) && (errno != EFBIG))) {
+ pr_fail("%s: semop with invalid sem_num did not fail with EFBIG as expected, errno=%d (%s)\n",
+ args->name, errno, strerror(errno));
+ rc = EXIT_FAILURE;
+ }
+ }
+ } while ((rc == EXIT_SUCCESS) && keep_stressing());
+
+ if (rc == EXIT_FAILURE)
+ kill(getppid(), SIGALRM);
+
+ return rc;
}
/*
@@ -308,8 +392,7 @@ again:
(void)setpgid(0, g_pgrp);
stress_parent_died_alarm();
- stress_semaphore_sysv_thrash(args);
- _exit(EXIT_SUCCESS);
+ _exit(stress_semaphore_sysv_thrash(args));
}
(void)setpgid(pid, g_pgrp);
return pid;
@@ -324,6 +407,7 @@ static int stress_sem_sysv(const stress_args_t *args)
pid_t pids[MAX_SEMAPHORE_PROCS];
uint64_t i;
uint64_t semaphore_sysv_procs = DEFAULT_SEMAPHORE_PROCS;
+ int rc = EXIT_SUCCESS;
if (!stress_get_setting("sem-sysv-procs", &semaphore_sysv_procs)) {
if (g_opt_flags & OPT_FLAGS_MAXIMIZE)
@@ -356,10 +440,14 @@ reap:
int status;
(void)shim_waitpid(pids[i], &status, 0);
+ if (WIFEXITED(status) &&
+ (WEXITSTATUS(status) != EXIT_SUCCESS)) {
+ rc = EXIT_FAILURE;
+ }
}
}
- return EXIT_SUCCESS;
+ return rc;
}
stressor_info_t stress_sem_sysv_info = {
--
2.21.3

View File

@ -1,56 +0,0 @@
From d3e6eb729840935ac4f700f4ac2d32ac6acaa88d Mon Sep 17 00:00:00 2001
From: Colin Ian King <colin.king@canonical.com>
Date: Mon, 18 May 2020 10:00:32 +0100
Subject: [PATCH 05/28] stress-shm-sysv: exercise NUMA mempolicy on shm
Add more kernel test coverage to shm
Signed-off-by: Colin Ian King <colin.king@canonical.com>
---
stress-shm-sysv.c | 23 +++++++++++++++++++++++
1 file changed, 23 insertions(+)
diff --git a/stress-shm-sysv.c b/stress-shm-sysv.c
index 9873f8935a12..7703e58cad7a 100644
--- a/stress-shm-sysv.c
+++ b/stress-shm-sysv.c
@@ -37,6 +37,10 @@ static const stress_help_t help[] = {
defined(HAVE_SHM_SYSV)
#define KEY_GET_RETRIES (40)
+#define BITS_PER_BYTE (8)
+#define NUMA_LONG_BITS (sizeof(unsigned long) * BITS_PER_BYTE)
+#define MPOL_F_ADDR (1 << 1)
+#define MPOL_DEFAULT (0)
/*
* Note, running this test with the --maximize option on
@@ -369,6 +373,25 @@ static int stress_shm_sysv_child(
}
#endif
+ /*
+ * Exercise NUMA mem_policy on shm
+ */
+#if defined(__NR_get_mempolicy) && \
+ defined(__NR_set_mempolicy)
+ {
+ int ret, mode;
+ unsigned long node_mask[NUMA_LONG_BITS];
+
+ ret = shim_get_mempolicy(&mode, node_mask, 1,
+ (unsigned long)addrs[i], MPOL_F_ADDR);
+ if (ret == 0) {
+ ret = shim_set_mempolicy(MPOL_DEFAULT, NULL, 1);
+ (void)ret;
+ }
+ (void)ret;
+ }
+#endif
+
inc_counter(args);
}
reap:
--
2.21.3

View File

@ -1,104 +0,0 @@
From ceb4a4712eb09892af949494a95ffc4d15f04272 Mon Sep 17 00:00:00 2001
From: Colin Ian King <colin.king@canonical.com>
Date: Mon, 18 May 2020 10:17:17 +0100
Subject: [PATCH 06/28] stress-shm-sysv: exercise shmctl and shmdt race on
child exit
Add a little more shm-sysv kernel coverage by performing shm
actions with a child process that has inherited shm from parent.
Signed-off-by: Colin Ian King <colin.king@canonical.com>
---
stress-shm-sysv.c | 34 ++++++++++++++++++++++++++++++----
1 file changed, 30 insertions(+), 4 deletions(-)
diff --git a/stress-shm-sysv.c b/stress-shm-sysv.c
index 7703e58cad7a..26d47ccdd4d7 100644
--- a/stress-shm-sysv.c
+++ b/stress-shm-sysv.c
@@ -200,6 +200,7 @@ static int stress_shm_sysv_child(
do {
size_t sz = max_sz;
+ pid_t pid = -1;
for (i = 0; i < shm_sysv_segments; i++) {
int shm_id, count = 0;
@@ -325,7 +326,7 @@ static int stress_shm_sysv_child(
}
}
#endif
-#if defined(IPC_STAT) && \
+#if defined(IPC_STAT) && \
defined(HAVE_SHMID_DS)
{
struct shmid_ds ds;
@@ -343,7 +344,7 @@ static int stress_shm_sysv_child(
#endif
}
#endif
-#if defined(IPC_INFO) && \
+#if defined(IPC_INFO) && \
defined(HAVE_SHMINFO)
{
struct shminfo s;
@@ -353,7 +354,7 @@ static int stress_shm_sysv_child(
args->name, errno, strerror(errno));
}
#endif
-#if defined(SHM_INFO) && \
+#if defined(SHM_INFO) && \
defined(HAVE_SHMINFO)
{
struct shm_info s;
@@ -363,7 +364,7 @@ static int stress_shm_sysv_child(
args->name, errno, strerror(errno));
}
#endif
-#if defined(SHM_LOCK) && \
+#if defined(SHM_LOCK) && \
defined(SHM_UNLOCK)
if (shmctl(shm_id, SHM_LOCK, (struct shmid_ds *)NULL) < 0) {
int ret;
@@ -394,6 +395,25 @@ static int stress_shm_sysv_child(
inc_counter(args);
}
+
+ pid = fork();
+ if (pid == 0) {
+ for (i = 0; i < shm_sysv_segments; i++) {
+ int ret;
+#if defined(IPC_STAT) && \
+ defined(HAVE_SHMID_DS)
+
+ if (shm_ids[i] >= 0) {
+ struct shmid_ds ds;
+ ret = shmctl(shm_ids[i], IPC_STAT, &ds);
+ (void)ret;
+ }
+#endif
+ ret = shmdt(addrs[i]);
+ (void)ret;
+ }
+ _exit(EXIT_SUCCESS);
+ }
reap:
for (i = 0; i < shm_sysv_segments; i++) {
if (addrs[i]) {
@@ -422,6 +442,12 @@ reap:
shm_ids[i] = -1;
keys[i] = 0;
}
+
+ if (pid >= 0) {
+ int status;
+
+ (void)waitpid(pid, &status, 0);
+ }
} while (ok && keep_stressing());
/* Inform parent of end of run */
--
2.21.3

View File

@ -1,79 +0,0 @@
From ed1ec01953a173f45d930e923b2e23daa5a1dc00 Mon Sep 17 00:00:00 2001
From: Colin Ian King <colin.king@canonical.com>
Date: Mon, 18 May 2020 10:38:19 +0100
Subject: [PATCH 07/28] stress-mq: add SIGEV_SIGNAL events to exercise kernel
Increase kernel coverage by also using SIGEV_SIGNAL mq events
Signed-off-by: Colin Ian King <colin.king@canonical.com>
---
stress-mq.c | 32 ++++++++++++++++++++++++++++----
1 file changed, 28 insertions(+), 4 deletions(-)
diff --git a/stress-mq.c b/stress-mq.c
index 2424748bb055..9b46a4683e77 100644
--- a/stress-mq.c
+++ b/stress-mq.c
@@ -62,6 +62,13 @@ static void stress_mq_notify_func(union sigval s)
(void)s;
}
+#if defined(SIGUSR2)
+static void MLOCKED_TEXT stress_sigusr2_handler(int signum)
+{
+ (void)signum;
+}
+#endif
+
/*
* stress_mq
* stress POSIX message queues
@@ -78,6 +85,11 @@ static int stress_mq(const stress_args_t *args)
time_t time_start;
struct timespec abs_timeout;
+#if defined(SIGUSR2)
+ if (stress_sighandler(args->name, SIGUSR2, stress_sigusr2_handler, NULL) < 0)
+ return EXIT_NO_RESOURCE;
+#endif
+
if (!stress_get_setting("mq-size", &mq_size)) {
if (g_opt_flags & OPT_FLAGS_MAXIMIZE)
mq_size = MAX_MQ_SIZE;
@@ -159,10 +171,6 @@ again:
struct sigevent sigev;
uint64_t values[PRIOS_MAX];
- (void)memset(&sigev, 0, sizeof sigev);
- sigev.sigev_notify = SIGEV_THREAD;
- sigev.sigev_notify_function = stress_mq_notify_func;
- sigev.sigev_notify_attributes = NULL;
(void)setpgid(0, g_pgrp);
stress_parent_died_alarm();
@@ -203,6 +211,22 @@ again:
args->name, errno, strerror(errno));
#endif
+ (void)memset(&sigev, 0, sizeof sigev);
+ switch (stress_mwc1()) {
+ case 0:
+#if defined(SIGUSR2)
+ sigev.sigev_notify = SIGEV_SIGNAL;
+ sigev.sigev_signo = SIGUSR2;
+ break;
+#else
+ CASE_FALLTHROUGH;
+#endif
+ default:
+ sigev.sigev_notify = SIGEV_THREAD;
+ sigev.sigev_notify_function = stress_mq_notify_func;
+ sigev.sigev_notify_attributes = NULL;
+ break;
+ }
(void)mq_notify(mq, &sigev);
}
--
2.21.3

View File

@ -1,293 +0,0 @@
From 846f27b3d7bdfc3c2fc99fc6ddc6d51d7d822b80 Mon Sep 17 00:00:00 2001
From: Colin Ian King <colin.king@canonical.com>
Date: Mon, 18 May 2020 14:20:44 +0100
Subject: [PATCH 08/28] stress-ng: add checksum sanity check on bogo ops stats
and run flag
ELISA request for run sanity check involves adding a duplicated bogo
ops and run flag in a different shared memory segment, hashing this
data and checking these with the stats at the end of a run. If any
corruption or run failures occur we have a mechanism of ensuring that
the measurements are sane with a hashed check on the data and comparing
the two separate copies.
Signed-off-by: Colin Ian King <colin.king@canonical.com>
---
stress-ng.c | 115 ++++++++++++++++++++++++++++++++++++++++++++++++----
stress-ng.h | 21 +++++++++-
2 files changed, 125 insertions(+), 11 deletions(-)
diff --git a/stress-ng.c b/stress-ng.c
index 17e7377d6f5d..c57ab29b49e3 100644
--- a/stress-ng.c
+++ b/stress-ng.c
@@ -966,6 +966,16 @@ static const stress_help_t help_generic[] = {
{ NULL, NULL, NULL }
};
+/*
+ * stress_hash_checksum()
+ * generate a hash of the checksum data
+ */
+static inline void stress_hash_checksum(stress_checksum_t *checksum)
+{
+ checksum->hash = stress_hash_jenkin((uint8_t *)&checksum->data,
+ sizeof(checksum->data));
+}
+
/*
* stressor_name_find()
* Find index into stressors by name
@@ -1651,6 +1661,7 @@ static void MLOCKED_TEXT stress_run(
double time_start, time_finish;
int32_t n_procs, j;
const int32_t total_procs = get_total_num_procs(procs_list);
+ stress_checksum_t *checksum = g_shared->checksums;
int32_t sched;
@@ -1659,12 +1670,11 @@ static void MLOCKED_TEXT stress_run(
long sched_runtime = -1;
long sched_deadline = -1;
-
wait_flag = true;
time_start = stress_time_now();
pr_dbg("starting stressors\n");
for (n_procs = 0; n_procs < total_procs; n_procs++) {
- for (g_proc_current = procs_list; g_proc_current; g_proc_current = g_proc_current->next) {
+ for (g_proc_current = procs_list; g_proc_current; g_proc_current = g_proc_current->next, checksum++) {
if (g_opt_timeout && (stress_time_now() - time_start > g_opt_timeout))
goto abort;
@@ -1765,9 +1775,16 @@ again:
.page_size = stress_get_pagesize(),
};
+ (void)memset(checksum, 0, sizeof(*checksum));
rc = g_proc_current->stressor->info->stressor(&args);
pr_fail_check(&rc);
- stats->run_ok = (rc == EXIT_SUCCESS);
+ if (rc == EXIT_SUCCESS) {
+ stats->run_ok = true;
+ checksum->data.run_ok = true;
+ }
+ stats->checksum = checksum;
+ checksum->data.counter = *args.counter;
+ stress_hash_checksum(checksum);
}
#if defined(STRESS_PERF_STATS) && defined(HAVE_LINUX_PERF_EVENT_H)
if (g_opt_flags & OPT_FLAGS_PERF_STATS) {
@@ -1878,6 +1895,65 @@ static int show_stressors(void)
return 0;
}
+/*
+ * metrics_check()
+ * as per ELISA request, sanity check bogo ops and run flag
+ * to see if corruption occurred and print failure messages
+ * and set *success to false if hash and data is dubious.
+ */
+static void metrics_check(bool *success)
+{
+ stress_proc_info_t *pi;
+ bool ok = true;
+
+ for (pi = procs_head; pi; pi = pi->next) {
+ int32_t j;
+
+ for (j = 0; j < pi->started_procs; j++) {
+ const stress_proc_stats_t *const stats = pi->stats[j];
+ const stress_checksum_t *checksum = stats->checksum;
+ stress_checksum_t stats_checksum;
+
+ if (checksum == NULL) {
+ pr_fail("%s instance %d unexpected null checksum data\n",
+ pi->stressor->name, j);
+ ok = false;
+ continue;
+ }
+
+ (void)memset(&stats_checksum, 0, sizeof(stats_checksum));
+ stats_checksum.data.counter = stats->counter;
+ stats_checksum.data.run_ok = stats->run_ok;
+ stress_hash_checksum(&stats_checksum);
+
+ if (stats->counter != checksum->data.counter) {
+ pr_fail("%s instance %d corrupted bogo-ops counter, %" PRIu64 " vs %" PRIu64 "\n",
+ pi->stressor->name, j,
+ stats->counter, checksum->data.counter);
+ ok = false;
+ }
+ if (stats->run_ok != checksum->data.run_ok) {
+ pr_fail("%s instance %d corrupted run flag, %d vs %d\n",
+ pi->stressor->name, j,
+ stats->run_ok, checksum->data.run_ok);
+ ok = false;
+ }
+ if (stats_checksum.hash != checksum->hash) {
+ pr_fail("%s instance %d hash error in bogo-ops counter and run flag, %" PRIu32 " vs %" PRIu32 "\n",
+ pi->stressor->name, j,
+ stats_checksum.hash, checksum->hash);
+ ok = false;
+ }
+ }
+ }
+ if (ok) {
+ pr_dbg("metrics check: all stressor metrics validated and sane\n");
+ } else {
+ pr_fail("metrics check: stressor metrics corrupted, data is compromised\n");
+ *success = false;
+ }
+}
+
/*
* metrics_dump()
* output metrics
@@ -2093,10 +2169,11 @@ static void log_system_info(void)
* that is marked read-only to stop accidental smashing
* from a run-away stack expansion
*/
-static inline void stress_map_shared(const size_t len)
+static inline void stress_map_shared(const size_t num_procs)
{
const size_t page_size = stress_get_pagesize();
- const size_t sz = (len + (page_size << 1)) & ~(page_size - 1);
+ size_t len = sizeof(stress_shared_t) + (sizeof(stress_proc_stats_t) * num_procs);
+ size_t sz = (len + (page_size << 1)) & ~(page_size - 1);
#if defined(HAVE_MPROTECT)
void *last_page;
#endif
@@ -2104,7 +2181,7 @@ static inline void stress_map_shared(const size_t len)
g_shared = (stress_shared_t *)mmap(NULL, sz, PROT_READ | PROT_WRITE,
MAP_SHARED | MAP_ANON, -1, 0);
if (g_shared == MAP_FAILED) {
- pr_err("Cannot mmap to shared memory region: errno=%d (%s)\n",
+ pr_err("Cannot mmap to shared memory region, errno=%d (%s)\n",
errno, strerror(errno));
free_procs();
exit(EXIT_FAILURE);
@@ -2137,6 +2214,25 @@ static inline void stress_map_shared(const size_t len)
g_shared->length -= sz;
}
#endif
+
+ /*
+ * copy of checksums and run data in a different shared
+ * memory segment so that we can sanity check these for
+ * any form of corruption
+ */
+ len = sizeof(stress_checksum_t) * STRESS_PROCS_MAX;
+ sz = (len + page_size) & ~(page_size - 1);
+ g_shared->checksums = (stress_checksum_t *)mmap(NULL, sz,
+ PROT_READ | PROT_WRITE, MAP_SHARED | MAP_ANON, -1, 0);
+ if (g_shared->checksums == MAP_FAILED) {
+ pr_err("Cannot mmap checksums, errno=%d (%s)\n",
+ errno, strerror(errno));
+ (void)munmap((void *)g_shared, g_shared->length);
+ free_procs();
+ exit(EXIT_FAILURE);
+ }
+ (void)memset(g_shared->checksums, 0, sz);
+ g_shared->checksums_length = sz;
}
/*
@@ -2145,6 +2241,7 @@ static inline void stress_map_shared(const size_t len)
*/
void stress_unmap_shared(void)
{
+ (void)munmap((void *)g_shared->checksums, g_shared->checksums_length);
(void)munmap((void *)g_shared, g_shared->length);
}
@@ -2785,7 +2882,6 @@ static inline void stress_mlock_executable(void)
int main(int argc, char **argv, char **envp)
{
double duration = 0.0; /* stressor run time in secs */
- size_t len;
bool success = true, resource_success = true;
FILE *yaml; /* YAML output file */
char *yaml_filename; /* YAML file name */
@@ -2997,8 +3093,7 @@ int main(int argc, char **argv, char **envp)
* Allocate shared memory segment for shared data
* across all the child stressors
*/
- len = sizeof(stress_shared_t) + (sizeof(stress_proc_stats_t) * get_total_num_procs(procs_head));
- stress_map_shared(len);
+ stress_map_shared(get_total_num_procs(procs_head));
/*
* Setup spinlocks
@@ -3076,6 +3171,8 @@ int main(int argc, char **argv, char **envp)
if (g_opt_flags & OPT_FLAGS_METRICS)
metrics_dump(yaml, ticks_per_sec);
+ metrics_check(&success);
+
#if defined(STRESS_PERF_STATS) && defined(HAVE_LINUX_PERF_EVENT_H)
/*
* Dump perf statistics
diff --git a/stress-ng.h b/stress-ng.h
index 85b2beccf051..54986499503d 100644
--- a/stress-ng.h
+++ b/stress-ng.h
@@ -907,6 +907,20 @@ typedef enum {
typedef struct stress_proc_info *stress_pproc_info_t;
+/*
+ * Per ELISA request, we have a duplicated counter
+ * and run_ok flag in a different shared memory region
+ * so we can sanity check these just in case the stats
+ * have got corrupted.
+ */
+typedef struct {
+ struct {
+ uint64_t counter; /* Copy of stats counter */
+ bool run_ok; /* Copy of run_ok */
+ } data;
+ uint32_t hash; /* Hash of data */
+} stress_checksum_t;
+
/* settings for storing opt arg parsed data */
typedef struct stress_setting {
struct stress_setting *next; /* next setting in list */
@@ -1838,6 +1852,7 @@ typedef struct {
stress_tz_t tz; /* thermal zones */
#endif
bool run_ok; /* true if stressor exited OK */
+ stress_checksum_t *checksum; /* pointer to checksum data */
} stress_proc_stats_t;
#define STRESS_WARN_HASH_MAX (128)
@@ -1889,6 +1904,8 @@ typedef struct {
uint32_t softlockup_count; /* Atomic counter of softlock children */
#endif
uint8_t str_shared[STR_SHARED_SIZE]; /* str copying buffer */
+ stress_checksum_t *checksums; /* per stressor counter checksum */
+ size_t checksums_length; /* size of checksums mapping */
stress_proc_stats_t stats[0]; /* Shared statistics */
} stress_shared_t;
@@ -3125,7 +3142,7 @@ typedef struct {
const char *name; /* name of stress test */
} stress_t;
-/* Per process information */
+/* Per stressor process information */
typedef struct stress_proc_info {
struct stress_proc_info *next; /* next proc info struct in list */
struct stress_proc_info *prev; /* prev proc info struct in list */
@@ -3133,7 +3150,7 @@ typedef struct stress_proc_info {
pid_t *pids; /* process id */
stress_proc_stats_t **stats; /* process proc stats info */
int32_t started_procs; /* count of started processes */
- int32_t num_procs; /* number of process per stressor */
+ int32_t num_procs; /* number of processes per stressor */
uint64_t bogo_ops; /* number of bogo ops */
} stress_proc_info_t;
--
2.21.3

View File

@ -1,38 +0,0 @@
From f7449735ad61d51def65b8e6c8ee0f2becb6765e Mon Sep 17 00:00:00 2001
From: Colin Ian King <colin.king@canonical.com>
Date: Tue, 19 May 2020 09:18:12 +0100
Subject: [PATCH 09/28] stress-dev: remove sleep and return EXIT_SUCCESS on
child exit
The sleep is surplus to requirements, so remove it. Also make child
exit with EXIT_SUCCESS when it successfully terminates.
Signed-off-by: Colin Ian King <colin.king@canonical.com>
---
stress-dev.c | 3 +--
1 file changed, 1 insertion(+), 2 deletions(-)
diff --git a/stress-dev.c b/stress-dev.c
index 9cde82549785..2eeb72c8cc21 100644
--- a/stress-dev.c
+++ b/stress-dev.c
@@ -1532,7 +1532,6 @@ again:
(void)setpgid(pid, g_pgrp);
/* Parent, wait for child */
wret = shim_waitpid(pid, &status, 0);
- sleep(2);
if (wret < 0) {
if (errno != EINTR)
pr_dbg("%s: waitpid(): errno=%d (%s)\n",
@@ -1601,7 +1600,7 @@ again:
pthread_join(pthreads[i], NULL);
}
stress_hash_delete(dev_hash_table);
- _exit(!keep_stressing_flag());
+ _exit(EXIT_SUCCESS);
}
} while (keep_stressing());
--
2.21.3

View File

@ -1,38 +0,0 @@
From 97aaa339ed3cfa22e73f2dcbd0bac26b00f3a0e3 Mon Sep 17 00:00:00 2001
From: Colin Ian King <colin.king@canonical.com>
Date: Tue, 19 May 2020 09:19:04 +0100
Subject: [PATCH 10/28] core-shim: rework waitpid again, terminate child on
EINTR (LP: #1879447)
The parent may receive a EINTR on a SIGALRM so send this to the
child. If it hasn't died after a while send the child SIGKILL
to force termination.
Signed-off-by: Colin Ian King <colin.king@canonical.com>
---
core-shim.c | 9 +++++----
1 file changed, 5 insertions(+), 4 deletions(-)
diff --git a/core-shim.c b/core-shim.c
index a44f6cf1b923..62c00ec991ef 100644
--- a/core-shim.c
+++ b/core-shim.c
@@ -1188,10 +1188,11 @@ pid_t shim_waitpid(pid_t pid, int *wstatus, int options)
* Retry if EINTR unless we've have 100
* consecutive EINTRs then give up.
*/
- if (!keep_stressing_flag())
- break;
- if (count++ > 100)
- break;
+ if (!keep_stressing_flag()) {
+ kill(pid, SIGALRM);
+ if (count++ > 100)
+ kill(pid, SIGKILL);
+ }
}
return ret;
}
--
2.21.3

View File

@ -1,125 +0,0 @@
From 9b173976fc1b6fa841cdc617aff26bedbef5282c Mon Sep 17 00:00:00 2001
From: Colin Ian King <colin.king@canonical.com>
Date: Tue, 19 May 2020 10:01:29 +0100
Subject: [PATCH 11/28] Add memory barriers an ready flag to check if counter
is in a sane state
The counter now is protected with a ready flag that is set to false
during the counter update. The ordering of the flag unset, counter
update and flag set is protected with memory barriers to enforce
strict ordering. Add a check at the end of the run to check if
the counter ready flag is in a sane state and fail with an error
if it is set incorrectly. Addresses concerns raised by ELISA.
Signed-off-by: Colin Ian King <colin.king@canonical.com>
---
stress-ng.c | 14 ++++++++++++++
stress-ng.h | 22 ++++++++++++++++++++++
2 files changed, 36 insertions(+)
diff --git a/stress-ng.c b/stress-ng.c
index c57ab29b49e3..66ee5d15fa37 100644
--- a/stress-ng.c
+++ b/stress-ng.c
@@ -1766,6 +1766,7 @@ again:
if (keep_stressing_flag() && !(g_opt_flags & OPT_FLAGS_DRY_RUN)) {
const stress_args_t args = {
.counter = &stats->counter,
+ .counter_ready = &stats->counter_ready,
.name = name,
.max_ops = g_proc_current->bogo_ops,
.instance = j,
@@ -1775,6 +1776,9 @@ again:
.page_size = stress_get_pagesize(),
};
+ stats->counter_ready = true;
+ stats->counter = 0;
+
(void)memset(checksum, 0, sizeof(*checksum));
rc = g_proc_current->stressor->info->stressor(&args);
pr_fail_check(&rc);
@@ -1782,6 +1786,16 @@ again:
stats->run_ok = true;
checksum->data.run_ok = true;
}
+ /*
+ * Bogo ops counter should be OK for reading,
+ * if not then flag up that the counter may
+ * be untrustyworthy
+ */
+ if (!stats->counter_ready) {
+ pr_fail("%s: bogo-ops counter in non-read state, metrics are untrustworthy\n",
+ name);
+ rc = EXIT_FAILURE;
+ }
stats->checksum = checksum;
checksum->data.counter = *args.counter;
stress_hash_checksum(checksum);
diff --git a/stress-ng.h b/stress-ng.h
index 54986499503d..7449af0c161f 100644
--- a/stress-ng.h
+++ b/stress-ng.h
@@ -979,6 +979,7 @@ typedef uint32_t stress_class_t;
/* stressor args */
typedef struct {
uint64_t *const counter; /* stressor counter */
+ bool *counter_ready; /* counter can be read */
const char *name; /* stressor name */
const uint64_t max_ops; /* max number of bogo ops */
const uint32_t instance; /* stressor instance # */
@@ -1692,10 +1693,20 @@ extern void pr_dbg_lock(bool *locked, const char *fmt, ...) FORMAT(printf, 2, 3
#define HAVE_PRCTL_TIMER_SLACK
#endif
+static inline void ALWAYS_INLINE shim_mb(void)
+{
+ asm volatile ("" ::: "memory");
+}
+
/* increment the stessor bogo ops counter */
static inline void ALWAYS_INLINE inc_counter(const stress_args_t *args)
{
+ *args->counter_ready = false;
+ shim_mb();
(*(args->counter))++;
+ shim_mb();
+ *args->counter_ready = true;
+ shim_mb();
}
static inline uint64_t ALWAYS_INLINE get_counter(const stress_args_t *args)
@@ -1705,12 +1716,22 @@ static inline uint64_t ALWAYS_INLINE get_counter(const stress_args_t *args)
static inline void ALWAYS_INLINE set_counter(const stress_args_t *args, const uint64_t val)
{
+ *args->counter_ready = false;
+ shim_mb();
*args->counter = val;
+ shim_mb();
+ *args->counter_ready = true;
+ shim_mb();
}
static inline void ALWAYS_INLINE add_counter(const stress_args_t *args, const uint64_t inc)
{
+ *args->counter_ready = false;
+ shim_mb();
*args->counter += inc;
+ shim_mb();
+ *args->counter_ready = true;
+ shim_mb();
}
/* pthread porting shims, spinlock or fallback to mutex */
@@ -1842,6 +1863,7 @@ typedef struct {
/* Per process statistics and accounting info */
typedef struct {
uint64_t counter; /* number of bogo ops */
+ bool counter_ready; /* counter can be read */
struct tms tms; /* run time stats of process */
double start; /* wall clock start time */
double finish; /* wall clock stop time */
--
2.21.3

View File

@ -1,73 +0,0 @@
From c6e63723e33a65cb93348a3f32a1a5828159786f Mon Sep 17 00:00:00 2001
From: Colin Ian King <colin.king@canonical.com>
Date: Tue, 19 May 2020 12:37:24 +0100
Subject: [PATCH 12/28] stress-dev: add block device lseeks and force return to
be stashed
Block devices can be lseek'd so add this. For all lseeks stash the
return offset to force compiler to not optimize anything away.
Signed-off-by: Colin Ian King <colin.king@canonical.com>
---
stress-dev.c | 24 +++++++++++++++++-------
1 file changed, 17 insertions(+), 7 deletions(-)
diff --git a/stress-dev.c b/stress-dev.c
index 2eeb72c8cc21..b3c156ba5eb9 100644
--- a/stress-dev.c
+++ b/stress-dev.c
@@ -503,6 +503,8 @@ static void stress_dev_blk(
const int fd,
const char *devpath)
{
+ off_t offset;
+
(void)name;
(void)fd;
(void)devpath;
@@ -633,6 +635,14 @@ static void stress_dev_blk(
(void)ret;
}
#endif
+ offset = lseek(fd, 0, SEEK_END);
+ stress_uint64_put((uint64_t)offset);
+
+ offset = lseek(fd, 0, SEEK_SET);
+ stress_uint64_put((uint64_t)offset);
+
+ offset = lseek(fd, 0, SEEK_CUR);
+ stress_uint64_put((uint64_t)offset);
}
#if defined(__linux__)
@@ -1167,7 +1177,7 @@ static inline void stress_dev_rw(
int32_t loops)
{
int fd, ret;
- off_t off;
+ off_t offset;
struct stat buf;
struct pollfd fds[1];
fd_set rfds;
@@ -1231,12 +1241,12 @@ static inline void stress_dev_rw(
stress_dev_tty(args->name, fd, path);
#endif
- off = lseek(fd, 0, SEEK_SET);
- (void)off;
- off = lseek(fd, 0, SEEK_CUR);
- (void)off;
- off = lseek(fd, 0, SEEK_END);
- (void)off;
+ offset = lseek(fd, 0, SEEK_SET);
+ stress_uint64_put((uint64_t)offset);
+ offset = lseek(fd, 0, SEEK_CUR);
+ stress_uint64_put((uint64_t)offset);
+ offset = lseek(fd, 0, SEEK_END);
+ stress_uint64_put((uint64_t)offset);
if (stress_time_now() - t_start > threshold) {
timeout = true;
--
2.21.3

View File

@ -1,35 +0,0 @@
From 956ddff4f664d010d5997e87ffed415a205d0425 Mon Sep 17 00:00:00 2001
From: Colin Ian King <colin.king@canonical.com>
Date: Wed, 20 May 2020 09:31:27 +0100
Subject: [PATCH 13/28] core-shim: add delay before re-waiting
Signed-off-by: Colin Ian King <colin.king@canonical.com>
---
core-shim.c | 5 +++--
1 file changed, 3 insertions(+), 2 deletions(-)
diff --git a/core-shim.c b/core-shim.c
index 62c00ec991ef..5e659f1ebf99 100644
--- a/core-shim.c
+++ b/core-shim.c
@@ -1185,14 +1185,15 @@ pid_t shim_waitpid(pid_t pid, int *wstatus, int options)
break;
/*
- * Retry if EINTR unless we've have 100
+ * Retry if EINTR unless we've have 2 mins
* consecutive EINTRs then give up.
*/
if (!keep_stressing_flag()) {
kill(pid, SIGALRM);
- if (count++ > 100)
+ if (count++ > 120)
kill(pid, SIGKILL);
}
+ sleep(1);
}
return ret;
}
--
2.21.3

View File

@ -1,32 +0,0 @@
From 5773014116db4118a775598024964b6c469bd122 Mon Sep 17 00:00:00 2001
From: Colin Ian King <colin.king@canonical.com>
Date: Wed, 20 May 2020 13:52:18 +0100
Subject: [PATCH 14/28] core-out-of-memory: return EXIT_NO_RESOUCE on --oomable
option (LP: #1879696)
Don't call _exit() in a child stressor as this stops the bogo ops
metrics being propagated back to the parent stress-ng mail program.
Instead, return with EXIT_NO_RESOURCE to indicate process got OOM'd
because of being out of memory resources.
Signed-off-by: Colin Ian King <colin.king@canonical.com>
---
core-out-of-memory.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/core-out-of-memory.c b/core-out-of-memory.c
index 893d7d0e4352..1f397b392f1a 100644
--- a/core-out-of-memory.c
+++ b/core-out-of-memory.c
@@ -222,7 +222,7 @@ again:
"killer, bailing out "
"(instance %d)\n",
args->name, args->instance);
- _exit(0);
+ return EXIT_NO_RESOURCE;
} else {
stress_log_system_mem_info();
pr_dbg("%s: assuming killed by OOM "
--
2.21.3

View File

@ -1,29 +0,0 @@
From d5973f31f8ad6e1d2ee1eb5ca65c336961e42485 Mon Sep 17 00:00:00 2001
From: Colin Ian King <colin.king@canonical.com>
Date: Wed, 20 May 2020 14:43:16 +0100
Subject: [PATCH 15/28] stress-get: fix #ifdef check on getpagesize
The getpagesize syscall was not being exercised because of a
typo. Fix this.
Signed-off-by: Colin Ian King <colin.king@canonical.com>
---
stress-get.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/stress-get.c b/stress-get.c
index 1dfc7120fb06..9bfc196f5114 100644
--- a/stress-get.c
+++ b/stress-get.c
@@ -388,7 +388,7 @@ static int stress_get(const stress_args_t *args)
}
#endif
-#if defined(HAVE_GETPAGESISE)
+#if defined(HAVE_GETPAGESIZE)
ret = getpagesize();
(void)ret;
#endif
--
2.21.3

View File

@ -1,44 +0,0 @@
From b5e7448bd7a12426fb47df6809fa9e5b3bcbdfef Mon Sep 17 00:00:00 2001
From: Colin Ian King <colin.king@canonical.com>
Date: Thu, 21 May 2020 08:05:14 +0100
Subject: [PATCH 16/28] core-out-of-memory: return EXIT_SUCCESS on --oomable
option (LP: #1879782)
The --oomable flag allows tests to run until they are OOM'd. If they
died because of being OOM'd then they have run to the expected
termination point, so return EXIT_SUCCESS.
Signed-off-by: Colin Ian King <colin.king@canonical.com>
---
core-out-of-memory.c | 9 ++++++++-
1 file changed, 8 insertions(+), 1 deletion(-)
diff --git a/core-out-of-memory.c b/core-out-of-memory.c
index 1f397b392f1a..8b44338d9678 100644
--- a/core-out-of-memory.c
+++ b/core-out-of-memory.c
@@ -216,13 +216,20 @@ again:
/* If we got killed by OOM killer, re-start */
if (WTERMSIG(status) == SIGKILL) {
+ /*
+ * The --oomable flag was enabled, so
+ * the behaviour here is to no longer
+ * retry. The exit return is EXIT_SUCCESS
+ * because the child is allowed to terminate
+ * by being OOM'd.
+ */
if (g_opt_flags & OPT_FLAGS_OOMABLE) {
stress_log_system_mem_info();
pr_dbg("%s: assuming killed by OOM "
"killer, bailing out "
"(instance %d)\n",
args->name, args->instance);
- return EXIT_NO_RESOURCE;
+ return EXIT_SUCCESS;
} else {
stress_log_system_mem_info();
pr_dbg("%s: assuming killed by OOM "
--
2.21.3

View File

@ -1,90 +0,0 @@
From 5dfc5ed3e0d92507e482529aae21090278fbd677 Mon Sep 17 00:00:00 2001
From: Colin Ian King <colin.king@canonical.com>
Date: Thu, 21 May 2020 08:25:43 +0100
Subject: [PATCH 17/28] core-ftrace: remove setting of set_event_pid and
refactor code
Some of the ftrace settings were extraneous, remove these down to the
bare minimum required for ftrace to be enabled.
Signed-off-by: Colin Ian King <colin.king@canonical.com>
---
core-ftrace.c | 26 ++++++--------------------
1 file changed, 6 insertions(+), 20 deletions(-)
diff --git a/core-ftrace.c b/core-ftrace.c
index a612d5701315..d759ec8988e0 100644
--- a/core-ftrace.c
+++ b/core-ftrace.c
@@ -242,12 +242,12 @@ static int stress_ftrace_parse_stat_files(const char *path, const bool start)
}
/*
- * stress_ftrace_set_pid_file()
+ * stress_ftrace_add_pid()
* enable/append/stop tracing on specific events.
* if pid < 0 then tracing pids are all removed otherwise
* the pid is added to the tracing events
*/
-static void stress_ftrace_set_pid_file(const pid_t pid, const char *file)
+void stress_ftrace_add_pid(const pid_t pid)
{
char filename[PATH_MAX];
char *path;
@@ -255,11 +255,14 @@ static void stress_ftrace_set_pid_file(const pid_t pid, const char *file)
int fd;
ssize_t ret;
+ if (!(g_opt_flags & OPT_FLAGS_FTRACE))
+ return;
+
path = stress_ftrace_get_debugfs_path();
if (!path)
return;
- (void)snprintf(filename, sizeof(filename), "%s/tracing/%s", path, file);
+ (void)snprintf(filename, sizeof(filename), "%s/tracing/set_ftrace_pid", path);
fd = open(filename, O_WRONLY | (pid < 0 ? O_TRUNC : O_APPEND));
if (fd < 0)
return;
@@ -273,15 +276,6 @@ static void stress_ftrace_set_pid_file(const pid_t pid, const char *file)
(void)close(fd);
}
-void stress_ftrace_add_pid(const pid_t pid)
-{
- if (!(g_opt_flags & OPT_FLAGS_FTRACE))
- return;
-
- stress_ftrace_set_pid_file(pid, "set_event_pid");
- stress_ftrace_set_pid_file(pid, "set_ftrace_pid");
-}
-
/*
* stress_ftrace_start()
* start ftracing function calls
@@ -306,13 +300,6 @@ int stress_ftrace_start(void)
return -1;
}
- (void)snprintf(filename, sizeof(filename), "%s/tracing/current_tracer", path);
- if (system_write(filename, "nop", 3) < 0) {
- pr_inf("ftrace: cannot disable the current tracer, errno=%d (%s)\n",
- errno, strerror(errno));
- return -1;
- }
- (void)snprintf(filename, sizeof(filename), "%s/tracing/function_profile_enabled", path);
if (system_write(filename, "0", 1) < 0) {
pr_inf("ftrace: cannot enable function profiling, errno=%d (%s)\n",
errno, strerror(errno));
@@ -407,7 +394,6 @@ int stress_ftrace_stop(void)
}
(void)snprintf(filename, sizeof(filename), "%s/tracing/trace_stat", path);
-
if (stress_ftrace_parse_stat_files(path, false) < 0)
return -1;
stress_ftrace_analyze();
--
2.21.3

View File

@ -1,28 +0,0 @@
From 4eeac8cdc23b797634a08cd2973ef86636c5a8b9 Mon Sep 17 00:00:00 2001
From: Colin Ian King <colin.king@canonical.com>
Date: Thu, 21 May 2020 08:58:55 +0100
Subject: [PATCH 18/28] core-ftrace: fix removed filename setting statement
Put a snprintf statement back after removing it
Fixes: 5dfc5ed3e0d9 ("core-ftrace: remove setting of set_event_pid and refactor code")
Signed-off-by: Colin Ian King <colin.king@canonical.com>
---
core-ftrace.c | 1 +
1 file changed, 1 insertion(+)
diff --git a/core-ftrace.c b/core-ftrace.c
index d759ec8988e0..d743c964dbbd 100644
--- a/core-ftrace.c
+++ b/core-ftrace.c
@@ -300,6 +300,7 @@ int stress_ftrace_start(void)
return -1;
}
+ (void)snprintf(filename, sizeof(filename), "%s/tracing/function_profile_enabled", path);
if (system_write(filename, "0", 1) < 0) {
pr_inf("ftrace: cannot enable function profiling, errno=%d (%s)\n",
errno, strerror(errno));
--
2.21.3

View File

@ -1,257 +0,0 @@
From 6ec3d71be8bd09d45979c6fb8759088690871e1c Mon Sep 17 00:00:00 2001
From: Colin Ian King <colin.king@canonical.com>
Date: Thu, 21 May 2020 10:30:35 +0100
Subject: [PATCH 19/28] stress-vm: fix bit error checking when bogo-ops limits
reached
There are some vm methods that abort early when the bogo-ops limit
has been reached and then sanity check the all the data even though
the all the data has not been set because of the premature abort.
Fix this so that we only sanity check full runs of data.
Signed-off-by: Colin Ian King <colin.king@canonical.com>
---
stress-vm.c | 99 ++++++++++++++++++++++++++++-------------------------
1 file changed, 52 insertions(+), 47 deletions(-)
diff --git a/stress-vm.c b/stress-vm.c
index 6542f4b7c822..c776b3427c25 100644
--- a/stress-vm.c
+++ b/stress-vm.c
@@ -350,11 +350,11 @@ static size_t TARGET_CLONES stress_vm_moving_inversion(
bit_errors++;
*(ptr++) = ~val;
c++;
- if (UNLIKELY(max_ops && c >= max_ops))
- goto abort;
- if (UNLIKELY(!keep_stressing_flag()))
- goto abort;
}
+ if (UNLIKELY(max_ops && c >= max_ops))
+ goto ret;
+ if (UNLIKELY(!keep_stressing_flag()))
+ goto ret;
(void)stress_mincore_touch_pages(buf, sz);
@@ -363,22 +363,22 @@ static size_t TARGET_CLONES stress_vm_moving_inversion(
stress_mwc_seed(w, z);
for (bit_errors = 0, ptr = (uint64_t *)buf; ptr < buf_end; ) {
uint64_t val = stress_mwc64();
+
if (UNLIKELY(*(ptr++) != ~val))
bit_errors++;
c++;
- if (UNLIKELY(max_ops && c >= max_ops))
- goto abort;
- if (UNLIKELY(!keep_stressing_flag()))
- goto abort;
}
+ if (UNLIKELY(max_ops && c >= max_ops))
+ goto ret;
+ if (UNLIKELY(!keep_stressing_flag()))
+ goto ret;
stress_mwc_seed(w, z);
for (ptr = (uint64_t *)buf_end; ptr > (uint64_t *)buf; ) {
*--ptr = stress_mwc64();
- c++;
- if (UNLIKELY(max_ops && c >= max_ops))
- goto abort;
}
+ if (UNLIKELY(!keep_stressing_flag()))
+ goto ret;
inject_random_bit_errors(buf, sz);
@@ -386,26 +386,34 @@ static size_t TARGET_CLONES stress_vm_moving_inversion(
stress_mwc_seed(w, z);
for (ptr = (uint64_t *)buf_end; ptr > (uint64_t *)buf; ) {
uint64_t val = stress_mwc64();
+
if (UNLIKELY(*--ptr != val))
bit_errors++;
*ptr = ~val;
c++;
- if (UNLIKELY(max_ops && c >= max_ops))
- goto abort;
- if (UNLIKELY(!keep_stressing_flag()))
- goto abort;
}
+ if (UNLIKELY(max_ops && c >= max_ops))
+ goto ret;
+ if (UNLIKELY(!keep_stressing_flag()))
+ goto ret;
+
stress_mwc_seed(w, z);
for (ptr = (uint64_t *)buf_end; ptr > (uint64_t *)buf; ) {
uint64_t val = stress_mwc64();
+
if (UNLIKELY(*--ptr != ~val))
bit_errors++;
- if (UNLIKELY(!keep_stressing_flag()))
- goto abort;
+ c++;
}
+ if (UNLIKELY(max_ops && c >= max_ops))
+ goto ret;
+ if (UNLIKELY(!keep_stressing_flag()))
+ goto ret;
-abort:
+ret:
stress_vm_check("moving inversion", bit_errors);
+ if (UNLIKELY(max_ops && c >= max_ops))
+ c = max_ops;
set_counter(args, c);
return bit_errors;
@@ -438,40 +446,40 @@ static size_t TARGET_CLONES stress_vm_modulo_x(
for (i = 0; i < stride; i++) {
for (ptr = buf + i; ptr < buf_end; ptr += stride) {
*ptr = pattern;
- if (UNLIKELY(!keep_stressing_flag()))
- goto abort;
}
+ if (UNLIKELY(!keep_stressing_flag()))
+ goto ret;
for (ptr = buf; ptr < buf_end; ptr += stride) {
for (j = 0; j < i && ptr < buf_end; j++) {
*ptr++ = compliment;
c++;
- if (UNLIKELY(max_ops && c >= max_ops))
- goto abort;
}
- if (!keep_stressing_flag())
- goto abort;
+ if (UNLIKELY(!keep_stressing_flag()))
+ goto ret;
ptr++;
for (j = i + 1; j < stride && ptr < buf_end; j++) {
*ptr++ = compliment;
c++;
- if (UNLIKELY(max_ops && c >= max_ops))
- goto abort;
}
if (UNLIKELY(!keep_stressing_flag()))
- goto abort;
+ goto ret;
}
inject_random_bit_errors(buf, sz);
for (ptr = buf + i; ptr < buf_end; ptr += stride) {
if (UNLIKELY(*ptr != pattern))
bit_errors++;
- if (UNLIKELY(!keep_stressing_flag()))
- return bit_errors;
}
+ if (UNLIKELY(!keep_stressing_flag()))
+ break;
+ if (UNLIKELY(max_ops && c >= max_ops))
+ break;
}
-abort:
+ if (UNLIKELY(max_ops && c >= max_ops))
+ c = max_ops;
stress_vm_check("modulo X", bit_errors);
+ret:
set_counter(args, c);
return bit_errors;
@@ -676,9 +684,6 @@ static size_t TARGET_CLONES stress_vm_gray(
if (UNLIKELY(!keep_stressing_flag()))
return 0;
*ptr = (v >> 1) ^ v;
- c++;
- if (UNLIKELY(max_ops && c >= max_ops))
- break;
}
(void)stress_mincore_touch_pages(buf, sz);
inject_random_bit_errors(buf, sz);
@@ -724,18 +729,15 @@ static size_t TARGET_CLONES stress_vm_incdec(
for (ptr = buf; ptr < buf_end; ptr++) {
*ptr += val;
- c++;
- if (UNLIKELY(max_ops && c >= max_ops))
- break;
}
(void)stress_mincore_touch_pages(buf, sz);
inject_random_bit_errors(buf, sz);
for (ptr = buf; ptr < buf_end; ptr++) {
*ptr -= val;
- c++;
- if (UNLIKELY(max_ops && c >= max_ops))
- break;
}
+ c += sz;
+ if (UNLIKELY(max_ops && c >= max_ops))
+ c = max_ops;
for (ptr = buf; ptr < buf_end; ptr++) {
if (UNLIKELY(*ptr != 0))
@@ -1253,9 +1255,6 @@ static size_t TARGET_CLONES stress_vm_galpat_zero(
break;
}
}
- c++;
- if (UNLIKELY(max_ops && c >= max_ops))
- break;
}
(void)stress_mincore_touch_pages(buf, sz);
inject_random_bit_errors(buf, sz);
@@ -1270,14 +1269,18 @@ static size_t TARGET_CLONES stress_vm_galpat_zero(
bits_set += stress_vm_count_bits(*(ptr + 6));
bits_set += stress_vm_count_bits(*(ptr + 7));
+ c++;
if (UNLIKELY(!keep_stressing_flag()))
- break;
+ goto ret;
}
if (bits_set != bits_bad)
bit_errors += UNSIGNED_ABS(bits_set, bits_bad);
stress_vm_check("galpat-zero", bit_errors);
+ret:
+ if (UNLIKELY(max_ops && c >= max_ops))
+ c = max_ops;
set_counter(args, c);
return bit_errors;
@@ -1315,9 +1318,6 @@ static size_t TARGET_CLONES stress_vm_galpat_one(
break;
}
}
- c++;
- if (UNLIKELY(max_ops && c >= max_ops))
- break;
}
(void)stress_mincore_touch_pages(buf, sz);
inject_random_bit_errors(buf, sz);
@@ -1331,14 +1331,19 @@ static size_t TARGET_CLONES stress_vm_galpat_one(
bits_set += stress_vm_count_bits(~(*(ptr + 5)));
bits_set += stress_vm_count_bits(~(*(ptr + 6)));
bits_set += stress_vm_count_bits(~(*(ptr + 7)));
+
+ c++;
if (UNLIKELY(!keep_stressing_flag()))
- break;
+ goto ret;
}
if (bits_set != bits_bad)
bit_errors += UNSIGNED_ABS(bits_set, bits_bad);
stress_vm_check("galpat-one", bit_errors);
+ret:
+ if (UNLIKELY(max_ops && c >= max_ops))
+ c = max_ops;
set_counter(args, c);
return bit_errors;
--
2.21.3

View File

@ -1,107 +0,0 @@
From 71bce95447ee977203d8225ddf29a40e692cd59d Mon Sep 17 00:00:00 2001
From: Colin Ian King <colin.king@canonical.com>
Date: Thu, 21 May 2020 11:15:25 +0100
Subject: [PATCH 20/28] Fix --seq mode checksum with multiple stressors and
sanity checking
The sanity checking of bogo ops is using the same base offset of
the checksum pointer for each round of stressor being run. Fix this
by ensuring it is incremented per run so that the sanity checking
checksumming and bogo op counter is stashed in the correct slot.
Signed-off-by: Colin Ian King <colin.king@canonical.com>
---
stress-ng.c | 23 +++++++++++++----------
1 file changed, 13 insertions(+), 10 deletions(-)
diff --git a/stress-ng.c b/stress-ng.c
index 66ee5d15fa37..dcfc1991c216 100644
--- a/stress-ng.c
+++ b/stress-ng.c
@@ -1655,13 +1655,13 @@ static void MLOCKED_TEXT stress_run(
stress_proc_info_t *procs_list,
double *duration,
bool *success,
- bool *resource_success
+ bool *resource_success,
+ stress_checksum_t **checksum
)
{
double time_start, time_finish;
int32_t n_procs, j;
const int32_t total_procs = get_total_num_procs(procs_list);
- stress_checksum_t *checksum = g_shared->checksums;
int32_t sched;
@@ -1674,7 +1674,7 @@ static void MLOCKED_TEXT stress_run(
time_start = stress_time_now();
pr_dbg("starting stressors\n");
for (n_procs = 0; n_procs < total_procs; n_procs++) {
- for (g_proc_current = procs_list; g_proc_current; g_proc_current = g_proc_current->next, checksum++) {
+ for (g_proc_current = procs_list; g_proc_current; g_proc_current = g_proc_current->next, (*checksum)++) {
if (g_opt_timeout && (stress_time_now() - time_start > g_opt_timeout))
goto abort;
@@ -1779,12 +1779,12 @@ again:
stats->counter_ready = true;
stats->counter = 0;
- (void)memset(checksum, 0, sizeof(*checksum));
+ (void)memset(*checksum, 0, sizeof(**checksum));
rc = g_proc_current->stressor->info->stressor(&args);
pr_fail_check(&rc);
if (rc == EXIT_SUCCESS) {
stats->run_ok = true;
- checksum->data.run_ok = true;
+ (*checksum)->data.run_ok = true;
}
/*
* Bogo ops counter should be OK for reading,
@@ -1796,9 +1796,9 @@ again:
name);
rc = EXIT_FAILURE;
}
- stats->checksum = checksum;
- checksum->data.counter = *args.counter;
- stress_hash_checksum(checksum);
+ stats->checksum = *checksum;
+ (*checksum)->data.counter = *args.counter;
+ stress_hash_checksum(*checksum);
}
#if defined(STRESS_PERF_STATS) && defined(HAVE_LINUX_PERF_EVENT_H)
if (g_opt_flags & OPT_FLAGS_PERF_STATS) {
@@ -2846,6 +2846,7 @@ static inline void stress_run_sequential(
bool *resource_success)
{
stress_proc_info_t *pi;
+ stress_checksum_t *checksum = g_shared->checksums;
/*
* Step through each stressor one by one
@@ -2854,7 +2855,7 @@ static inline void stress_run_sequential(
stress_proc_info_t *next = pi->next;
pi->next = NULL;
- stress_run(pi, duration, success, resource_success);
+ stress_run(pi, duration, success, resource_success, &checksum);
pi->next = next;
}
@@ -2869,10 +2870,12 @@ static inline void stress_run_parallel(
bool *success,
bool *resource_success)
{
+ stress_checksum_t *checksum = g_shared->checksums;
+
/*
* Run all stressors in parallel
*/
- stress_run(procs_head, duration, success, resource_success);
+ stress_run(procs_head, duration, success, resource_success, &checksum);
}
/*
--
2.21.3

View File

@ -1,51 +0,0 @@
From 8f1334931e38918ac02cf4aef9f62ec3bee377b5 Mon Sep 17 00:00:00 2001
From: Colin Ian King <colin.king@canonical.com>
Date: Thu, 21 May 2020 11:17:57 +0100
Subject: [PATCH 21/28] kernel-coverage.sh: move the quick spin through
stressors to the end of the test
Keeps the coverage in the original order, move these to the end
Signed-off-by: Colin Ian King <colin.king@canonical.com>
---
kernel-coverage.sh | 18 +++++++++---------
1 file changed, 9 insertions(+), 9 deletions(-)
diff --git a/kernel-coverage.sh b/kernel-coverage.sh
index e26738e337c8..7b8f79033598 100755
--- a/kernel-coverage.sh
+++ b/kernel-coverage.sh
@@ -58,15 +58,6 @@ DURATION=60
do_stress --all 1
-#
-# Quick spin through all the classes of stressors with ftrace enabled
-#
-DURATION=1
-for CLASS in cpu-cache cpu device filesystem interrupt io memory network os pipe scheduler security vm
-do
- sudo $STRESS_NG --class $CLASS --ftrace --seq 1 -v --timestamp --syslog -t $DURATION
-done
-
DURATION=30
do_stress --cpu 0 --taskset 0,2 --ignite-cpu
do_stress --cpu 0 --taskset 1,2,3
@@ -196,5 +187,14 @@ if [ -e $PERF_PARANOID ]; then
(echo $paranoid_saved | sudo tee $PERF_PARANOID) > /dev/null
fi
+#
+# Quick spin through all the classes of stressors with ftrace enabled
+#
+DURATION=1
+for CLASS in cpu-cache cpu device filesystem interrupt io memory network os pipe scheduler security vm
+do
+ sudo $STRESS_NG --class $CLASS --ftrace --seq 1 -v --timestamp --syslog -t $DURATION
+done
+
sudo lcov -c -o kernel.info
sudo genhtml -o html kernel.info
--
2.21.3

View File

@ -1,43 +0,0 @@
From 19594f15ac2bf6ce84492ab7d17b1133aac50bde Mon Sep 17 00:00:00 2001
From: Colin Ian King <colin.king@canonical.com>
Date: Thu, 21 May 2020 11:30:43 +0100
Subject: [PATCH 22/28] shim_waitpid: allow a few retries before throttling
retry
The retry sleep kicks in too early, allow several retries before
throttling back and sleeping per iteration. Makes normnal termination
waits more responsive on the waiting parent.
Signed-off-by: Colin Ian King <colin.king@canonical.com>
---
core-shim.c | 6 ++++--
1 file changed, 4 insertions(+), 2 deletions(-)
diff --git a/core-shim.c b/core-shim.c
index 5e659f1ebf99..17935f05cdd3 100644
--- a/core-shim.c
+++ b/core-shim.c
@@ -1184,16 +1184,18 @@ pid_t shim_waitpid(pid_t pid, int *wstatus, int options)
if ((ret >= 0) || (errno != EINTR))
break;
+ count++;
/*
* Retry if EINTR unless we've have 2 mins
* consecutive EINTRs then give up.
*/
if (!keep_stressing_flag()) {
kill(pid, SIGALRM);
- if (count++ > 120)
+ if (count > 120)
kill(pid, SIGKILL);
}
- sleep(1);
+ if (count > 10)
+ sleep(1);
}
return ret;
}
--
2.21.3

View File

@ -1,27 +0,0 @@
From 232b9282522effb16c2940eb403d87079bbd8719 Mon Sep 17 00:00:00 2001
From: Colin Ian King <colin.king@canonical.com>
Date: Thu, 21 May 2020 11:33:00 +0100
Subject: [PATCH 23/28] stress-dev: voidify pthread_join return, we don't care
about it
Signed-off-by: Colin Ian King <colin.king@canonical.com>
---
stress-dev.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/stress-dev.c b/stress-dev.c
index b3c156ba5eb9..224bc48c5a3a 100644
--- a/stress-dev.c
+++ b/stress-dev.c
@@ -1607,7 +1607,7 @@ again:
for (i = 0; i < MAX_DEV_THREADS; i++) {
if (ret[i] == 0)
- pthread_join(pthreads[i], NULL);
+ (void)pthread_join(pthreads[i], NULL);
}
stress_hash_delete(dev_hash_table);
_exit(EXIT_SUCCESS);
--
2.21.3

View File

@ -1,27 +0,0 @@
From a268e6664fd2d840b77bf4c30d5e8ccf62b71576 Mon Sep 17 00:00:00 2001
From: Colin Ian King <colin.king@canonical.com>
Date: Thu, 21 May 2020 11:33:55 +0100
Subject: [PATCH 24/28] stress-inode-flags: voidify pthread_join return, we
don't care about it
Signed-off-by: Colin Ian King <colin.king@canonical.com>
---
stress-inode-flags.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/stress-inode-flags.c b/stress-inode-flags.c
index b6ba3a3c7f8b..e1ad171d961f 100644
--- a/stress-inode-flags.c
+++ b/stress-inode-flags.c
@@ -250,7 +250,7 @@ static int stress_inode_flags(const stress_args_t *args)
for (i = 0; i < MAX_INODE_FLAG_THREADS; i++) {
if (ret[i] == 0) {
- pthread_join(pthreads[i], NULL);
+ (void)pthread_join(pthreads[i], NULL);
if (pa[i].pthread_ret < 0)
rc = EXIT_FAILURE;
}
--
2.21.3

View File

@ -1,27 +0,0 @@
From fcb1e50c88eb6b0c9b13b4c209ffe709943e703d Mon Sep 17 00:00:00 2001
From: Colin Ian King <colin.king@canonical.com>
Date: Thu, 21 May 2020 11:34:26 +0100
Subject: [PATCH 25/28] stress-madvise: voidify pthread_join return, we don't
care about it
Signed-off-by: Colin Ian King <colin.king@canonical.com>
---
stress-madvise.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/stress-madvise.c b/stress-madvise.c
index 40d8e2dc4038..b9ecf038c13d 100644
--- a/stress-madvise.c
+++ b/stress-madvise.c
@@ -346,7 +346,7 @@ static int stress_madvise(const stress_args_t *args)
}
for (i = 0; i < NUM_PTHREADS; i++) {
if (rets[i] == 0)
- pthread_join(pthreads[i], NULL);
+ (void)pthread_join(pthreads[i], NULL);
}
}
#else
--
2.21.3

View File

@ -1,32 +0,0 @@
From c352fe6413a986d680ee838c1604185e79122bc2 Mon Sep 17 00:00:00 2001
From: Colin Ian King <colin.king@canonical.com>
Date: Thu, 21 May 2020 11:36:22 +0100
Subject: [PATCH 26/28] stress-memthrash: silently ignore ESRCH pthread_join
failures
This is not strictly an error conditions, so ignore it.
Signed-off-by: Colin Ian King <colin.king@canonical.com>
---
stress-memthrash.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/stress-memthrash.c b/stress-memthrash.c
index 4de645181a75..93f359518693 100644
--- a/stress-memthrash.c
+++ b/stress-memthrash.c
@@ -543,9 +543,10 @@ reap:
for (i = 0; i < max_threads; i++) {
if (!ret[i]) {
ret[i] = pthread_join(pthreads[i], NULL);
- if (ret[i])
+ if (ret[i] && (ret[i] != ESRCH)) {
pr_fail("%s: pthread join failed, errno=%d (%s)\n",
args->name, ret[i], strerror(ret[i]));
+ }
}
}
reap_mem:
--
2.21.3

View File

@ -1,29 +0,0 @@
From 1b4471bbd234f962a513f77d183c43cf5e8833d3 Mon Sep 17 00:00:00 2001
From: John Kacur <jkacur@redhat.com>
Date: Thu, 21 May 2020 14:50:25 -0400
Subject: [PATCH 27/28] stress-ng: README: update libsctp name for RHEL,
fedora, related distros
update the libsctp name for RHEL, fedora and similar distros
Signed-off-by: John Kacur <jkacur@redhat.com>
---
README | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/README b/README
index a4e83d059ee6..ac675b075607 100644
--- a/README
+++ b/README
@@ -54,7 +54,7 @@ RHEL, Fedora, Centos:
* libgcrypt-devel
* Judy-devel
* keyutils-libs
- * libsctp-devel
+ * lksctp-tools-devel
* zlib-devel
SUSE:
--
2.21.3

View File

@ -1,30 +0,0 @@
From b0a98280be341438efeb548312dde8f87e342a30 Mon Sep 17 00:00:00 2001
From: Colin Ian King <colin.king@canonical.com>
Date: Fri, 22 May 2020 12:01:12 +0100
Subject: [PATCH 28/28] stress-ng: fix long form if -x option, use "exclude"
instead of "list"
Fix the long form of -x, use --exclude. Thanks to Vegard Nossum for
spotting this.
Signed-off-by: Colin Ian King <colin.king@canonical.com>
---
stress-ng.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/stress-ng.c b/stress-ng.c
index dcfc1991c216..1872ee1bf1bb 100644
--- a/stress-ng.c
+++ b/stress-ng.c
@@ -962,7 +962,7 @@ static const stress_help_t help_generic[] = {
{ NULL, "verify", "verify results (not available on all tests)" },
{ "V", "version", "show version" },
{ "Y", "yaml file", "output results to YAML formatted filed" },
- { "x", "list", "list of stressors to exclude (not run)" },
+ { "x", "exclude", "list of stressors to exclude (not run)" },
{ NULL, NULL, NULL }
};
--
2.21.3

View File

@ -1,21 +1,20 @@
Name: rteval-loads Name: rteval-loads
Version: 1.4 Version: 1.4
Release: 11%{?dist} Release: 13%{?dist}
Summary: Source files for rteval loads Summary: Source files for rteval loads
Group: Development/Tools Group: Development/Tools
License: GPLv2 License: GPLv2
URL: https://git.kernel.org/pub/scm/utils/rteval/rteval.git URL: https://git.kernel.org/pub/scm/utils/rteval/rteval.git
Source0: https://www.kernel.org/pub/linux/kernel/v5.x/linux-5.7.tar.xz Source0: https://www.kernel.org/pub/linux/kernel/v5.x/linux-5.7.tar.xz
BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n)
%package -n stress-ng %package -n stress-ng
Version: 0.11.10 Version: 0.12.06
Release: 4%{?dist} Release: 2%{?dist}
Summary: Stress test a computer system in various ways Summary: Stress test a computer system in various ways
Source1: https://kernel.ubuntu.com/~cking/tarballs/stress-ng/stress-ng-%{version}.tar.xz Source1: https://kernel.ubuntu.com/~cking/tarballs/stress-ng/stress-ng-%{version}.tar.xz
BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n) BuildRequires: make
Requires: gcc binutils make kernel-headers
#BuildArch: noarch
BuildRequires: gcc BuildRequires: gcc
BuildRequires: glibc-devel BuildRequires: glibc-devel
BuildRequires: kernel-headers BuildRequires: kernel-headers
@ -23,44 +22,12 @@ BuildRequires: keyutils-libs-devel
BuildRequires: libaio-devel BuildRequires: libaio-devel
BuildRequires: libattr-devel BuildRequires: libattr-devel
BuildRequires: libcap-devel BuildRequires: libcap-devel
BuildRequires: libgcrypt-devel
BuildRequires: lksctp-tools-devel BuildRequires: lksctp-tools-devel
BuildRequires: libatomic
BuildRequires: zlib-devel BuildRequires: zlib-devel
ExcludeArch: ppc64
ExcludeArch: ppc64le
# The following architecture is excluded because stress-ng is alreadz
# available there
ExcludeArch: aarch64
#Patches #Patches
Patch1: 0001-stress-hdd-use-preadv-preadv2-pwritev-pwritev2.patch
Patch2: 0002-syscalls-update-preadv-preadv2-and-pwritev-entries.patch
Patch3: 0003-stress-sock-add-a-few-more-ioctls-to-exercise.patch
Patch4: 0004-stress-sem-sysv-exercise-some-invalid-options-to-get.patch
Patch5: 0005-stress-shm-sysv-exercise-NUMA-mempolicy-on-shm.patch
Patch6: 0006-stress-shm-sysv-exercise-shmctl-and-shmdt-race-on-ch.patch
Patch7: 0007-stress-mq-add-SIGEV_SIGNAL-events-to-exercise-kernel.patch
Patch8: 0008-stress-ng-add-checksum-sanity-check-on-bogo-ops-stat.patch
Patch9: 0009-stress-dev-remove-sleep-and-return-EXIT_SUCCESS-on-c.patch
Patch10: 0010-core-shim-rework-waitpid-again-terminate-child-on-EI.patch
Patch11: 0011-Add-memory-barriers-an-ready-flag-to-check-if-counte.patch
Patch12: 0012-stress-dev-add-block-device-lseeks-and-force-return-.patch
Patch13: 0013-core-shim-add-delay-before-re-waiting.patch
Patch14: 0014-core-out-of-memory-return-EXIT_NO_RESOUCE-on-oomable.patch
Patch15: 0015-stress-get-fix-ifdef-check-on-getpagesize.patch
Patch16: 0016-core-out-of-memory-return-EXIT_SUCCESS-on-oomable-op.patch
Patch17: 0017-core-ftrace-remove-setting-of-set_event_pid-and-refa.patch
Patch18: 0018-core-ftrace-fix-removed-filename-setting-statement.patch
Patch19: 0019-stress-vm-fix-bit-error-checking-when-bogo-ops-limit.patch
Patch20: 0020-Fix-seq-mode-checksum-with-multiple-stressors-and-sa.patch
Patch21: 0021-kernel-coverage.sh-move-the-quick-spin-through-stres.patch
Patch22: 0022-shim_waitpid-allow-a-few-retries-before-throttling-r.patch
Patch23: 0023-stress-dev-voidify-pthread_join-return-we-don-t-care.patch
Patch24: 0024-stress-inode-flags-voidify-pthread_join-return-we-do.patch
Patch25: 0025-stress-madvise-voidify-pthread_join-return-we-don-t-.patch
Patch26: 0026-stress-memthrash-silently-ignore-ESRCH-pthread_join-.patch
Patch27: 0027-stress-ng-README-update-libsctp-name-for-RHEL-fedora.patch
Patch28: 0028-stress-ng-fix-long-form-if-x-option-use-exclude-inst.patch
%description %description
This package provides source code for system loads used by the rteval package This package provides source code for system loads used by the rteval package
@ -72,34 +39,6 @@ system kernel interfaces.
%prep %prep
%setup -q -b1 -n stress-ng-%{version} %setup -q -b1 -n stress-ng-%{version}
%patch1 -p1
%patch2 -p1
%patch3 -p1
%patch4 -p1
%patch5 -p1
%patch6 -p1
%patch7 -p1
%patch8 -p1
%patch9 -p1
%patch10 -p1
%patch11 -p1
%patch12 -p1
%patch13 -p1
%patch14 -p1
%patch15 -p1
%patch16 -p1
%patch17 -p1
%patch18 -p1
%patch19 -p1
%patch20 -p1
%patch21 -p1
%patch22 -p1
%patch23 -p1
%patch24 -p1
%patch25 -p1
%patch26 -p1
%patch27 -p1
%patch28 -p1
%build -n stress-ng %build -n stress-ng
export CFLAGS="%{optflags}" export CFLAGS="%{optflags}"
@ -111,9 +50,13 @@ rm -rf ${RPM_BUILD_ROOT}
mkdir -p ${RPM_BUILD_ROOT} mkdir -p ${RPM_BUILD_ROOT}
mkdir -p ${RPM_BUILD_ROOT}/usr/share/rteval/loadsource mkdir -p ${RPM_BUILD_ROOT}/usr/share/rteval/loadsource
install -m 644 %{SOURCE0} ${RPM_BUILD_ROOT}/usr/share/rteval/loadsource install -m 644 %{SOURCE0} ${RPM_BUILD_ROOT}/usr/share/rteval/loadsource
mkdir -p ${RPM_BUILD_ROOT}/%{_datadir}/stress-ng/example-jobs
mkdir -p ${RPM_BUILD_ROOT}/%{_datadir}/bash-completion/completions # stress-ng
make DESTDIR=${RPM_BUILD_ROOT} install install -p -m 755 -D stress-ng %{buildroot}%{_bindir}/stress-ng
install -p -m 644 -D stress-ng.1 %{buildroot}%{_mandir}/man1/stress-ng.1
mkdir -p %{buildroot}%{_datadir}/bash-completion/completions
install -pm 644 bash-completion/stress-ng \
%{buildroot}%{_datadir}/bash-completion/completions/stress-ng
%clean %clean
rm -rf ${RPM_BUILD_ROOT} rm -rf ${RPM_BUILD_ROOT}
@ -125,13 +68,25 @@ rm -rf ${RPM_BUILD_ROOT}
%doc %doc
%files -n stress-ng %files -n stress-ng
%license COPYING
%doc README
%{_bindir}/stress-ng %{_bindir}/stress-ng
%{_datadir}/bash-completion/completions/stress-ng
%{_mandir}/man1/stress-ng.1.gz %{_mandir}/man1/stress-ng.1.gz
%{_datadir}/stress-ng/example-jobs/*.job %dir %{_datadir}/bash-completion
%dir %{_datadir}/bash-completion/completions
%{_datadir}/bash-completion/completions/stress-ng
%changelog %changelog
* Fri Jan 08 2021 John Kacur <jkacur@redhat.com> / 1.4-11 * Wed Apr 28 2021 John Kacur <jkacur@redhat.com> - 1.14-13
- Rebuild rteval-build with a fixed binutils in brew
- Bump the release number of stress-ng as well
Resolves: rhbz#1954451
* Mon Apr 12 2021 John Kacur <jkacur@redhat.com> - 1.14-12
- Update stress-ng to 0.12.06 upstream
Resolves: rhbz#1947648
* Fri Jan 08 2021 John Kacur <jkacur@redhat.com> - 1.4-11
- Update the URL source to the correct current location. - Update the URL source to the correct current location.
Resolves: rhbz#1914420 Resolves: rhbz#1914420