From: Robert Foley <robert.foley@linaro.org>
To: Richard Henderson <richard.henderson@linaro.org>
Cc: "Peter Puhov" <peter.puhov@linaro.org>,
"Alex Bennée" <alex.bennee@linaro.org>,
qemu-devel@nongnu.org
Subject: Re: [PATCH v1 1/5] Add a mutex to guarantee single writer to qemu_logfile handle.
Date: Mon, 18 Nov 2019 07:39:22 -0500 [thread overview]
Message-ID: <CAEyhzFt7PbvWTwTMER4icmOVGu-juCDafcOfT=sbNOBBUyXyCA@mail.gmail.com> (raw)
In-Reply-To: <f41150bd-81dc-f754-be91-72065b31cae4@linaro.org>
> > +
> > + g_assert(qemu_logfile_mutex.initialized);
>
> Why the asserts?
>
> If you want a runtime test, then use the test to initialize it.
> Otherwise, trust the constructor.
>
I see your point here. We can/should just trust the constructor.
Will remove the mutex.initialized asserts.
Thanks,
-Rob
On Sat, 16 Nov 2019 at 06:58, Richard Henderson
<richard.henderson@linaro.org> wrote:
>
> On 11/12/19 4:01 PM, Robert Foley wrote:
> > Also added qemu_logfile_init() for initializing the logfile mutex.
> >
> > Signed-off-by: Robert Foley <robert.foley@linaro.org>
> > ---
> > v1
> > - changed qemu_logfile_init() to use __constructor__.
> > ---
> > util/log.c | 14 ++++++++++++++
> > 1 file changed, 14 insertions(+)
> >
> > diff --git a/util/log.c b/util/log.c
> > index 1ca13059ee..c25643dc99 100644
> > --- a/util/log.c
> > +++ b/util/log.c
> > @@ -24,8 +24,10 @@
> > #include "qapi/error.h"
> > #include "qemu/cutils.h"
> > #include "trace/control.h"
> > +#include "qemu/thread.h"
> >
> > static char *logfilename;
> > +static QemuMutex qemu_logfile_mutex;
> > FILE *qemu_logfile;
> > int qemu_loglevel;
> > static int log_append = 0;
> > @@ -49,6 +51,11 @@ int qemu_log(const char *fmt, ...)
> > return ret;
> > }
> >
> > +static void __attribute__((__constructor__)) qemu_logfile_init(void)
> > +{
> > + qemu_mutex_init(&qemu_logfile_mutex);
> > +}
> > +
> > static bool log_uses_own_buffers;
> >
> > /* enable or disable low levels log */
> > @@ -58,6 +65,9 @@ void qemu_set_log(int log_flags)
> > #ifdef CONFIG_TRACE_LOG
> > qemu_loglevel |= LOG_TRACE;
> > #endif
> > +
> > + g_assert(qemu_logfile_mutex.initialized);
>
> Why the asserts?
>
> If you want a runtime test, then use the test to initialize it.
> Otherwise, trust the constructor.
>
>
> r~
next prev parent reply other threads:[~2019-11-18 12:40 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-11-12 15:01 [PATCH v1 0/5] Make the qemu_logfile handle thread safe Robert Foley
2019-11-12 15:01 ` [PATCH v1 1/5] Add a mutex to guarantee single writer to qemu_logfile handle Robert Foley
2019-11-12 17:09 ` Alex Bennée
2019-11-16 11:57 ` Richard Henderson
2019-11-18 12:39 ` Robert Foley [this message]
2019-11-12 15:01 ` [PATCH v1 2/5] qemu_log_lock/unlock now preserves the " Robert Foley
2019-11-12 17:17 ` Alex Bennée
2019-11-16 12:26 ` Richard Henderson
2019-11-12 15:01 ` [PATCH v1 3/5] Add use of RCU for qemu_logfile Robert Foley
2019-11-12 17:36 ` Alex Bennée
2019-11-12 19:20 ` Robert Foley
2019-11-13 15:24 ` Alex Bennée
2019-11-12 15:01 ` [PATCH v1 4/5] Added tests for close and change of logfile Robert Foley
2019-11-12 18:21 ` Alex Bennée
2019-11-12 15:01 ` [PATCH v1 5/5] Fix double free issue in qemu_set_log_filename() Robert Foley
2019-11-12 18:23 ` Alex Bennée
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='CAEyhzFt7PbvWTwTMER4icmOVGu-juCDafcOfT=sbNOBBUyXyCA@mail.gmail.com' \
--to=robert.foley@linaro.org \
--cc=alex.bennee@linaro.org \
--cc=peter.puhov@linaro.org \
--cc=qemu-devel@nongnu.org \
--cc=richard.henderson@linaro.org \
/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).