All of lore.kernel.org
 help / color / mirror / Atom feed
From: Stefan Hajnoczi <stefanha@redhat.com>
To: Peter Xu <peterx@redhat.com>
Cc: qemu-devel@nongnu.org, "Eric Blake" <eblake@redhat.com>,
	"Marc-André Lureau" <marcandre.lureau@redhat.com>,
	"Markus Armbruster" <armbru@redhat.com>,
	"Dr . David Alan Gilbert" <dgilbert@redhat.com>
Subject: Re: [Qemu-devel] [PATCH v2 1/3] monitor: rename out_lock to mon_lock
Date: Mon, 30 Apr 2018 10:56:49 +0100	[thread overview]
Message-ID: <20180430095649.GC4002@stefanha-x1.localdomain> (raw)
In-Reply-To: <20180418090239.13090-2-peterx@redhat.com>

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

On Wed, Apr 18, 2018 at 05:02:37PM +0800, Peter Xu wrote:
> The out_lock was only protecting out buffers.  In the future the monitor
> code will start to run in multiple threads.  We turn it into a bigger
> lock to protect not only the out buffer but also all the rest.  We split
> this lock until necessary.  So far I don't see a reason to complicate
> lock usage for monitors.
> 
> Since at it, arrange the Monitor struct a bit.
> 
> Signed-off-by: Peter Xu <peterx@redhat.com>
> ---
>  monitor.c | 39 ++++++++++++++++++---------------------
>  1 file changed, 18 insertions(+), 21 deletions(-)
> 
> diff --git a/monitor.c b/monitor.c
> index 39f8ee17ba..c93aa4e22b 100644
> --- a/monitor.c
> +++ b/monitor.c
> @@ -202,20 +202,17 @@ typedef struct {
>  
>  struct Monitor {
>      CharBackend chr;
> +    /* We can't access guest memory when holding the lock */
> +    QemuMutex mon_lock;

Please document which field this lock protects.  For example, outbuf and
out_watch need a comment.

>      int reset_seen;
>      int flags;
>      int suspend_cnt;            /* Needs to be accessed atomically */
>      bool skip_flush;
>      bool use_io_thr;
> -
> -    /* We can't access guest memory when holding the lock */
> -    QemuMutex out_lock;
>      QString *outbuf;
>      guint out_watch;

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 455 bytes --]

  reply	other threads:[~2018-04-30  9:57 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-04-18  9:02 [Qemu-devel] [PATCH v2 0/3] monitor: let Monitor be thread safe Peter Xu
2018-04-18  9:02 ` [Qemu-devel] [PATCH v2 1/3] monitor: rename out_lock to mon_lock Peter Xu
2018-04-30  9:56   ` Stefan Hajnoczi [this message]
2018-05-02  6:33     ` Peter Xu
2018-04-18  9:02 ` [Qemu-devel] [PATCH v2 2/3] monitor: take mon_lock where proper Peter Xu
2018-04-30 10:10   ` Stefan Hajnoczi
2018-05-02  7:04     ` Peter Xu
2018-04-18  9:02 ` [Qemu-devel] [PATCH v2 3/3] monitor: add lock to protect mon_fdsets Peter Xu
2018-04-30 10:21   ` Stefan Hajnoczi
2018-05-02  7:22     ` 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=20180430095649.GC4002@stefanha-x1.localdomain \
    --to=stefanha@redhat.com \
    --cc=armbru@redhat.com \
    --cc=dgilbert@redhat.com \
    --cc=eblake@redhat.com \
    --cc=marcandre.lureau@redhat.com \
    --cc=peterx@redhat.com \
    --cc=qemu-devel@nongnu.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 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.