From: Peter Xu <peterx@redhat.com>
To: Wolfgang Bumiller <w.bumiller@proxmox.com>
Cc: Markus Armbruster <armbru@redhat.com>, qemu-devel@nongnu.org
Subject: Re: [Qemu-devel] [PULL 6/7] monitor: move init global earlier
Date: Thu, 6 Sep 2018 11:38:25 +0800 [thread overview]
Message-ID: <20180906033825.GB16937@xz-x1> (raw)
In-Reply-To: <20180905150510.wn4cfhj73z7cbtvb@olga.proxmox.com>
On Wed, Sep 05, 2018 at 05:05:10PM +0200, Wolfgang Bumiller wrote:
> On Mon, Jun 18, 2018 at 04:08:53PM +0200, Markus Armbruster wrote:
> > From: Peter Xu <peterx@redhat.com>
> >
> > Before this patch, monitor fd helpers might be called even earlier than
> > monitor_init_globals(). This can be problematic.
> >
> > After previous work, now monitor_init_globals() does not depend on
> > accelerator initialization any more. Call it earlier (before CLI
> > parsing; that's where the monitor APIs might be called) to make sure it
> > is called before any of the monitor APIs.
>
> It looks like this patch moves the creation of the 'IO mon_iothread' to
> before the call to os_daemonize().
> With qemu 3.0 I'm experiencing crashes when shutting down daemonized
> qemu instances, at pthread_join() on the 'IO mon_iothread' thread.
>
> monitor_init_globals() calls monitor_iothread_init(), which in turn uses
> iothread_create() to create a joinable thread. Then os_daemonize() is
> called after which the thread is no longer "ours".
> Debug-writing the thread IDs at pthread_create() and pthread_join()
> together with the 'detachable' flag revealed that the mon_iothread ID is
> already being reused, in my trace for a detached thread, and the join
> then ends with a coredump and ugly log output.
Indeed. So we have these ordering constraints:
init mon locks [1]
cli parsing
daemonize
create mon iothread [2]
I can't figure out a way unless we split the global init routine for
the monitors, possibly (and simply) by postpone creation of the
iothread. Thoughts?
(Note that AFAICT Markus is on holiday and will be back after two weeks)
Regards,
--
Peter Xu
next prev parent reply other threads:[~2018-09-06 3:38 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-06-18 14:08 [Qemu-devel] [PULL 0/7] monitor: Thread safety improvements Markus Armbruster
2018-06-18 14:08 ` [Qemu-devel] [PULL 1/7] monitor: rename out_lock to mon_lock Markus Armbruster
2018-06-18 14:08 ` [Qemu-devel] [PULL 2/7] monitor: protect mon->fds with mon_lock Markus Armbruster
2018-06-18 14:08 ` [Qemu-devel] [PULL 3/7] monitor: more comments on lock-free elements Markus Armbruster
2018-06-18 14:08 ` [Qemu-devel] [PULL 4/7] monitor: fix comment for monitor_lock Markus Armbruster
2018-06-18 14:08 ` [Qemu-devel] [PULL 5/7] monitor: remove event_clock_type Markus Armbruster
2018-06-18 14:08 ` [Qemu-devel] [PULL 6/7] monitor: move init global earlier Markus Armbruster
2018-09-05 15:05 ` Wolfgang Bumiller
2018-09-06 3:38 ` Peter Xu [this message]
2018-06-18 14:08 ` [Qemu-devel] [PULL 7/7] monitor: add lock to protect mon_fdsets Markus Armbruster
2018-06-19 15:04 ` [Qemu-devel] [PULL 0/7] monitor: Thread safety improvements Peter Maydell
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=20180906033825.GB16937@xz-x1 \
--to=peterx@redhat.com \
--cc=armbru@redhat.com \
--cc=qemu-devel@nongnu.org \
--cc=w.bumiller@proxmox.com \
/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).