From: Kevin Wolf <kwolf@redhat.com>
To: Stefan Hajnoczi <stefanha@redhat.com>
Cc: mario.dechenno@unina2.it, Paolo Bonzini <pbonzini@redhat.com>,
qemu-devel@nongnu.org
Subject: Re: [Qemu-devel] [PATCH] osdep: initialize glib threads in all QEMU tools
Date: Tue, 8 Oct 2013 14:25:50 +0200 [thread overview]
Message-ID: <20131008122550.GD25109@dhcp-200-207.str.redhat.com> (raw)
In-Reply-To: <1381226311-23489-1-git-send-email-stefanha@redhat.com>
Am 08.10.2013 um 11:58 hat Stefan Hajnoczi geschrieben:
> glib versions prior to 2.31.0 require an explicit g_thread_init() call
> to enable multi-threading.
>
> Failure to initialize threading causes glib to take single-threaded code
> paths without synchronization. For example, the g_slice allocator will
> crash due to race conditions.
>
> Fix this for all QEMU tool programs (qemu-nbd, qemu-io, qemu-img) by
> moving the g_thread_init() call from vl.c:main() into a new
> osdep.c:thread_init() constructor function.
>
> thread_init() has __attribute__((constructor)) and is automatically
> invoked by the runtime during startup.
>
> We can now drop the "simple" trace backend's g_thread_init() call since
> thread_init() already called it.
>
> Note that we must keep coroutine-gthread.c's g_thread_init() call which
> is located in a constructor function. There is no guarantee for
> constructor function ordering so thread_init() may only be called later.
The glib documentation says:
Since version 2.24, calling g_thread_init() multiple times is
allowed, but nothing happens except for the first call.
I take that this means previously it wasn't allowed. qemu's configure
checks for a minimum version of 2.12, so we seems to support glib
versions that don't allow g_thread_init() to be called multiple times.
Do we need to protect against this?
Kevin
next prev parent reply other threads:[~2013-10-08 12:25 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-10-08 9:58 [Qemu-devel] [PATCH] osdep: initialize glib threads in all QEMU tools Stefan Hajnoczi
2013-10-08 12:25 ` Kevin Wolf [this message]
2013-10-08 13:08 ` Paolo Bonzini
2013-10-08 13:58 ` Kevin Wolf
2013-10-09 8:31 ` Stefan Hajnoczi
2014-03-23 15:56 ` Stefan Hajnoczi
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=20131008122550.GD25109@dhcp-200-207.str.redhat.com \
--to=kwolf@redhat.com \
--cc=mario.dechenno@unina2.it \
--cc=pbonzini@redhat.com \
--cc=qemu-devel@nongnu.org \
--cc=stefanha@redhat.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).