qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Anthony Liguori <anthony@codemonkey.ws>
To: qemu-devel@nongnu.org
Cc: Blue Swirl <blauwirbel@gmail.com>
Subject: Re: [Qemu-devel] [6391] Fix nographic mode and VNC
Date: Wed, 21 Jan 2009 21:31:06 -0600	[thread overview]
Message-ID: <4977E87A.5040904@codemonkey.ws> (raw)
In-Reply-To: <200901220004.11338.paul@codesourcery.com>

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
>
>
>   

  reply	other threads:[~2009-01-22  3:31 UTC|newest]

Thread overview: 19+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-01-21 19:28 [Qemu-devel] [6391] Fix nographic mode and VNC Blue Swirl
2009-01-21 19:39 ` Stefano Stabellini
2009-01-21 19:52   ` Blue Swirl
2009-01-21 19:56     ` Stefano Stabellini
2009-01-21 20:03 ` Samuel Thibault
2009-01-21 20:16   ` Blue Swirl
2009-01-21 20:29     ` Samuel Thibault
2009-01-21 20:44       ` Blue Swirl
2009-01-21 21:33         ` Anthony Liguori
2009-01-22  0:04         ` Paul Brook
2009-01-22  3:31           ` Anthony Liguori [this message]
2009-01-22  4:23             ` Paul Brook
2009-01-22 12:36               ` Ian Jackson
2009-01-23 18:59                 ` Paul Brook
2009-01-22 15:29               ` Anthony Liguori
2009-01-23 18:20                 ` Paul Brook
2009-01-23 19:37                   ` Anthony Liguori
2009-01-25 19:57                   ` Jamie Lokier
2009-01-25 23:25                     ` Paul Brook

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=4977E87A.5040904@codemonkey.ws \
    --to=anthony@codemonkey.ws \
    --cc=blauwirbel@gmail.com \
    --cc=qemu-devel@nongnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).