From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1KYnw2-0006Ym-1g for qemu-devel@nongnu.org; Thu, 28 Aug 2008 16:17:38 -0400 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1KYnvz-0006YP-Id for qemu-devel@nongnu.org; Thu, 28 Aug 2008 16:17:37 -0400 Received: from [199.232.76.173] (port=38040 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1KYnvz-0006YM-Ee for qemu-devel@nongnu.org; Thu, 28 Aug 2008 16:17:35 -0400 Received: from an-out-0708.google.com ([209.85.132.246]:18283) by monty-python.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1KYnvy-0005ht-W3 for qemu-devel@nongnu.org; Thu, 28 Aug 2008 16:17:35 -0400 Received: by an-out-0708.google.com with SMTP id d18so87449and.130 for ; Thu, 28 Aug 2008 13:17:33 -0700 (PDT) Message-ID: <48B707AC.8040301@codemonkey.ws> Date: Thu, 28 Aug 2008 15:16:44 -0500 From: Anthony Liguori MIME-Version: 1.0 Subject: Re: [Qemu-devel] [PATCH 1/2] Use fd signal trick to break us out of select; do not sigwait References: <69b245c5aebe9d170b7641a266d5700f9c9420c0.1219763627.git.Ian.Jackson@eu.citrix.com> In-Reply-To: <69b245c5aebe9d170b7641a266d5700f9c9420c0.1219763627.git.Ian.Jackson@eu.citrix.com> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Reply-To: qemu-devel@nongnu.org List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: ian.jackson@eu.citrix.com Ian Jackson wrote: > * Use of SIGUSR2 to interrupt select() does not work because signals > which arrive just before entry to select() do not interrupt it. > > * The sigwait approach to detecting aio does not work properly because > some versions of glibc forget to block signals on the private aio > thread under some hard-to-reproduce conditions. This means that > blocking SIGUSR2 is ineffective; the signals can be lost and the > program can block in sigwait (!) > > So instead we use the time-honoured self-pipe trick: in the signal > handler we write to a pipe, which we select on when we want to wait > for the signal, and which we read from (to empty out) just before > actually doing the `top half' processing which deals with the condition > to which the signal relates. > > We use the existing fd handler infrastructure to run the desired > completion code out of the main event loop; in the aio completion wait > we use a cut-down version of the same arrangements. > Hi Ian, Somehow, I didn't see this until today--sorry for the delayed response. I personally prefer the patch I posted. I've also got another patch on top of it that refactors the aio API so that multiple aio implementations can be used. I notice you leave the qemu_aio_poll() in place in the main loop, is there a reason you left it there? Regards, Anthony Liguori