stress-ng/SOURCES/0003-stress-shm-move-dev-sh...

56 lines
1.6 KiB
Diff

From 7681f2d05470b8c8850346bcf12e525f628941b3 Mon Sep 17 00:00:00 2001
From: Colin Ian King <colin.i.king@gmail.com>
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 <colin.i.king@gmail.com>
---
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