From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1LPqHr-0004Dz-VO for qemu-devel@nongnu.org; Wed, 21 Jan 2009 22:31:23 -0500 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1LPqHq-0004Cn-KR for qemu-devel@nongnu.org; Wed, 21 Jan 2009 22:31:23 -0500 Received: from [199.232.76.173] (port=41173 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1LPqHq-0004Ce-DS for qemu-devel@nongnu.org; Wed, 21 Jan 2009 22:31:22 -0500 Received: from mail-gx0-f12.google.com ([209.85.217.12]:41902) by monty-python.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1LPqHp-0004wY-Uk for qemu-devel@nongnu.org; Wed, 21 Jan 2009 22:31:22 -0500 Received: by gxk5 with SMTP id 5so428908gxk.10 for ; Wed, 21 Jan 2009 19:31:21 -0800 (PST) Message-ID: <4977E87A.5040904@codemonkey.ws> Date: Wed, 21 Jan 2009 21:31:06 -0600 From: Anthony Liguori MIME-Version: 1.0 Subject: Re: [Qemu-devel] [6391] Fix nographic mode and VNC References: <20090121202904.GE5237@const.famille.thibault.fr> <200901220004.11338.paul@codesourcery.com> In-Reply-To: <200901220004.11338.paul@codesourcery.com> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit Reply-To: qemu-devel@nongnu.org List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: Blue Swirl Paul Brook wrote: >> Some other way, like SIGIO or IO worker thread, may work too. It may >> also be a big change. >> > > Using a side effect of the the gui refresh timer to implement IO polling is > absolutely the wrong way to fix things. > > All IO should be event driven. If it isn't then then it needs fixing. The > polling timeout is determined by timeout = 5000 in vl.c. > No, this is a fundamentally broken aspect of TCG (and dyngen). cpu_exec() spins in a loop checking for 'event_pending'. This is set whenever the host_alarm_timer callback signals. Alternatively, a halted guest will cause cpu_exec() to exit. Only then do you do a select() on pending IO. If you are using dynticks as your clock, the guest has a slow clock, and the guest is not using halt instructions, then you will not poll IO until the next guest timer tick b/c your guest is just going to spin. There are three possible solutions. Set SIGIO on every file descriptor so that TCG breaks whenever IO is pending. Besides ugliness, this fails because not every type of file descriptor supports SIGIO. A second solution is to use a polling select() in cpu_exec. Since you're adding a system call (and a rather heavy one) in the fast path, this is going to likely hurt TCG performance. The third possibility is to have the select() run in a separate thread from the TCG cpu_exec() loop. cpu_exec() would do an atomic read of 'event_pending' and the IO thread would do an atomic write of 'event_pending' whenever select() returned a writable file descriptor. Regards, Anthony Liguori > Paul > > >