All of lore.kernel.org
 help / color / mirror / Atom feed
From: Paolo Bonzini <pbonzini@redhat.com>
To: Stefan Hajnoczi <stefanha@redhat.com>
Cc: "Alex Bennée" <alex.bennee@linaro.org>,
	qemu-devel <qemu-devel@nongnu.org>,
	"Dr. David Alan Gilbert" <dgilbert@redhat.com>
Subject: Re: [PATCH 0/2] thread: add lock guard macros
Date: Wed, 11 Mar 2020 13:52:35 +0100	[thread overview]
Message-ID: <CABgObfat-zQziF1EoJTjCO6zJBEYu074PZUCQOrgpeuC2uzFuw@mail.gmail.com> (raw)
In-Reply-To: <20200311123624.277221-1-stefanha@redhat.com>

[-- Attachment #1: Type: text/plain, Size: 1289 bytes --]

Il mer 11 mar 2020, 13:38 Stefan Hajnoczi <stefanha@redhat.com> ha scritto:

> Lock guards automatically call qemu_(rec_)mutex_unlock() when returning
> from a
> function or leaving leaving a lexical scope.  This simplifies code and
> eliminates leaks (especially in error code paths).
>
> This series adds lock guards for QemuMutex and QemuRecMutex.  It does not
> convert the entire tree but includes example conversions.
>

Thanks for picking this up! It should be possible to use QemuLockable to
introduce a single set of lock guard macros that work for mutexes,
spinlocks and CoMutexes. Would you look into that?

(C++ also has unique_lock, a kind of lock guard that can be unlocked early
and won't cause a double unlock, and also can be created unlocked. However
it makes sense to not implement that unless one has a killer application of
it in the tree).

Paolo


> Stefan Hajnoczi (2):
>   thread: add QemuRecMutex lock guards
>   thread: add QemuMutex lock guards
>
>  include/qemu/thread.h | 52 +++++++++++++++++++++++++++++++++++++++++++
>  plugins/core.c        |  6 ++---
>  plugins/loader.c      | 15 ++++++-------
>  util/qemu-timer.c     | 22 +++++++++---------
>  4 files changed, 71 insertions(+), 24 deletions(-)
>
> --
> 2.24.1
>
>

[-- Attachment #2: Type: text/html, Size: 1946 bytes --]

  parent reply	other threads:[~2020-03-11 12:53 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-03-11 12:36 [PATCH 0/2] thread: add lock guard macros Stefan Hajnoczi
2020-03-11 12:36 ` [PATCH 1/2] thread: add QemuRecMutex lock guards Stefan Hajnoczi
2020-03-11 12:36 ` [PATCH 2/2] thread: add QemuMutex " Stefan Hajnoczi
2020-03-11 12:52 ` Paolo Bonzini [this message]
2020-03-11 17:06   ` [PATCH 0/2] thread: add lock guard macros Stefan Hajnoczi
2020-03-11 13:20 ` no-reply
2020-03-11 13:22 ` no-reply
2020-03-11 14:50 ` Markus Armbruster
2020-03-11 15:06   ` Paolo Bonzini
2020-03-11 17:02     ` 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=CABgObfat-zQziF1EoJTjCO6zJBEYu074PZUCQOrgpeuC2uzFuw@mail.gmail.com \
    --to=pbonzini@redhat.com \
    --cc=alex.bennee@linaro.org \
    --cc=dgilbert@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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.