From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:41750) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aSs12-0004ow-5x for qemu-devel@nongnu.org; Mon, 08 Feb 2016 15:02:33 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1aSs0y-00057s-Oa for qemu-devel@nongnu.org; Mon, 08 Feb 2016 15:02:32 -0500 Received: from mail-wm0-x233.google.com ([2a00:1450:400c:c09::233]:35063) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aSs0y-00057b-EM for qemu-devel@nongnu.org; Mon, 08 Feb 2016 15:02:28 -0500 Received: by mail-wm0-x233.google.com with SMTP id c200so32019334wme.0 for ; Mon, 08 Feb 2016 12:02:28 -0800 (PST) References: <20160208153014.GD31586@stefanha-x1.localdomain> <1454957515-29258-1-git-send-email-hollis_blanchard@mentor.com> From: Alex =?utf-8?Q?Benn=C3=A9e?= In-reply-to: <1454957515-29258-1-git-send-email-hollis_blanchard@mentor.com> Date: Mon, 08 Feb 2016 20:02:26 +0000 Message-ID: <87h9hjvulp.fsf@linaro.org> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit Subject: Re: [Qemu-devel] [PATCH] trace: only create simple backend trace files when an event is emitted. List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Hollis Blanchard Cc: stefanha@gmail.com, qemu-devel@nongnu.org Hollis Blanchard writes: > Previously, trace record files (created by st_set_trace_file_enabled(true)) > were created by the simple backend at initialization time, even if no events > were actually enabled. > > As a consequence, the working directory would become littered with trace-PID > files just by enabling the simple backend at configure time, even when no > -trace options were used. > > --- > I've been using this to avoid creation of empty trace record files. I haven't > done any scientific performance studies, but an extra function > call/conditional/return when recording every trace event doesn't seem to have > any noticeable effect. > > Signed-off-by: Hollis Blanchard > --- > trace/simple.c | 5 +++-- > 1 file changed, 3 insertions(+), 2 deletions(-) > > diff --git a/trace/simple.c b/trace/simple.c > index 3fdcc82..67ccc3c 100644 > --- a/trace/simple.c > +++ b/trace/simple.c > @@ -209,6 +209,8 @@ int trace_record_start(TraceBufferRecord *rec, TraceEventID event, size_t datasi > uint64_t event_u64 = event; > uint64_t timestamp_ns = get_clock(); > > + st_set_trace_file_enabled(true); > + > do { > old_idx = g_atomic_int_get(&trace_idx); > smp_rmb(); > @@ -320,6 +322,7 @@ void st_set_trace_file_enabled(bool enable) > */ > void st_set_trace_file(const char *file) > { > + /* Tracing will be re-enabled when the next event is written. */ > st_set_trace_file_enabled(false); > > g_free(trace_file_name); > @@ -330,8 +333,6 @@ void st_set_trace_file(const char *file) > } else { > trace_file_name = g_strdup_printf("%s", file); > } > - > - st_set_trace_file_enabled(true); > } This fixes the "make check" bug I reported: http://lists.nongnu.org/archive/html/qemu-devel/2016-02/msg01811.html because by not enabling the file it doesn't attempt to flush it before the test has started. However as it is a side-effect of the patch there may be a better solution. However have a: Tested-by: Alex Bennée -- Alex Bennée