From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([140.186.70.92]:59281) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1RJopP-0003YJ-F8 for qemu-devel@nongnu.org; Fri, 28 Oct 2011 11:58:44 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1RJopO-0007BB-8o for qemu-devel@nongnu.org; Fri, 28 Oct 2011 11:58:43 -0400 Received: from mail-qw0-f45.google.com ([209.85.216.45]:51328) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1RJopO-0007B7-5I for qemu-devel@nongnu.org; Fri, 28 Oct 2011 11:58:42 -0400 Received: by qadc12 with SMTP id c12so4663558qad.4 for ; Fri, 28 Oct 2011 08:58:41 -0700 (PDT) Sender: Paolo Bonzini Message-ID: <4EAAD12A.1070603@redhat.com> Date: Fri, 28 Oct 2011 17:58:34 +0200 From: Paolo Bonzini MIME-Version: 1.0 References: <1316443033-6489-1-git-send-email-freddy77@gmail.com> <4EA95BFF.6070807@redhat.com> <20111027135731.GA21052@stefanha-thinkpad.localdomain> <4EA96776.6020807@redhat.com> <4EA96B82.6070507@redhat.com> <4EAA9310.2030705@redhat.com> <4EAA9700.6030605@redhat.com> <4EAAA025.100@redhat.com> In-Reply-To: Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Subject: Re: [Qemu-devel] [PATCH v2] block: avoid SIGUSR2 List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Stefan Hajnoczi Cc: Lucas Meneghel Rodrigues , Kevin Wolf , aliguori@us.ibm.com, Stefan Hajnoczi , Peter Maydell , qemu-devel@nongnu.org, Michael Walle , Zhi Yong Wu , Frediano Ziglio , Cleber Rosa On 10/28/2011 02:31 PM, Stefan Hajnoczi wrote: > Zhi Yong: We were just talking about converting devices to aio. If > you have time to do that for fdc, sd, or any other synchronous API > users in hw/ that would be helpful. Please let us know which device > you are refactoring so we don't duplicate work. The problem is not really fdc or sd themselves, but whoever uses the result of the synchronous reads---respectively DMA and the SD clients. Some SD clients talk to the SD card in a relatively confined way and have interrupts that they set when the operation is done, so these confined parts that talk to the card could be changed to a coroutine and locked with a CoMutex. However, not even all of these can do it (in particular I'm not sure about ssi-sd.c cannot). I'm thinking that the problem with the floppy is really that it mixes synchronous and asynchronous parts. As long as you're entirely synchronous you should not have any problem, but as soon as you add asynchronicity (via bottom halves) you now have to deal with reentrancy. "git grep _bh hw/" suggests that this should not be a huge problem; most if not all occurrences are related to ptimers, or are in entirely asynchronous code (IDE, SCSI, virtio). Floppy+DMA seems to be the only problematic occurrence, and any fix (switch to timers, drop idle BH in qemu_aio_wait, reschedule if DMA reenters during I/O, drop BH completely and just loop) is as good as the others. (Actually, another one worth checking is ATAPI, but I don't know the code and the standards well enough). Paolo