perf bench futex, wake: Fixlets for futex_wait return checks
Subsystems (2)
Davidlohr Bueso
reviewerPATCH 1/1 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 <[email protected]>
--- 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(-)
tools/perf/bench/futex-requeue.c +2 -2
@@ -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 ; } }
tools/perf/bench/futex-wake-parallel.c +11 -2
@@ -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 );
tools/perf/bench/futex-wake.c +10 -1
@@ -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 );
Signature · 1 line
2.26.2