Re: [patch 2/2] QEMU: decrease console "refresh rate" with -nographic

Marcelo Tosatti
2008-04-14T15:02:55Z

On Sun, Apr 13, 2008 at 06:30:34PM +0200, Anders wrote:
> Marcelo Tosatti wrote:
>
> >With SIGIO enabled on stdio, there's no need to wakeup the thread
> >performing IO every 30ms.
> >
> >Signed-off-by: Marcelo Tosatti <mtosatti@redhat.com>
> >
> >Index: kvm-userspace.io/qemu/vl.c
> >===================================================================
> >--- kvm-userspace.io.orig/qemu/vl.c
> >+++ kvm-userspace.io/qemu/vl.c
> >@@ -5640,6 +5640,7 @@ static void dumb_display_init(DisplaySta
> > ds->dpy_update = dumb_update;
> > ds->dpy_resize = dumb_resize;
> > ds->dpy_refresh = dumb_refresh;
> >+ ds->gui_timer_interval = 1000;
> > }
> >
> > /***********************************************************/
> >
>
> Why even the 1000ms timer? I was proposing to just set ds->dpy_refresh
> to NULL for the dumb_display, but hit the qemu-devel dead-end.
>
> http://lists.gnu.org/archive/html/qemu-devel/2008-01/msg00374.html
>
> Do you see a problem with that approach?

Issue is that the dumb console timer "wakes up" the vcpu to do IO
processing in main_loop_wait().

So while you're right that vga_hw_update() is a no-op for the -nographic
case, the indirect effect of the timer triggering main_loop_wait() is
needed for reading input from stdio in a way that feels interactive for
the user.

Which is of course not what the code appears to achieve. Apparently it
works by luck :)

I believe that qemu also wants a separate io thread doing select() with a
timeout rather than relying on signals.

> If yes, then that problem is
> probably currently present in the unconnected VNC case, as that one now
> disables the periodic timer completely.

Note that setting gui_timer_interval to 0 does not disable the timer:

/* in ms */
#define GUI_REFRESH_INTERVAL 30

static void gui_update(void *opaque)
{
DisplayState *ds = opaque;
ds->dpy_refresh(ds);
qemu_mod_timer(ds->gui_timer,
(ds->gui_timer_interval ?
ds->gui_timer_interval :
GUI_REFRESH_INTERVAL)
+ qemu_get_clock(rt_clock));
}