From: Markus Armbruster <armbru@redhat.com>
To: Peter Xu <peterx@redhat.com>
Cc: qemu-devel@nongnu.org,
"Dr . David Alan Gilbert" <dgilbert@redhat.com>,
"Stefan Hajnoczi" <stefanha@redhat.com>,
"Marc-André Lureau" <marcandre.lureau@redhat.com>
Subject: Re: [Qemu-devel] [PATCH v5 1/4] monitor: rename out_lock to mon_lock
Date: Thu, 17 May 2018 14:32:34 +0200 [thread overview]
Message-ID: <877eo2mpi5.fsf@dusky.pond.sub.org> (raw)
In-Reply-To: <20180509041734.14135-2-peterx@redhat.com> (Peter Xu's message of "Wed, 9 May 2018 12:17:31 +0800")
Peter Xu <peterx@redhat.com> writes:
> The out_lock was only protecting a few Monitor fields. In the future
"was protecting"? When? Or do you mean "is protecting"?
> 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 turn it into a bigger lock"? If this patch does what its title
claims, it can't "turn" anything. Do you perhaps mean "We're going to
turn it into a bigger lock"?
> For now we share the lock. We can split the lock when needed.
What exactly do you mean by "we share the lock"?
> Since at it, arrange the Monitor struct a bit.
"Since we're at it, rearrange". Can touch up on commit.
>
> Reviewed-by: Stefan Hajnoczi <stefanha@redhat.com>
> Signed-off-by: Peter Xu <peterx@redhat.com>
> ---
> monitor.c | 53 +++++++++++++++++++++++++++++------------------------
> 1 file changed, 29 insertions(+), 24 deletions(-)
>
> diff --git a/monitor.c b/monitor.c
> index 46814af533..14c681dc8a 100644
> --- a/monitor.c
> +++ b/monitor.c
> @@ -207,15 +207,6 @@ struct Monitor {
> 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;
> -
> - /* Read under either BQL or out_lock, written with BQL+out_lock. */
> - int mux_out;
> -
> ReadLineState *rs;
> MonitorQMP qmp;
> gchar *mon_cpu_path;
> @@ -224,6 +215,20 @@ struct Monitor {
> mon_cmd_t *cmd_table;
> QLIST_HEAD(,mon_fd_t) fds;
> QTAILQ_ENTRY(Monitor) entry;
> +
> + /*
> + * The per-monitor lock. We can't access guest memory when holding
> + * the lock.
> + */
> + QemuMutex mon_lock;
> +
> + /*
> + * Fields that are protected by the per-monitor lock.
> + */
> + QString *outbuf;
> + guint out_watch;
> + /* Read under either BQL or mon_lock, written with BQL+mon_lock. */
> + int mux_out;
This is an improvement.
> };
>
> /* Let's add monitor global variables to this struct. */
[Remainder of patch snipped; it looks completely mechanical]
next prev parent reply other threads:[~2018-05-17 12:32 UTC|newest]
Thread overview: 22+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-05-09 4:17 [Qemu-devel] [PATCH v5 0/4] monitor: let Monitor be thread safe Peter Xu
2018-05-09 4:17 ` [Qemu-devel] [PATCH v5 1/4] monitor: rename out_lock to mon_lock Peter Xu
2018-05-17 12:32 ` Markus Armbruster [this message]
2018-05-18 10:15 ` Peter Xu
2018-05-09 4:17 ` [Qemu-devel] [PATCH v5 2/4] monitor: protect mon->fds with mon_lock Peter Xu
2018-05-10 10:11 ` Stefan Hajnoczi
2018-05-17 12:47 ` Markus Armbruster
2018-05-09 4:17 ` [Qemu-devel] [PATCH v5 3/4] monitor: more comments on lock-free fleids/funcs Peter Xu
2018-05-10 10:12 ` Stefan Hajnoczi
2018-05-17 12:46 ` Markus Armbruster
2018-05-18 10:21 ` Peter Xu
2018-05-23 8:29 ` Markus Armbruster
2018-05-23 8:47 ` Peter Xu
2018-05-23 15:15 ` Markus Armbruster
2018-05-24 4:37 ` Peter Xu
2018-05-09 4:17 ` [Qemu-devel] [PATCH v5 4/4] monitor: add lock to protect mon_fdsets Peter Xu
2018-05-17 13:03 ` Markus Armbruster
2018-05-18 10:53 ` Peter Xu
2018-05-18 12:27 ` Markus Armbruster
2018-05-21 5:18 ` Peter Xu
2018-05-23 8:39 ` Markus Armbruster
2018-05-23 8:52 ` 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=877eo2mpi5.fsf@dusky.pond.sub.org \
--to=armbru@redhat.com \
--cc=dgilbert@redhat.com \
--cc=marcandre.lureau@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).