[tip:perf/core] perf bench futex: Handle spurious wakeups

From: tip-bot for Davidlohr Bueso
Date: Sun May 10 2015 - 03:11:24 EST


Commit-ID: 598adc5c9c1cfd3f154f6d9df72b38eda63e306e
Gitweb: http://git.kernel.org/tip/598adc5c9c1cfd3f154f6d9df72b38eda63e306e
Author: Davidlohr Bueso <dave@xxxxxxxxxxxx>
AuthorDate: Fri, 8 May 2015 11:38:00 -0700
Committer: Arnaldo Carvalho de Melo <acme@xxxxxxxxxx>
CommitDate: Fri, 8 May 2015 16:24:02 -0300

perf bench futex: Handle spurious wakeups

Wrap futex_wait around a loop and catch for EINTR.

Either a spurious wakeup occurred or a signal interrupted is, either way
we need to block again.

Signed-off-by: Davidlohr Bueso <dbueso@xxxxxxx>
Cc: Davidlohr Bueso <dbueso@xxxxxxx>
Link: http://lkml.kernel.org/r/1431110280-20231-2-git-send-email-dave@xxxxxxxxxxxx
Signed-off-by: Arnaldo Carvalho de Melo <acme@xxxxxxxxxx>
---
tools/perf/bench/futex-wake.c | 7 ++++++-
1 file changed, 6 insertions(+), 1 deletion(-)

diff --git a/tools/perf/bench/futex-wake.c b/tools/perf/bench/futex-wake.c
index 929f762..e5e41d3 100644
--- a/tools/perf/bench/futex-wake.c
+++ b/tools/perf/bench/futex-wake.c
@@ -60,7 +60,12 @@ static void *workerfn(void *arg __maybe_unused)
pthread_cond_wait(&thread_worker, &thread_lock);
pthread_mutex_unlock(&thread_lock);

- futex_wait(&futex1, 0, NULL, futex_flag);
+ while (1) {
+ if (futex_wait(&futex1, 0, NULL, futex_flag) != EINTR)
+ break;
+ }
+
+ pthread_exit(NULL);
return NULL;
}

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/