[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Qemu-devel] RFC: running the user interface in a thread ...
From: |
Stefan Hajnoczi |
Subject: |
Re: [Qemu-devel] RFC: running the user interface in a thread ... |
Date: |
Thu, 21 Jan 2016 09:58:11 +0000 |
User-agent: |
Mutt/1.5.24 (2015-08-30) |
On Tue, Jan 19, 2016 at 01:51:09PM +0100, Kevin Wolf wrote:
> Am 18.01.2016 um 10:54 hat Gerd Hoffmann geschrieben:
> > Hi folks,
> >
> > I'm starting to investigate if and how we can move the user interface
> > code into its own thread instead of running it in the iothread and
> > therefore avoid blocking the guest in case some UI actions take a little
> > longer.
> >
> > opengl and toolkits tend to be bad at multithreading. So my idea is to
> > have a single thread dedicated to all the UI + rendering stuff, possibly
> > let even the virglrenderer run in ui thread context.
> >
> > I think we have to make that opt-in per user interface, so we can go
> > forward step by step.
> >
> > The ui thread will need quite some stuff provided by the mainloop. Wait
> > for all kinds of events (from vnc socket, x11 connection, ...).
> > Probably timers too. Wait for events from other threads (guest screen
> > updates).
> >
> > Suggestions how to tackle that?
> > Can I reuse the qemu mainloop code outside of the iothread?
>
> That should be possible. The block layer runs additional main loops in
> dataplane threads. I think AioContext is the keyword here, so that you
> process only events in your own UI context.
>
> I'm copying Stefan who knows this stuff a bit better than me.
>
> > Maybe it'll be better to go straight for a glib main loop?
That sounds good in theory (but see below) since AioContext integrates
with the glib main loop because it is a GSource. QEMU code should use
AioContext where we have high resolution timers and APIs for file
descriptor, EventNotifier, and BH.
But I think using multiple glib main loops has limitations/problems.
CCing Daniel Berrange because I vaguely remember this topic being
discussed.
> > Is it possible to wait for file handle events and posix condition
> > variables at the same time?
I don't think POSIX condition variables can be monitored from an event
loop.
Use BH or EventNotifier instead. BH has optimizations to avoid syscalls
where possible while EventNotifier is just a plain eventfd/pipe
(requires a write() syscall for each notification).
signature.asc
Description: PGP signature
- Re: [Qemu-devel] RFC: running the user interface in a thread ..., (continued)
- Re: [Qemu-devel] RFC: running the user interface in a thread ..., Eric Blake, 2016/01/18
- Re: [Qemu-devel] RFC: running the user interface in a thread ..., Markus Armbruster, 2016/01/19
- Re: [Qemu-devel] RFC: running the user interface in a thread ..., Daniel P. Berrange, 2016/01/19
- Re: [Qemu-devel] RFC: running the user interface in a thread ..., Eric Blake, 2016/01/20
- Re: [Qemu-devel] RFC: running the user interface in a thread ..., Gerd Hoffmann, 2016/01/20
Re: [Qemu-devel] RFC: running the user interface in a thread ..., Kevin Wolf, 2016/01/19
Re: [Qemu-devel] RFC: running the user interface in a thread ..., Daniel P. Berrange, 2016/01/19
Re: [Qemu-devel] RFC: running the user interface in a thread ..., Dave Airlie, 2016/01/21