From: Davidlohr Bueso <dave@stgolabs.net>
To: Arnaldo Carvalho de Melo <acme@kernel.org>,
Ingo Molnar <mingo@kernel.org>
Cc: linux-kernel@vger.kernel.org, dave@stgolabs.net,
Davidlohr Bueso <dbueso@suse.de>
Subject: [PATCH 2/2] perf bench futex: Handle spurious wakeups
Date: Fri, 8 May 2015 11:38:00 -0700 [thread overview]
Message-ID: <1431110280-20231-2-git-send-email-dave@stgolabs.net> (raw)
In-Reply-To: <1431110280-20231-1-git-send-email-dave@stgolabs.net>
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@suse.de>
---
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;
}
--
2.1.4
next prev parent reply other threads:[~2015-05-08 18:38 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-05-08 18:37 [PATCH 1/2] perf bench futex: Support parallel waker threads Davidlohr Bueso
2015-05-08 18:38 ` Davidlohr Bueso [this message]
2015-05-10 7:11 ` [tip:perf/core] perf bench futex: Handle spurious wakeups tip-bot for Davidlohr Bueso
2015-05-08 19:24 ` [PATCH 1/2] perf bench futex: Support parallel waker threads Arnaldo Carvalho de Melo
2015-05-10 7:10 ` [tip:perf/core] " tip-bot for Davidlohr Bueso
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1431110280-20231-2-git-send-email-dave@stgolabs.net \
--to=dave@stgolabs.net \
--cc=acme@kernel.org \
--cc=dbueso@suse.de \
--cc=linux-kernel@vger.kernel.org \
--cc=mingo@kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®