From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1Kxn0p-0002OC-Ft for qemu-devel@nongnu.org; Wed, 05 Nov 2008 13:21:51 -0500 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1Kxn0l-0002NT-Pu for qemu-devel@nongnu.org; Wed, 05 Nov 2008 13:21:50 -0500 Received: from [199.232.76.173] (port=55632 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1Kxn0l-0002NQ-L3 for qemu-devel@nongnu.org; Wed, 05 Nov 2008 13:21:47 -0500 Received: from fmmailgate01.web.de ([217.72.192.221]:35937) by monty-python.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1Kxn0k-0008Qe-UP for qemu-devel@nongnu.org; Wed, 05 Nov 2008 13:21:47 -0500 Message-ID: <4911E434.5020105@web.de> Date: Wed, 05 Nov 2008 19:21:40 +0100 From: Jan Kiszka MIME-Version: 1.0 Subject: Re: [Qemu-devel] Re: [5578] Increase default IO timeout from 10ms to 5s References: <20081104113204.GA32125@shareable.org> <20081104.092231.-1384053398.imp@bsdimp.com> <20081105150042.GJ13630@shareable.org> <20081105.091015.232928302.imp@bsdimp.com> In-Reply-To: <20081105.091015.232928302.imp@bsdimp.com> Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="------------enigFF8F4A57BF0863162F06227F" Sender: jan.kiszka@web.de Reply-To: qemu-devel@nongnu.org List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: "M. Warner Losh" Cc: qemu-devel@nongnu.org This is an OpenPGP/MIME signed message (RFC 2440 and 3156) --------------enigFF8F4A57BF0863162F06227F Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable M. Warner Losh wrote: > In message: <20081105150042.GJ13630@shareable.org> > Jamie Lokier writes: > : M. Warner Losh wrote: > : > : In other words, don't use pselect() if you might run on a kernel = older > : > : than 2.6.16, or on a host architecture which adds pselect() in a = later > : > : kernel version. Also, I wouldn't be surprised if older versions = of > : > : some BSDs have similar dodgy wrappers. > : >=20 > : > Which ones have a good kernel implementation of it? FreeBSD's is > : > currently approximately: > : >=20 > : > if (!mask) > : > _sigprocmask(mask, &oldmask); > : > /* here */ > : > select(); > : > if (!mask) > : > _sigprocmask(oldmask, NULL); > : >=20 > : > I'm assuming that the problem is due to a signal arriving at /* her= e */. > :=20 > : If that's _kernel_ code and the kernel behaves like Linux, it's not a= > : problem because signals don't affect the control flow until returning= > : to userspace, meaning the select() will return EINTR. >=20 > It is currently user level code, and I'm looking at moving it into the > kernel, but I need to understand the race being talked about here. =46rom the Linux man page on [p]select: "The reason that pselect() is needed is that if one wants to wait for either a signal or for a file descriptor to become ready, then an atomic test is needed to prevent race conditions. (Suppose the signal handler sets a global flag and returns. Then a test of this global flag followed by a call of select() could hang indefinitely if the signal arrived just after the test but just before the call. By contrast, pselect() allows one to first block signals, handle the signals that have come in, then call pselect() with the desired sigmask, avoiding the race.)" So the unmasking and possible blocking on select must be done atomically. And that is only feasible in kernel land. Jan --------------enigFF8F4A57BF0863162F06227F Content-Type: application/pgp-signature; name="signature.asc" Content-Description: OpenPGP digital signature Content-Disposition: attachment; filename="signature.asc" -----BEGIN PGP SIGNATURE----- Version: GnuPG v2.0.9 (GNU/Linux) Comment: Using GnuPG with SUSE - http://enigmail.mozdev.org iEYEARECAAYFAkkR5DgACgkQniDOoMHTA+lzPACePOHnXnlKedzk0iM28hsz4DIG cLIAn1NdwBtN8seMuFW3ayJ9roedCTv9 =J2EK -----END PGP SIGNATURE----- --------------enigFF8F4A57BF0863162F06227F--