From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([208.118.235.92]:33144) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1SyNwh-0003o2-Kx for qemu-devel@nongnu.org; Mon, 06 Aug 2012 10:06:17 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1SyNwd-0007mN-FQ for qemu-devel@nongnu.org; Mon, 06 Aug 2012 10:06:11 -0400 Received: from mx1.redhat.com ([209.132.183.28]:31542) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1SyNwd-0007m1-5j for qemu-devel@nongnu.org; Mon, 06 Aug 2012 10:06:07 -0400 Message-ID: <501FCF45.4010003@redhat.com> Date: Mon, 06 Aug 2012 17:05:57 +0300 From: Avi Kivity MIME-Version: 1.0 References: <1343793936-28000-1-git-send-email-david@gibson.dropbear.id.au> In-Reply-To: <1343793936-28000-1-git-send-email-david@gibson.dropbear.id.au> Content-Type: text/plain; charset=ISO-8859-1 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: David Gibson Cc: Alexey Kardashevskiy , pbonzini@redhat.com, qemu-devel@nongnu.org, anthony@codemonkey.ws On 08/01/2012 07:05 AM, David Gibson wrote: > From: Alexey Kardashevskiy > > 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 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) > and enables/disabled MSI/MSIX which creates eventfd handles. > As the main loop should be waiting on the newly created eventfds, > it has to be restarted. > > The patch adds the qemu_notify_event() call to interrupt select() > to make main_loop() restart select() 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; > } Perhaps it's better to do this unconditionally (on the delete path too) so that removals are processed without delay and we don't have closed fds hanging around in select(). -- error compiling committee.c: too many arguments to function