lkml.org 
[lkml]   [2021]   [Oct]   [11]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
From
Subject[PATCH] perf bench futex, wake: Fixlets for futex_wait return checks
Date
- 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@suse.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
\
 
 \ /
  Last update: 2021-10-12 05:09    [W:0.022 / U:1.748 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site