Received: from eggs.gnu.org ([2001:4830:134:3::10]:33926) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aSn8F-0000nH-EN for qemu-devel@nongnu.org; Mon, 08 Feb 2016 09:49:43 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1aSn8A-0005Yf-Mt for qemu-devel@nongnu.org; Mon, 08 Feb 2016 09:49:39 -0500 Received: from mx1.redhat.com ([209.132.183.28]:52505) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aSn8A-0005Ya-H3 for qemu-devel@nongnu.org; Mon, 08 Feb 2016 09:49:34 -0500 Received: from int-mx13.intmail.prod.int.phx2.redhat.com (int-mx13.intmail.prod.int.phx2.redhat.com [10.5.11.26]) by mx1.redhat.com (Postfix) with ESMTPS id 3C1775A76 for ; Mon, 8 Feb 2016 14:49:33 +0000 (UTC) Date: Fri, 5 Feb 2016 17:51:49 +0000 From: Stefan Hajnoczi Message-ID: <20160205175149.GA797@stefanha-x1.localdomain> References: <1452870739-28484-1-git-send-email-pbonzini@redhat.com> <1452870739-28484-6-git-send-email-pbonzini@redhat.com> <20160202145206.GB32084@stefanha-x1.localdomain> <56B0C4E3.5060808@redhat.com> <20160203093444.GB26227@stefanha-x1.localdomain> <56B1CDE6.9070700@redhat.com> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="mYCpIKhGyMATD0i+" Content-Disposition: inline In-Reply-To: <56B1CDE6.9070700@redhat.com> Subject: Re: [Qemu-devel] [PATCH 05/16] iothread: release AioContext around aio_poll List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Paolo Bonzini Cc: qemu-devel@nongnu.org --mYCpIKhGyMATD0i+ Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Wed, Feb 03, 2016 at 10:52:38AM +0100, Paolo Bonzini wrote: >=20 >=20 > On 03/02/2016 10:34, Stefan Hajnoczi wrote: > >>>>>>>>> + g_usleep(500000); > >>>>> Sleep? > >>>=20 > >>> What about it? :) > > Sleep in a loop is inefficient but at least correct. > >=20 > > A sleep outside a loop is a race condition. If the machine is > > heavily loaded, whatever you are waiting for may not happen in 500 > > ms and the test case is unreliable. > >=20 > > What is the purpose of this sleep? >=20 > In the test the desired ordering of events is >=20 > main thread additional thread > --------------------------------------------------------------------- > lock start_lock > start thread > lock start_lock (waits) > acquire context > unlock start_lock > lock start_lock (returns) > unlock start_lock > aio_poll > poll() <<<< > event_notifier_set <<<< >=20 > Comparing the test to QEMU, the roles of the threads are reversed. The > test's "main thread" is QEMU's dataplane thread, and the test's > additional thread is QEMU's main thread. >=20 > The sleep "ensures" that poll() blocks before event_notifier_set. The > sleep represents how QEMU's main thread acquires the context rarely, > and not right after starting the dataplane thread. >=20 > Because this is a file descriptor source, there is really no > difference between the code's behavior, no matter if aio_poll starts > before or after the event_notifier_set. The test passes even if you > remove the sleep. >=20 > Do you have any suggestion? Just add a comment? How about removing the sleep and adding a comment explaining that the event_notifier_set() could happen either before or during poll()? Stefan --mYCpIKhGyMATD0i+ Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- Version: GnuPG v1 iQEcBAEBAgAGBQJWtOE1AAoJEJykq7OBq3PIifoH/1m+jIpNwtFMTr9p72wOIR8+ 49FP5xJnvgTAPJ19GQfib5jMZfTBypfL2+ZooEsvSQOqNvM2atJhYc2OW9PIwL85 g9G5hTpKc6k8zrTktwDPe7YRfntXdv72iLp7kGuLFxCgwGDmrkDS8NmKEBajQhI1 gGsZmhAuxvyYmuhooysgxoSxcsyWO3J+7WZEIm0AULYWBMXC0cdAtpFe1/GhEe5n rJxVwMyooE7L4/otNsGKTKf1nD4h+usCgc38ilToLnxSl/Adu7n4cyyz1Z6vNGtL aksztzEbYAb48pCon6uYRhJdDDbIAKSBL08fFQGSwWI86cBzErktZciVbCwR3/w= =WrVG -----END PGP SIGNATURE----- --mYCpIKhGyMATD0i+--