From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([208.118.235.92]:35521) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1SrTpr-0004Sg-HS for qemu-devel@nongnu.org; Wed, 18 Jul 2012 08:58:41 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1SrTpl-0007ut-M2 for qemu-devel@nongnu.org; Wed, 18 Jul 2012 08:58:35 -0400 Received: from mail-pb0-f45.google.com ([209.85.160.45]:47471) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1SrTpl-0007uo-F5 for qemu-devel@nongnu.org; Wed, 18 Jul 2012 08:58:29 -0400 Received: by pbbro12 with SMTP id ro12so2593885pbb.4 for ; Wed, 18 Jul 2012 05:58:28 -0700 (PDT) Message-ID: <5006B2EF.9040609@ozlabs.ru> Date: Wed, 18 Jul 2012 22:58:23 +1000 From: Alexey Kardashevskiy MIME-Version: 1.0 References: <4FF0A980.4070903@ozlabs.ru> <1342613333-20239-1-git-send-email-aik@ozlabs.ru> <20120718122202.GA5292@redhat.com> In-Reply-To: <20120718122202.GA5292@redhat.com> Content-Type: text/plain; charset=KOI8-R Content-Transfer-Encoding: 7bit Subject: Re: [Qemu-devel] [PATCH] eventfd: making it thread safe List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: "Michael S. Tsirkin" Cc: qemu-devel@nongnu.org On 18/07/12 22:22, Michael S. Tsirkin wrote: > On Wed, Jul 18, 2012 at 10:08:53PM +1000, Alexey Kardashevskiy wrote: >> QEMU uses IO handlers to run select() in the main loop. >> The handlers list is managed by qemu_set_fd_handler() helper >> which works fine when called from the main thread as it is >> called not when select() is waiting. > > when select() is not waiting? > >> >> However IO handlers list can be changed in the thread other than >> the main one doing os_host_main_loop_wait(), for example, as a result >> of a hypercall which changes PCI config space (VFIO on POWER is the case) > > So the problem is only with VFIO? Can it affect vhost-net? Honestly I have no idea about vhost-net as I never tried it. >> and enables/disabled MSI/MSIX which closes/creates eventfd handles. > > There doesn't seem to be a notification in case an fd is > deleted. It's probably not at all urgent to remove > an fd from select - why do you mention closing handles? Agrhh. I missed this comment in the patch I just reposted. Mentioned because the file* is still open when there is no need in it. It has no effect for eventfd but may have for somebody else so we probably want to add a notification on deletion. Dunno. >> If the main loop is waiting on such eventfd, it has to be restarted. > > Do you really mean 'should be waiting on the newly created > eventfd'? > >> The patch adds the qemu_notify_event() call to interrupt select() >> and make main_loop() to restart select() > > s/and make main_loop() to restart/to make main_loop() restart/? Thanks for the comments. David used to polish my english but he is vacation now :) >> with the updated IO >> handlers list. >> >> Signed-off-by: Alexey Kardashevskiy >> Reviewed-by: Paolo Bonzini >> --- >> iohandler.c | 1 + >> 1 file changed, 1 insertion(+) >> >> diff --git a/iohandler.c b/iohandler.c >> index 3c74de6..dea4355 100644 >> --- a/iohandler.c >> +++ b/iohandler.c >> @@ -77,6 +77,7 @@ int qemu_set_fd_handler2(int fd, >> ioh->fd_write = fd_write; >> ioh->opaque = opaque; >> ioh->deleted = 0; >> + qemu_notify_event(); >> } >> return 0; >> } >> -- >> 1.7.10.4 -- Alexey