From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([140.186.70.92]:47506) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1R8ncH-0003S9-43 for qemu-devel@nongnu.org; Wed, 28 Sep 2011 02:27:37 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1R8ncG-0001Ll-1j for qemu-devel@nongnu.org; Wed, 28 Sep 2011 02:27:37 -0400 Received: from mail-ww0-f53.google.com ([74.125.82.53]:47671) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1R8ncF-0001Lc-Tb for qemu-devel@nongnu.org; Wed, 28 Sep 2011 02:27:36 -0400 Received: by wwg14 with SMTP id 14so7124861wwg.10 for ; Tue, 27 Sep 2011 23:27:34 -0700 (PDT) Sender: Paolo Bonzini Message-ID: <4E82BE4A.3040904@redhat.com> Date: Wed, 28 Sep 2011 08:27:22 +0200 From: Paolo Bonzini MIME-Version: 1.0 References: <1317133583-25212-1-git-send-email-avi@redhat.com> <4E81EB8A.3070202@siemens.com> <4E81F43B.1040708@codemonkey.ws> <4E81FC29.9090503@redhat.com> <4E823EEE.3030807@codemonkey.ws> In-Reply-To: <4E823EEE.3030807@codemonkey.ws> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Subject: Re: [Qemu-devel] [PATCH] event_notifier: move to top-level directory List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Anthony Liguori Cc: Kevin Wolf , Jan Kiszka , Avi Kivity , qemu-devel@nongnu.org, Stefan Hajnoczi On 09/27/2011 11:23 PM, Anthony Liguori wrote: > On 09/27/2011 11:39 AM, Paolo Bonzini wrote: >> On 09/27/2011 06:05 PM, Anthony Liguori wrote: >>> Actually, for posix-aio, we can just switch to using g_idle_add(). >>> g_idle_add() uses g_source_attach which is thread safe. g_idle_add() >>> gives you a thread safe mechanism to defer a piece of work to the >>> main loop which is really what we want here. >> >> For that, a bottom half would also do (apart that I am not sure it is >> async-safe with TCG). In fact, that would make sense since all of >> posix_aio_process_queue could become a bottom half. > > Bottom halves are signal safe, not thread safe. > > To make bottom halves thread safe, you would (in the very least) have to > add some barriers when reading/writing the scheduling flag. You can probably assume that qemu_notify_event (and dually the read in the main loop) are resp. write/read memory barriers. Or even full. If we switch entirely to GSources, it would be nice to use them. But since we aren't, and our main loop functionality is quite different from glib's (it doesn't rely on abstractions for file descriptors, for example), it is just a painful incomplete transition to use glib's idle sources to do the exact same thing that is done by bottom halves (which are already in our toolbox). Paolo