qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
* [Qemu-devel] [PATCH 0/4] RFC: make chardev context switching safer
@ 2019-02-20 16:06 Marc-André Lureau
  2019-02-20 16:06 ` [Qemu-devel] [PATCH 1/4] iothread: wait until the glib context is acquired Marc-André Lureau
                   ` (4 more replies)
  0 siblings, 5 replies; 14+ messages in thread
From: Marc-André Lureau @ 2019-02-20 16:06 UTC (permalink / raw)
  To: qemu-devel
  Cc: Paolo Bonzini, Marc-André Lureau, Markus Armbruster,
	Dr. David Alan Gilbert

Hi,

The chardev context switching code is a bit fragile, as it works as if
the current context is properly synchronized with the new context.  It
isn't so obvious to me that concurrent usage of chardev can't happen,
as there might be various main loop sources being dispatched during
the switch.

Worried about the situation, I wrote those patches a while ago, I
think they are still worth to consider. I used to have some basic
test, but it now conflicts a lot with recent changes. I would like to
get some feedback about the series before I rewrite it.

The importat patch is "chardev: make qemu_chr_fe_set_handlers()
context switching safer". It works by "freezing" the given contexts
while the chardev will "move" (recreate to the new context) the
various sources it owns. This looks quite ugly to me overall, but still
safer than today.

This should allow to simplify the scary code from "monitor: set the
chardev context from the main context/thread".

Finally, "char-socket: restart the reconnect timer to switch context"
shows that we have chardev backends that do not switch fully yet.

(there should be a meme "using chardev from multiple threads is
considered harmful")

Marc-André Lureau (4):
  iothread: wait until the glib context is acquired
  chardev: make qemu_chr_fe_set_handlers() context switching safer
  monitor: set the chardev context from the main context/thread
  char-socket: restart the reconnect timer to switch context

 include/chardev/char-fe.h |  23 +++++++++
 chardev/char-fe.c         | 103 +++++++++++++++++++++++++++++++++-----
 chardev/char-mux.c        |  14 +++---
 chardev/char-socket.c     |   5 ++
 iothread.c                |   7 +++
 monitor.c                 |  39 +++------------
 6 files changed, 139 insertions(+), 52 deletions(-)

-- 
2.21.0.rc1

^ permalink raw reply	[flat|nested] 14+ messages in thread

end of thread, other threads:[~2019-02-22  8:59 UTC | newest]

Thread overview: 14+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2019-02-20 16:06 [Qemu-devel] [PATCH 0/4] RFC: make chardev context switching safer Marc-André Lureau
2019-02-20 16:06 ` [Qemu-devel] [PATCH 1/4] iothread: wait until the glib context is acquired Marc-André Lureau
2019-02-21  7:59   ` Peter Xu
2019-02-21 10:39     ` Marc-André Lureau
2019-02-22  3:29       ` Peter Xu
2019-02-20 16:06 ` [Qemu-devel] [PATCH 2/4] chardev: make qemu_chr_fe_set_handlers() context switching safer Marc-André Lureau
2019-02-21  8:03   ` Peter Xu
2019-02-22  8:32     ` Philippe Mathieu-Daudé
2019-02-22  8:58       ` Marc-André Lureau
2019-02-22  8:56     ` Peter Xu
2019-02-20 16:06 ` [Qemu-devel] [PATCH 3/4] monitor: set the chardev context from the main context/thread Marc-André Lureau
2019-02-20 16:06 ` [Qemu-devel] [PATCH 4/4] char-socket: restart the reconnect timer to switch context Marc-André Lureau
2019-02-21  7:57 ` [Qemu-devel] [PATCH 0/4] RFC: make chardev context switching safer Peter Xu
2019-02-21 10:48   ` Marc-André Lureau

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