[<prev] [next>] [day] [month] [year] [list]
Message-Id: <20211012030914.101944-1-dave@stgolabs.net>
Date: Mon, 11 Oct 2021 20:09:14 -0700
From: Davidlohr Bueso <dave@...olabs.net>
To: acme@...nel.org
Cc: linux-kernel@...r.kernel.org, dave@...olabs.net,
Davidlohr Bueso <dbueso@...e.de>
Subject: [PATCH] perf bench futex, wake: Fixlets for futex_wait return checks
- Avoid checking against EINTR which has for a very long time no longer
been the case for spurious wakeups. Properly use EAGAIN instead - albeit
there should be no error scenarios in these workloads.
- Do not bogusly check syscall(2) return, but instead rely on errno.
- Use warn() instead of warnx() for we want an appended message.
Signed-off-by: Davidlohr Bueso <dbueso@...e.de>
---
tools/perf/bench/futex-requeue.c | 4 ++--
tools/perf/bench/futex-wake-parallel.c | 13 +++++++++++--
tools/perf/bench/futex-wake.c | 11 ++++++++++-
3 files changed, 23 insertions(+), 5 deletions(-)
diff --git a/tools/perf/bench/futex-requeue.c b/tools/perf/bench/futex-requeue.c
index 97fe31fd3a23..ef09ca189e47 100644
--- a/tools/perf/bench/futex-requeue.c
+++ b/tools/perf/bench/futex-requeue.c
@@ -97,7 +97,7 @@ static void *workerfn(void *arg __maybe_unused)
if (ret && errno != EAGAIN) {
if (!params.silent)
- warnx("futex_wait");
+ warn("futex_wait");
break;
}
} else {
@@ -111,7 +111,7 @@ static void *workerfn(void *arg __maybe_unused)
if (ret && errno != EAGAIN) {
if (!params.silent)
- warnx("futex_wait_requeue_pi");
+ warn("futex_wait_requeue_pi");
break;
}
}
diff --git a/tools/perf/bench/futex-wake-parallel.c b/tools/perf/bench/futex-wake-parallel.c
index e970e6b9ad53..76b57eac2375 100644
--- a/tools/perf/bench/futex-wake-parallel.c
+++ b/tools/perf/bench/futex-wake-parallel.c
@@ -132,9 +132,18 @@ static void *blocked_workerfn(void *arg __maybe_unused)
pthread_cond_wait(&thread_worker, &thread_lock);
pthread_mutex_unlock(&thread_lock);
- while (1) { /* handle spurious wakeups */
- if (futex_wait(&futex, 0, NULL, futex_flag) != EINTR)
+ while (1) {
+ int ret;
+
+ ret = futex_wait(&futex, 0, NULL, futex_flag);
+ if (!ret)
+ break;
+
+ if (ret && errno != EAGAIN) {
+ if (!params.silent)
+ warn("futex_wait");
break;
+ }
}
pthread_exit(NULL);
diff --git a/tools/perf/bench/futex-wake.c b/tools/perf/bench/futex-wake.c
index 77f058a47790..8e99b506d4f0 100644
--- a/tools/perf/bench/futex-wake.c
+++ b/tools/perf/bench/futex-wake.c
@@ -73,8 +73,17 @@ static void *workerfn(void *arg __maybe_unused)
pthread_mutex_unlock(&thread_lock);
while (1) {
- if (futex_wait(&futex1, 0, NULL, futex_flag) != EINTR)
+ int ret;
+
+ ret = futex_wait(&futex1, 0, NULL, futex_flag);
+ if (!ret)
+ break;
+
+ if (ret && errno != EAGAIN) {
+ if (!params.silent)
+ warn("futex_wait");
break;
+ }
}
pthread_exit(NULL);
--
2.26.2
Powered by blists - more mailing lists