From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:52319) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XXEzH-0007p6-US for qemu-devel@nongnu.org; Thu, 25 Sep 2014 15:46:09 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1XXEz8-000395-LG for qemu-devel@nongnu.org; Thu, 25 Sep 2014 15:45:59 -0400 Received: from mail-wi0-x229.google.com ([2a00:1450:400c:c05::229]:62626) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XXEz8-00037n-7t for qemu-devel@nongnu.org; Thu, 25 Sep 2014 15:45:50 -0400 Received: by mail-wi0-f169.google.com with SMTP id fb4so8999410wid.4 for ; Thu, 25 Sep 2014 12:45:44 -0700 (PDT) Sender: Paolo Bonzini Message-ID: <542470E4.6060402@redhat.com> Date: Thu, 25 Sep 2014 21:45:40 +0200 From: Paolo Bonzini MIME-Version: 1.0 References: <1411665709-2052-1-git-send-email-famz@redhat.com> <1411665709-2052-3-git-send-email-famz@redhat.com> In-Reply-To: <1411665709-2052-3-git-send-email-famz@redhat.com> Content-Type: text/plain; charset=windows-1252 Content-Transfer-Encoding: 8bit Subject: Re: [Qemu-devel] [PATCH 2/2] iohandler: Add Linux implementation of iohandler GSource List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Fam Zheng , qemu-devel@nongnu.org Cc: Kevin Wolf , Stefan Hajnoczi Il 25/09/2014 19:21, Fam Zheng ha scritto: > + while (true) { > + r = epoll_pwait(s->epollfd.fd, events, MAX_EVENTS, 0, &origmask); You can save a syscall by doing this just once. You would just get a readable epoll file descriptor on the next main loop iteration. Also, origmask is an input parameter, so you need to use epoll_wait. Also, as an extra optimization perhaps you can make a second list with iohandlers that were modified or have a read_poll handler, and only call iohandler_get_events on that one. Perhaps this together lowers the cost of epoll enough to more easily reach the break-even point. Though I wonder if it would be acceptable to make ioeventfd off by default for virtio-serial... Thanks, Paolo > + if (r < 0) { > + break; > + } else if (r == 0) { > + break; > + } else { > + for (i = 0; i < r; i++) { > + iohandler_dispatch_event(s, &events[i]); > + } > + if (r < MAX_EVENTS) { > + break; > + } > + } > + } > +