From bd40d05c6b0b4ddb531d8a1392346e532c3987f0 Mon Sep 17 00:00:00 2001 From: John Kacur Date: Tue, 22 Nov 2022 10:32:59 -0500 Subject: [PATCH] Rebase to upstream V0.15.00 Add the following upstream patches stress-shm: move /dev/shm check to earlier in the setup phase stress-shm: skip stressor if /dev/shm is not mounted with tmpfs on linux stress-sysfs: check for zero sysfs entries after pruning the directory Resolves: rhbz#2144070 Signed-off-by: John Kacur --- .gitignore | 1 + ...ck-for-zero-sysfs-entries-after-prun.patch | 55 +++++++++++++++++++ ...stressor-if-dev-shm-is-not-mounted-w.patch | 37 +++++++++++++ ...dev-shm-check-to-earlier-in-the-setu.patch | 55 +++++++++++++++++++ sources | 2 +- stress-ng.spec | 19 ++++++- 6 files changed, 167 insertions(+), 2 deletions(-) create mode 100644 0001-stress-sysfs-check-for-zero-sysfs-entries-after-prun.patch create mode 100644 0002-stress-shm-skip-stressor-if-dev-shm-is-not-mounted-w.patch create mode 100644 0003-stress-shm-move-dev-shm-check-to-earlier-in-the-setu.patch diff --git a/.gitignore b/.gitignore index e40f9aa..07d5874 100644 --- a/.gitignore +++ b/.gitignore @@ -1 +1,2 @@ +*.swp /stress-ng-*.tar.xz diff --git a/0001-stress-sysfs-check-for-zero-sysfs-entries-after-prun.patch b/0001-stress-sysfs-check-for-zero-sysfs-entries-after-prun.patch new file mode 100644 index 0000000..ddac617 --- /dev/null +++ b/0001-stress-sysfs-check-for-zero-sysfs-entries-after-prun.patch @@ -0,0 +1,55 @@ +From 6a22f648bd3452c83c5f88ec530d496fefe5e9a0 Mon Sep 17 00:00:00 2001 +From: Colin Ian King +Date: Mon, 21 Nov 2022 12:16:47 +0000 +Subject: [PATCH 1/3] stress-sysfs: check for zero sysfs entries after pruning + the directory + +Signed-off-by: Colin Ian King +--- + stress-sysfs.c | 18 +++++++++++------- + 1 file changed, 11 insertions(+), 7 deletions(-) + +diff --git a/stress-sysfs.c b/stress-sysfs.c +index 00fe9ba08100..24267d00ee5a 100644 +--- a/stress-sysfs.c ++++ b/stress-sysfs.c +@@ -634,14 +634,11 @@ static int stress_sysfs(const stress_args_t *args) + } + + n = scandir("/sys", &dlist, NULL, alphasort); +- if (n <= 0) { +- if (args->instance == 0) +- pr_inf_skip("%s: no /sys entries found, skipping stressor\n", args->name); +- stress_dirent_list_free(dlist, n); +- (void)munmap((void *)ctxt, sizeof(*ctxt)); +- return EXIT_NO_RESOURCE; +- } ++ if (n <= 0) ++ goto exit_no_sysfs_entries; + n = stress_dirent_list_prune(dlist, n); ++ if (n <= 0) ++ goto exit_no_sysfs_entries; + + os_release = 0; + #if defined(HAVE_UNAME) && \ +@@ -806,10 +803,17 @@ finish: + (void)close(ctxt->kmsgfd); + (void)shim_pthread_spin_destroy(&lock); + ++exit_free: + stress_dirent_list_free(dlist, n); + (void)munmap((void *)ctxt, sizeof(*ctxt)); + + return rc; ++ ++exit_no_sysfs_entries: ++ if (args->instance == 0) ++ pr_inf_skip("%s: no /sys entries found, skipping stressor\n", args->name); ++ rc = EXIT_NO_RESOURCE; ++ goto exit_free; + } + + stressor_info_t stress_sysfs_info = { +-- +2.38.1 + diff --git a/0002-stress-shm-skip-stressor-if-dev-shm-is-not-mounted-w.patch b/0002-stress-shm-skip-stressor-if-dev-shm-is-not-mounted-w.patch new file mode 100644 index 0000000..495fd4d --- /dev/null +++ b/0002-stress-shm-skip-stressor-if-dev-shm-is-not-mounted-w.patch @@ -0,0 +1,37 @@ +From f424f5b774b7cb0fd7939d28e68db6fa977baea1 Mon Sep 17 00:00:00 2001 +From: Colin Ian King +Date: Mon, 21 Nov 2022 12:45:11 +0000 +Subject: [PATCH 2/3] stress-shm: skip stressor if /dev/shm is not mounted with + tmpfs on linux + +Signed-off-by: Colin Ian King +--- + stress-shm.c | 12 ++++++++++++ + 1 file changed, 12 insertions(+) + +diff --git a/stress-shm.c b/stress-shm.c +index 91bcd961aeb1..4e6327ac97d4 100644 +--- a/stress-shm.c ++++ b/stress-shm.c +@@ -122,6 +122,18 @@ static int stress_shm_posix_child( + const size_t page_size = args->page_size; + struct sigaction sa; + ++#if defined(__linux__) ++ /* ++ * /dev/shm should be mounted with tmpfs and ++ * be writeable, if not shm_open will fail ++ */ ++ if (access("/dev/shm", W_OK) < 0) { ++ pr_inf("%s: cannot access /dev/shm for writes, errno=%d (%s) skipping stressor\n", ++ args->name, errno, strerror(errno)); ++ return EXIT_NO_RESOURCE; ++ } ++#endif ++ + addrs = calloc(shm_posix_objects, sizeof(*addrs)); + if (!addrs) { + pr_fail("%s: calloc on addrs failed, out of memory\n", args->name); +-- +2.38.1 + diff --git a/0003-stress-shm-move-dev-shm-check-to-earlier-in-the-setu.patch b/0003-stress-shm-move-dev-shm-check-to-earlier-in-the-setu.patch new file mode 100644 index 0000000..831ac96 --- /dev/null +++ b/0003-stress-shm-move-dev-shm-check-to-earlier-in-the-setu.patch @@ -0,0 +1,55 @@ +From 7681f2d05470b8c8850346bcf12e525f628941b3 Mon Sep 17 00:00:00 2001 +From: Colin Ian King +Date: Mon, 21 Nov 2022 12:46:54 +0000 +Subject: [PATCH 3/3] stress-shm: move /dev/shm check to earlier in the setup + phase + +Signed-off-by: Colin Ian King +--- + stress-shm.c | 23 +++++++++++------------ + 1 file changed, 11 insertions(+), 12 deletions(-) + +diff --git a/stress-shm.c b/stress-shm.c +index 4e6327ac97d4..a9c26498024e 100644 +--- a/stress-shm.c ++++ b/stress-shm.c +@@ -122,18 +122,6 @@ static int stress_shm_posix_child( + const size_t page_size = args->page_size; + struct sigaction sa; + +-#if defined(__linux__) +- /* +- * /dev/shm should be mounted with tmpfs and +- * be writeable, if not shm_open will fail +- */ +- if (access("/dev/shm", W_OK) < 0) { +- pr_inf("%s: cannot access /dev/shm for writes, errno=%d (%s) skipping stressor\n", +- args->name, errno, strerror(errno)); +- return EXIT_NO_RESOURCE; +- } +-#endif +- + addrs = calloc(shm_posix_objects, sizeof(*addrs)); + if (!addrs) { + pr_fail("%s: calloc on addrs failed, out of memory\n", args->name); +@@ -384,6 +372,17 @@ static int stress_shm(const stress_args_t *args) + } + orig_sz = sz = shm_posix_bytes & ~(page_size - 1); + ++#if defined(__linux__) ++ /* ++ * /dev/shm should be mounted with tmpfs and ++ * be writeable, if not shm_open will fail ++ */ ++ if (access("/dev/shm", W_OK) < 0) { ++ pr_inf("%s: cannot access /dev/shm for writes, errno=%d (%s) skipping stressor\n", ++ args->name, errno, strerror(errno)); ++ return EXIT_NO_RESOURCE; ++ } ++#endif + stress_set_proc_state(args->name, STRESS_STATE_RUN); + + while (keep_stressing_flag() && retry) { +-- +2.38.1 + diff --git a/sources b/sources index f9b5ce3..7cc48a7 100644 --- a/sources +++ b/sources @@ -1 +1 @@ -SHA512 (stress-ng-0.14.06.tar.xz) = 2019733a0d07dc56e9d6834c19714e4e72adef9bee6899e88612b532e0326fbac2fb716300d9082db849968bd0f9de4a7c388dcd7ed3a289d3995eeff9f0c9ca +SHA512 (stress-ng-0.15.00.tar.xz) = ca7f3e89285d1a4651d90e73132eefa51eb3449c1018871c9adce155288e42de2a67aaa3d53053daacb65cbd6acece471334423ec208075ef46db53a51a12971 diff --git a/stress-ng.spec b/stress-ng.spec index b607d96..9e355a6 100644 --- a/stress-ng.spec +++ b/stress-ng.spec @@ -1,5 +1,5 @@ Name: stress-ng -Version: 0.14.06 +Version: 0.15.00 Release: 1%{?dist} Summary: Stress test a computer system in various ways @@ -7,6 +7,9 @@ License: GPLv2+ URL: https://github.com/ColinIanKing/%{name}/tarball Source0: https://github.com/ColinIanKing/%{name}/tarball/%{name}-%{version}.tar.xz +# Work around for ld.gold error +%undefine _package_note_flags + BuildRequires: make BuildRequires: gcc BuildRequires: glibc-devel @@ -22,6 +25,9 @@ BuildRequires: zlib-devel BuildRequires: Judy-devel # Patches +Patch1: 0001-stress-sysfs-check-for-zero-sysfs-entries-after-prun.patch +Patch2: 0002-stress-shm-skip-stressor-if-dev-shm-is-not-mounted-w.patch +Patch3: 0003-stress-shm-move-dev-shm-check-to-earlier-in-the-setu.patch %description Stress test a computer system in various ways. It was designed to exercise @@ -30,6 +36,9 @@ system kernel interfaces. %prep %setup -q +%patch1 -p1 +%patch2 -p1 +%patch3 -p1 %build export CFLAGS="%{optflags}" @@ -53,6 +62,14 @@ install -pm 644 bash-completion/%{name} \ %{_datadir}/bash-completion/completions/%{name} %changelog +* Mon Nov 21 2022 John Kacur - 0.15.00-1 +- Rebase to upstream V0.15.00 +- Add the following upstream patches +- stress-shm: move /dev/shm check to earlier in the setup phase +- stress-shm: skip stressor if /dev/shm is not mounted with tmpfs on linux +- stress-sysfs: check for zero sysfs entries after pruning the directory +Resolves: rhbz#2144070 + * Tue Oct 18 2022 John Kacur - 0.14.06-1 - Rebase to upstream V0.14.06 Resolves: rhbz#2119871