From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:36380) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Za1oW-0008KK-Uj for qemu-devel@nongnu.org; Thu, 10 Sep 2015 09:22:57 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Za1oS-0000TV-1a for qemu-devel@nongnu.org; Thu, 10 Sep 2015 09:22:56 -0400 Received: from mail-wi0-f171.google.com ([209.85.212.171]:37695) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Za1oR-0000TN-Ri for qemu-devel@nongnu.org; Thu, 10 Sep 2015 09:22:51 -0400 Received: by wicfx3 with SMTP id fx3so23045278wic.0 for ; Thu, 10 Sep 2015 06:22:51 -0700 (PDT) References: <1440375847-17603-1-git-send-email-cota@braap.org> <1440375847-17603-12-git-send-email-cota@braap.org> From: Alex =?utf-8?Q?Benn=C3=A9e?= In-reply-to: <1440375847-17603-12-git-send-email-cota@braap.org> Date: Thu, 10 Sep 2015 14:22:49 +0100 Message-ID: <87zj0u8l3q.fsf@linaro.org> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit Subject: Re: [Qemu-devel] [RFC 11/38] qemu-thread: handle spurious futex_wait wakeups List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: "Emilio G. Cota" Cc: mttcg@listserver.greensocs.com, mark.burton@greensocs.com, a.rigo@virtualopensystems.com, qemu-devel@nongnu.org, guillaume.delbergue@greensocs.com, pbonzini@redhat.com, Frederic Konrad Emilio G. Cota writes: > Signed-off-by: Emilio G. Cota > --- > util/qemu-thread-posix.c | 11 ++++++++++- > 1 file changed, 10 insertions(+), 1 deletion(-) > > diff --git a/util/qemu-thread-posix.c b/util/qemu-thread-posix.c > index 04dae0f..3760e27 100644 > --- a/util/qemu-thread-posix.c > +++ b/util/qemu-thread-posix.c > @@ -303,7 +303,16 @@ static inline void futex_wake(QemuEvent *ev, int n) > > static inline void futex_wait(QemuEvent *ev, unsigned val) > { > - futex(ev, FUTEX_WAIT, (int) val, NULL, NULL, 0); > + while (futex(ev, FUTEX_WAIT, (int) val, NULL, NULL, 0)) { > + switch (errno) { > + case EWOULDBLOCK: > + return; > + case EINTR: > + break; /* get out of switch and retry */ > + default: > + abort(); I'd be tempted to error_exit with the errno in this case so additional information is reported before we bail out. The man pages seems to indicate other errnos are possible for FUTUX_WAIT although they may be unlikely: EACCES No read access to futex memory. EFAULT Error retrieving timeout information from user space. I guess things would have gone very wrong for these EINVAL Invalid argument. Hard to get wrong ENFILE The system limit on the total number of open files has been reached. Might happen under system load? ENOSYS Invalid operation specified in op. Hardcoded op so no ETIMEDOUT Timeout during the FUTEX_WAIT operation. No timeout specified so we shouldn't hit it > + } > + } > } > #else > static inline void futex_wake(QemuEvent *ev, int n) -- Alex Bennée