From: "Emilio G. Cota" <cota@braap.org>
To: Peter Xu <peterx@redhat.com>
Cc: Fam Zheng <famz@redhat.com>, Paolo Bonzini <pbonzini@redhat.com>,
qemu-devel@nongnu.org, Stefan Hajnoczi <stefanha@redhat.com>
Subject: Re: [Qemu-devel] [PATCH v2] QemuMutex: support --enable-debug-mutex
Date: Thu, 19 Apr 2018 15:43:01 -0400 [thread overview]
Message-ID: <20180419194301.GA22127@flamenco> (raw)
In-Reply-To: <20180419031335.GH14841@xz-mi>
On Thu, Apr 19, 2018 at 11:13:35 +0800, Peter Xu wrote:
> On Thu, Apr 19, 2018 at 09:56:31AM +0800, Fam Zheng wrote:
(snip)
> > > @@ -12,6 +12,10 @@ typedef QemuMutex QemuRecMutex;
> > >
> > > struct QemuMutex {
> > > pthread_mutex_t lock;
> > > +#ifdef CONFIG_DEBUG_MUTEX
> > > + const char *file;
> > > + int line;
> > > +#endif
> >
> > These look quite cheap, why we need a configure option to enable it?
>
> Yeah; I am not 100% sure about whether it's cheap or not, hence with
> that. I can remove that part if we are sure we want it always.
I can think of a few good reasons not to enable these by default.
* Adds 12 bytes to struct QemuMutex on 64-bit hosts.
* Increases slightly the critical region (the assignment happens
once the lock has been acquired)
+ This is measurable for a single-thread with a microbenchmark:
Before (no --enable-debug-mutex):
$ taskset -c 0 tests/atomic_add-bench -n 1 -m -d 10
Parameters:
# of threads: 1
duration: 10
ops' range: 1024
Results:
Duration: 10 s
Throughput: 57.59 Mops/s
Throughput/thread: 57.59 Mops/s/thread
After (with --enable-debug-mutex):
$ taskset -c 0 tests/atomic_add-bench -n 1 -m -d 10
Parameters:
# of threads: 1
duration: 10
ops' range: 1024
Results:
Duration: 10 s
Throughput: 56.25 Mops/s
Throughput/thread: 56.25 Mops/s/thread
NB. The -m option for atomic_add-bench is not upstream yet, but
feel free to cherry-pick this commit:
https://github.com/cota/qemu/commit/f04f34df
+ A longer critical section can impact scalability, especially
for large core counts.
Also note that there are some alternatives to this.
On POSIX systems when I need to debug mutexes I just revert
24fa904 ("qemu-thread: do not use PTHREAD_MUTEX_ERRORCHECK",
2015-03-10). Note that this doesn't work well with fork() in
linux-user, but I rarely need that.
Another alternative is to trace mutex_lock, that will give
you the same info although at higher overhead (in both runtime
and disk usage).
So I'm not against this, but please keep it configured out.
BTW you might also want to add the file/line pair to
qemu-thread-win32.c, or hide the configure option to Windows
users.
Thanks,
Emilio
next prev parent reply other threads:[~2018-04-19 19:43 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-04-18 9:06 [Qemu-devel] [PATCH v2] QemuMutex: support --enable-debug-mutex Peter Xu
2018-04-19 1:56 ` Fam Zheng
2018-04-19 3:13 ` Peter Xu
2018-04-19 19:43 ` Emilio G. Cota [this message]
2018-04-19 22:48 ` Emilio G. Cota
2018-04-20 2:30 ` Peter Xu
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=20180419194301.GA22127@flamenco \
--to=cota@braap.org \
--cc=famz@redhat.com \
--cc=pbonzini@redhat.com \
--cc=peterx@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).