[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Qemu-devel] [RFC v4 15/27] monitor: let monitor_{suspend|resume} th
From: |
Peter Xu |
Subject: |
Re: [Qemu-devel] [RFC v4 15/27] monitor: let monitor_{suspend|resume} thread safe |
Date: |
Fri, 24 Nov 2017 15:58:41 +0800 |
User-agent: |
Mutt/1.9.1 (2017-09-22) |
On Thu, Nov 23, 2017 at 11:23:16AM +0000, Dr. David Alan Gilbert wrote:
> * Peter Xu (address@hidden) wrote:
> > Monitor code now can be run in more than one thread. Let the suspend
> > and resume code be thread safe.
> >
> > Reviewed-by: Fam Zheng <address@hidden>
> > Signed-off-by: Peter Xu <address@hidden>
> > ---
> > monitor.c | 5 +++--
> > 1 file changed, 3 insertions(+), 2 deletions(-)
> >
> > diff --git a/monitor.c b/monitor.c
> > index ec03f1b232..30f9cd80de 100644
> > --- a/monitor.c
> > +++ b/monitor.c
> > @@ -4003,7 +4003,7 @@ int monitor_suspend(Monitor *mon)
> > {
> > if (!mon->rs)
> > return -ENOTTY;
> > - mon->suspend_cnt++;
> > + atomic_inc(&mon->suspend_cnt);
> > return 0;
> > }
> >
> > @@ -4011,8 +4011,9 @@ void monitor_resume(Monitor *mon)
> > {
> > if (!mon->rs)
> > return;
> > - if (--mon->suspend_cnt == 0)
> > + if (atomic_dec_fetch(&mon->suspend_cnt) == 0) {
> > readline_show_prompt(mon->rs);
> > + }
> > }
> >
> > static QObject *get_qmp_greeting(void)
>
> Do you also need to do an atomic_read() in monitor_can_read?
> (I guess the code in monitor_event is ok because it's only the mux
> path, but still it's probably better to use all atomic ops on
> the suspend_cnt variable to be consistent).
Agreed.
--
Peter Xu
- Re: [Qemu-devel] [RFC v4 09/27] monitor: create monitor dedicate iothread, (continued)
[Qemu-devel] [RFC v4 11/27] qmp: introduce QMPCapability, Peter Xu, 2017/11/16
[Qemu-devel] [RFC v4 13/27] qmp: introduce some capability helpers, Peter Xu, 2017/11/16
[Qemu-devel] [RFC v4 12/27] qmp: negociate QMP capabilities, Peter Xu, 2017/11/16
[Qemu-devel] [RFC v4 14/27] monitor: introduce monitor_qmp_respond(), Peter Xu, 2017/11/16
[Qemu-devel] [RFC v4 15/27] monitor: let monitor_{suspend|resume} thread safe, Peter Xu, 2017/11/16
[Qemu-devel] [RFC v4 16/27] monitor: separate QMP parser and dispatcher, Peter Xu, 2017/11/16
[Qemu-devel] [RFC v4 17/27] qmp: add new event "request-dropped", Peter Xu, 2017/11/16
[Qemu-devel] [RFC v4 18/27] monitor: send event when request queue full, Peter Xu, 2017/11/16
[Qemu-devel] [RFC v4 19/27] qapi: introduce new cmd option "allow-oob", Peter Xu, 2017/11/16
[Qemu-devel] [RFC v4 20/27] qmp: support out-of-band (oob) execution, Peter Xu, 2017/11/16
[Qemu-devel] [RFC v4 21/27] qmp: let migrate-incoming allow out-of-band, Peter Xu, 2017/11/16