[Qemu-devel] [PATCH v4 3/4] monitor: more comments on lock-free fleids/funcs

Peter Xu posted 4 patches 7 years, 6 months ago
There is a newer version of this series
[Qemu-devel] [PATCH v4 3/4] monitor: more comments on lock-free fleids/funcs
Posted by Peter Xu 7 years, 6 months ago
Add some explicit comment for both Readline and cpu_set/cpu_get helpers
that they do not need the mon_lock protection.

Signed-off-by: Peter Xu <peterx@redhat.com>
---
 monitor.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/monitor.c b/monitor.c
index 9f361ec21e..6100ad44f8 100644
--- a/monitor.c
+++ b/monitor.c
@@ -207,6 +207,7 @@ struct Monitor {
     int suspend_cnt;            /* Needs to be accessed atomically */
     bool skip_flush;
     bool use_io_thr;
+    /* Only used in parser, so no lock needed. */
     ReadLineState *rs;
     MonitorQMP qmp;
     gchar *mon_cpu_path;
@@ -1316,7 +1317,7 @@ void qmp_qmp_capabilities(bool has_enable, QMPCapabilityList *enable,
     cur_mon->qmp.commands = &qmp_commands;
 }
 
-/* set the current CPU defined by the user */
+/* set the current CPU defined by the user.  BQL needed. */
 int monitor_set_cpu(int cpu_index)
 {
     CPUState *cpu;
@@ -1330,6 +1331,7 @@ int monitor_set_cpu(int cpu_index)
     return 0;
 }
 
+/* BQL neeeded. */
 static CPUState *mon_get_cpu_sync(bool synchronize)
 {
     CPUState *cpu;
-- 
2.14.3


Re: [Qemu-devel] [PATCH v4 3/4] monitor: more comments on lock-free fleids/funcs
Posted by Stefan Hajnoczi 7 years, 5 months ago
On Wed, May 02, 2018 at 06:04:21PM +0800, Peter Xu wrote:
> Add some explicit comment for both Readline and cpu_set/cpu_get helpers
> that they do not need the mon_lock protection.
> 
> Signed-off-by: Peter Xu <peterx@redhat.com>
> ---
>  monitor.c | 4 +++-
>  1 file changed, 3 insertions(+), 1 deletion(-)
> 
> diff --git a/monitor.c b/monitor.c
> index 9f361ec21e..6100ad44f8 100644
> --- a/monitor.c
> +++ b/monitor.c
> @@ -207,6 +207,7 @@ struct Monitor {
>      int suspend_cnt;            /* Needs to be accessed atomically */
>      bool skip_flush;
>      bool use_io_thr;
> +    /* Only used in parser, so no lock needed. */
>      ReadLineState *rs;
>      MonitorQMP qmp;
>      gchar *mon_cpu_path;

Which fields does this comment cover?
Re: [Qemu-devel] [PATCH v4 3/4] monitor: more comments on lock-free fleids/funcs
Posted by Peter Xu 7 years, 5 months ago
On Tue, May 08, 2018 at 11:23:38AM +0100, Stefan Hajnoczi wrote:
> On Wed, May 02, 2018 at 06:04:21PM +0800, Peter Xu wrote:
> > Add some explicit comment for both Readline and cpu_set/cpu_get helpers
> > that they do not need the mon_lock protection.
> > 
> > Signed-off-by: Peter Xu <peterx@redhat.com>
> > ---
> >  monitor.c | 4 +++-
> >  1 file changed, 3 insertions(+), 1 deletion(-)
> > 
> > diff --git a/monitor.c b/monitor.c
> > index 9f361ec21e..6100ad44f8 100644
> > --- a/monitor.c
> > +++ b/monitor.c
> > @@ -207,6 +207,7 @@ struct Monitor {
> >      int suspend_cnt;            /* Needs to be accessed atomically */
> >      bool skip_flush;
> >      bool use_io_thr;
> > +    /* Only used in parser, so no lock needed. */
> >      ReadLineState *rs;
> >      MonitorQMP qmp;
> >      gchar *mon_cpu_path;
> 
> Which fields does this comment cover?

"rs" only.  Maybe I should move the comment to the end of line?

    ReadLineState *rs;       /* Only used in parser, so no lock needed. */

-- 
Peter Xu

Re: [Qemu-devel] [PATCH v4 3/4] monitor: more comments on lock-free fleids/funcs
Posted by Stefan Hajnoczi 7 years, 5 months ago
On Tue, May 08, 2018 at 06:32:32PM +0800, Peter Xu wrote:
> On Tue, May 08, 2018 at 11:23:38AM +0100, Stefan Hajnoczi wrote:
> > On Wed, May 02, 2018 at 06:04:21PM +0800, Peter Xu wrote:
> > > Add some explicit comment for both Readline and cpu_set/cpu_get helpers
> > > that they do not need the mon_lock protection.
> > > 
> > > Signed-off-by: Peter Xu <peterx@redhat.com>
> > > ---
> > >  monitor.c | 4 +++-
> > >  1 file changed, 3 insertions(+), 1 deletion(-)
> > > 
> > > diff --git a/monitor.c b/monitor.c
> > > index 9f361ec21e..6100ad44f8 100644
> > > --- a/monitor.c
> > > +++ b/monitor.c
> > > @@ -207,6 +207,7 @@ struct Monitor {
> > >      int suspend_cnt;            /* Needs to be accessed atomically */
> > >      bool skip_flush;
> > >      bool use_io_thr;
> > > +    /* Only used in parser, so no lock needed. */
> > >      ReadLineState *rs;
> > >      MonitorQMP qmp;
> > >      gchar *mon_cpu_path;
> > 
> > Which fields does this comment cover?
> 
> "rs" only.  Maybe I should move the comment to the end of line?
> 
>     ReadLineState *rs;       /* Only used in parser, so no lock needed. */

Yes, please.

Stefan