qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Michael Mueller <mimu@linux.vnet.ibm.com>
To: Stefan Hajnoczi <stefanha@gmail.com>
Cc: "Christian Borntraeger" <borntraeger@de.ibm.com>,
	qemu-devel@nongnu.org, Lluís <xscript@gmx.net>
Subject: Re: [Qemu-devel] [PATCH 02/12] trace+libvirt: start trace processing thread in final child process
Date: Fri, 6 Sep 2013 16:06:08 +0200	[thread overview]
Message-ID: <20130906160608.2c7a64c5@bee> (raw)
In-Reply-To: <20130717020815.GC26311@stefanha-thinkpad.redhat.com>

On Wed, 17 Jul 2013 10:08:15 +0800
Stefan Hajnoczi <stefanha@gmail.com> wrote:

> On Tue, Jul 16, 2013 at 02:17:28PM +0200, Michael Mueller wrote:
> > On Tue, 16 Jul 2013 11:05:11 +0800
> > Stefan Hajnoczi <stefanha@gmail.com> wrote:
> > 
> > > On Mon, Jul 15, 2013 at 09:41:19PM +0200, Christian Borntraeger wrote:
> > > > When running with trace backend e.g. "simple" the writer thread
> > > > needs to be implemented in the same process context as the trace
> > > > points that will be processed. Under libvirtd control, qemu gets
> > > > first started in daemonized mode to privide its capabilities.
> > > > Creating the writer thread in the initial process context then
> > > > leads to a dead lock because the thread gets termined together with
> > > > the initial parent. (-daemonize) This results in stale qemu
> > > > processes. Fix this by deferring trace initialization.
> > > 
> > > I don't think this works since trace events will fill up trace_buf[]
> > > and eventually invoke flush_trace_file().
> > > 
> > > At that point we use trace_available_cond and trace_empty_cond, which
> > > may be NULL in Glib <2.31.0.
> > > 
> > > Perhaps this can be made safe by checking trace_writeout_enabled.  It
> > > will be false before the backend has been initialized.
> > > 
> > > Stefan
> > > 
> > 
> > You mean something like this. I'll give it a try:
> > 
> > ---
> >  trace/simple.c |    3 ++-
> >  1 file changed, 2 insertions(+), 1 deletion(-)
> > 
> > --- a/trace/simple.c
> > +++ b/trace/simple.c
> > @@ -53,7 +53,7 @@ static GCond *trace_empty_cond;
> >  #endif
> >  
> >  static bool trace_available;
> > -static bool trace_writeout_enabled;
> > +static bool trace_writeout_enabled = false;
> 
> static bool is automatically initialized to false.
> 
> >  enum {
> >      TRACE_BUF_LEN = 4096 * 64,
> > @@ -427,5 +427,6 @@ bool trace_backend_init(const char *even
> >      atexit(st_flush_trace_buffer);
> >      trace_backend_init_events(events);
> >      st_set_trace_file(file);
> > +    trace_writeout_enabled = false;
> 
> I was thinking along the lines of trace_record_finish() not calling
> flush_trace_file() if trace_writeout_enabled is false.
> 
> Stefan
> 

I just looked into it again and think that it is save the way I suggested, because as long
trace_backend_init() isn't called, also trace_backend_init_events() hasn't registered any
events. Thus no trace records will be written and can fill up the trace buffer.

Michael

  reply	other threads:[~2013-09-06 14:06 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-07-15 19:41 [Qemu-devel] [PATCH 02/12] trace+libvirt: start trace processing thread in final child process Christian Borntraeger
2013-07-16  3:05 ` Stefan Hajnoczi
2013-07-16 12:17   ` Michael Mueller
2013-07-17  2:08     ` Stefan Hajnoczi
2013-09-06 14:06       ` Michael Mueller [this message]
2013-09-23 13:09         ` 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=20130906160608.2c7a64c5@bee \
    --to=mimu@linux.vnet.ibm.com \
    --cc=borntraeger@de.ibm.com \
    --cc=qemu-devel@nongnu.org \
    --cc=stefanha@gmail.com \
    --cc=xscript@gmx.net \
    /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).