All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v4 0/1] monitor: Support specified vCPU registers
@ 2022-08-02  7:37 zhenwei pi
  2022-08-02  7:37 ` [PATCH v4 1/1] " zhenwei pi
  2022-09-15 11:00 ` [PATCH v4 0/1] " Dr. David Alan Gilbert
  0 siblings, 2 replies; 7+ messages in thread
From: zhenwei pi @ 2022-08-02  7:37 UTC (permalink / raw)
  To: dgilbert, armbru; +Cc: qemu-devel, darren.kenny, zhenwei pi

v3 -> v4: 
- Tweake a few document and output '\n' prefix.

v2 -> v3: 
- Add more document in help info.
- Use 'qemu_get_cpu()' to simplify code.

v1 -> v2: 
- Typo fix in commit message.
- Suggested by Darren, use '[-a|vcpu]' instead of '[-a] [vcpu]',
  becase only one of these may be specified at a time.

v1:
- Support specified vCPU registers for monitor command.

Zhenwei Pi (1):
  monitor: Support specified vCPU registers

 hmp-commands-info.hx |  8 +++++---
 monitor/misc.c       | 10 ++++++++--
 2 files changed, 13 insertions(+), 5 deletions(-)

-- 
2.20.1



^ permalink raw reply	[flat|nested] 7+ messages in thread

* [PATCH v4 1/1] monitor: Support specified vCPU registers
  2022-08-02  7:37 [PATCH v4 0/1] monitor: Support specified vCPU registers zhenwei pi
@ 2022-08-02  7:37 ` zhenwei pi
  2022-08-02 10:55   ` Darren Kenny
  2022-08-15 12:00   ` Dr. David Alan Gilbert
  2022-09-15 11:00 ` [PATCH v4 0/1] " Dr. David Alan Gilbert
  1 sibling, 2 replies; 7+ messages in thread
From: zhenwei pi @ 2022-08-02  7:37 UTC (permalink / raw)
  To: dgilbert, armbru; +Cc: qemu-devel, darren.kenny, zhenwei pi

Originally we have to get all the vCPU registers and parse the
specified one. To improve the performance of this usage, allow user
specified vCPU id to query registers.

Run a VM with 16 vCPU, use bcc tool to track the latency of
'hmp_info_registers':
'info registers -a' uses about 3ms;
'info registers 12' uses about 150us.

Cc: Darren Kenny <darren.kenny@oracle.com>
Reviewed-by: Markus Armbruster <armbru@redhat.com>
Signed-off-by: zhenwei pi <pizhenwei@bytedance.com>
---
 hmp-commands-info.hx |  8 +++++---
 monitor/misc.c       | 10 ++++++++--
 2 files changed, 13 insertions(+), 5 deletions(-)

diff --git a/hmp-commands-info.hx b/hmp-commands-info.hx
index 188d9ece3b..e012035541 100644
--- a/hmp-commands-info.hx
+++ b/hmp-commands-info.hx
@@ -100,9 +100,11 @@ ERST
 
     {
         .name       = "registers",
-        .args_type  = "cpustate_all:-a",
-        .params     = "[-a]",
-        .help       = "show the cpu registers (-a: all - show register info for all cpus)",
+        .args_type  = "cpustate_all:-a,vcpu:i?",
+        .params     = "[-a|vcpu]",
+        .help       = "show the cpu registers (-a: show register info for all cpus;"
+                      " vcpu: specific vCPU to query; show the current CPU's registers if"
+                      " no argument is specified)",
         .cmd        = hmp_info_registers,
     },
 
diff --git a/monitor/misc.c b/monitor/misc.c
index 3d2312ba8d..6436a8786b 100644
--- a/monitor/misc.c
+++ b/monitor/misc.c
@@ -307,6 +307,7 @@ int monitor_get_cpu_index(Monitor *mon)
 static void hmp_info_registers(Monitor *mon, const QDict *qdict)
 {
     bool all_cpus = qdict_get_try_bool(qdict, "cpustate_all", false);
+    int vcpu = qdict_get_try_int(qdict, "vcpu", -1);
     CPUState *cs;
 
     if (all_cpus) {
@@ -315,13 +316,18 @@ static void hmp_info_registers(Monitor *mon, const QDict *qdict)
             cpu_dump_state(cs, NULL, CPU_DUMP_FPU);
         }
     } else {
-        cs = mon_get_cpu(mon);
+        cs = vcpu >= 0 ? qemu_get_cpu(vcpu) : mon_get_cpu(mon);
 
         if (!cs) {
-            monitor_printf(mon, "No CPU available\n");
+            if (vcpu >= 0) {
+                monitor_printf(mon, "CPU#%d not available\n", vcpu);
+            } else {
+                monitor_printf(mon, "No CPU available\n");
+            }
             return;
         }
 
+        monitor_printf(mon, "\nCPU#%d\n", cs->cpu_index);
         cpu_dump_state(cs, NULL, CPU_DUMP_FPU);
     }
 }
-- 
2.20.1



^ permalink raw reply related	[flat|nested] 7+ messages in thread

* Re: [PATCH v4 1/1] monitor: Support specified vCPU registers
  2022-08-02  7:37 ` [PATCH v4 1/1] " zhenwei pi
@ 2022-08-02 10:55   ` Darren Kenny
  2022-08-15 12:00   ` Dr. David Alan Gilbert
  1 sibling, 0 replies; 7+ messages in thread
From: Darren Kenny @ 2022-08-02 10:55 UTC (permalink / raw)
  To: zhenwei pi, dgilbert, armbru; +Cc: qemu-devel, zhenwei pi

This looks good to me...

On Tuesday, 2022-08-02 at 15:37:20 +08, zhenwei pi wrote:
> Originally we have to get all the vCPU registers and parse the
> specified one. To improve the performance of this usage, allow user
> specified vCPU id to query registers.
>
> Run a VM with 16 vCPU, use bcc tool to track the latency of
> 'hmp_info_registers':
> 'info registers -a' uses about 3ms;
> 'info registers 12' uses about 150us.
>
> Cc: Darren Kenny <darren.kenny@oracle.com>
> Reviewed-by: Markus Armbruster <armbru@redhat.com>
> Signed-off-by: zhenwei pi <pizhenwei@bytedance.com>

Reviewed-by: Darren Kenny <darren.kenny@oracle.com>

Thanks,

Darren.

> ---
>  hmp-commands-info.hx |  8 +++++---
>  monitor/misc.c       | 10 ++++++++--
>  2 files changed, 13 insertions(+), 5 deletions(-)
>
> diff --git a/hmp-commands-info.hx b/hmp-commands-info.hx
> index 188d9ece3b..e012035541 100644
> --- a/hmp-commands-info.hx
> +++ b/hmp-commands-info.hx
> @@ -100,9 +100,11 @@ ERST
>  
>      {
>          .name       = "registers",
> -        .args_type  = "cpustate_all:-a",
> -        .params     = "[-a]",
> -        .help       = "show the cpu registers (-a: all - show register info for all cpus)",
> +        .args_type  = "cpustate_all:-a,vcpu:i?",
> +        .params     = "[-a|vcpu]",
> +        .help       = "show the cpu registers (-a: show register info for all cpus;"
> +                      " vcpu: specific vCPU to query; show the current CPU's registers if"
> +                      " no argument is specified)",
>          .cmd        = hmp_info_registers,
>      },
>  
> diff --git a/monitor/misc.c b/monitor/misc.c
> index 3d2312ba8d..6436a8786b 100644
> --- a/monitor/misc.c
> +++ b/monitor/misc.c
> @@ -307,6 +307,7 @@ int monitor_get_cpu_index(Monitor *mon)
>  static void hmp_info_registers(Monitor *mon, const QDict *qdict)
>  {
>      bool all_cpus = qdict_get_try_bool(qdict, "cpustate_all", false);
> +    int vcpu = qdict_get_try_int(qdict, "vcpu", -1);
>      CPUState *cs;
>  
>      if (all_cpus) {
> @@ -315,13 +316,18 @@ static void hmp_info_registers(Monitor *mon, const QDict *qdict)
>              cpu_dump_state(cs, NULL, CPU_DUMP_FPU);
>          }
>      } else {
> -        cs = mon_get_cpu(mon);
> +        cs = vcpu >= 0 ? qemu_get_cpu(vcpu) : mon_get_cpu(mon);
>  
>          if (!cs) {
> -            monitor_printf(mon, "No CPU available\n");
> +            if (vcpu >= 0) {
> +                monitor_printf(mon, "CPU#%d not available\n", vcpu);
> +            } else {
> +                monitor_printf(mon, "No CPU available\n");
> +            }
>              return;
>          }
>  
> +        monitor_printf(mon, "\nCPU#%d\n", cs->cpu_index);
>          cpu_dump_state(cs, NULL, CPU_DUMP_FPU);
>      }
>  }
> -- 
> 2.20.1


^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH v4 1/1] monitor: Support specified vCPU registers
  2022-08-02  7:37 ` [PATCH v4 1/1] " zhenwei pi
  2022-08-02 10:55   ` Darren Kenny
@ 2022-08-15 12:00   ` Dr. David Alan Gilbert
  2022-09-07  3:22     ` PING: " zhenwei pi
  1 sibling, 1 reply; 7+ messages in thread
From: Dr. David Alan Gilbert @ 2022-08-15 12:00 UTC (permalink / raw)
  To: zhenwei pi; +Cc: armbru, qemu-devel, darren.kenny

* zhenwei pi (pizhenwei@bytedance.com) wrote:
> Originally we have to get all the vCPU registers and parse the
> specified one. To improve the performance of this usage, allow user
> specified vCPU id to query registers.
> 
> Run a VM with 16 vCPU, use bcc tool to track the latency of
> 'hmp_info_registers':
> 'info registers -a' uses about 3ms;
> 'info registers 12' uses about 150us.
> 
> Cc: Darren Kenny <darren.kenny@oracle.com>
> Reviewed-by: Markus Armbruster <armbru@redhat.com>
> Signed-off-by: zhenwei pi <pizhenwei@bytedance.com>

Reviewed-by: Dr. David Alan Gilbert <dgilbert@redhat.com>

> ---
>  hmp-commands-info.hx |  8 +++++---
>  monitor/misc.c       | 10 ++++++++--
>  2 files changed, 13 insertions(+), 5 deletions(-)
> 
> diff --git a/hmp-commands-info.hx b/hmp-commands-info.hx
> index 188d9ece3b..e012035541 100644
> --- a/hmp-commands-info.hx
> +++ b/hmp-commands-info.hx
> @@ -100,9 +100,11 @@ ERST
>  
>      {
>          .name       = "registers",
> -        .args_type  = "cpustate_all:-a",
> -        .params     = "[-a]",
> -        .help       = "show the cpu registers (-a: all - show register info for all cpus)",
> +        .args_type  = "cpustate_all:-a,vcpu:i?",
> +        .params     = "[-a|vcpu]",
> +        .help       = "show the cpu registers (-a: show register info for all cpus;"
> +                      " vcpu: specific vCPU to query; show the current CPU's registers if"
> +                      " no argument is specified)",
>          .cmd        = hmp_info_registers,
>      },
>  
> diff --git a/monitor/misc.c b/monitor/misc.c
> index 3d2312ba8d..6436a8786b 100644
> --- a/monitor/misc.c
> +++ b/monitor/misc.c
> @@ -307,6 +307,7 @@ int monitor_get_cpu_index(Monitor *mon)
>  static void hmp_info_registers(Monitor *mon, const QDict *qdict)
>  {
>      bool all_cpus = qdict_get_try_bool(qdict, "cpustate_all", false);
> +    int vcpu = qdict_get_try_int(qdict, "vcpu", -1);
>      CPUState *cs;
>  
>      if (all_cpus) {
> @@ -315,13 +316,18 @@ static void hmp_info_registers(Monitor *mon, const QDict *qdict)
>              cpu_dump_state(cs, NULL, CPU_DUMP_FPU);
>          }
>      } else {
> -        cs = mon_get_cpu(mon);
> +        cs = vcpu >= 0 ? qemu_get_cpu(vcpu) : mon_get_cpu(mon);
>  
>          if (!cs) {
> -            monitor_printf(mon, "No CPU available\n");
> +            if (vcpu >= 0) {
> +                monitor_printf(mon, "CPU#%d not available\n", vcpu);
> +            } else {
> +                monitor_printf(mon, "No CPU available\n");
> +            }
>              return;
>          }
>  
> +        monitor_printf(mon, "\nCPU#%d\n", cs->cpu_index);
>          cpu_dump_state(cs, NULL, CPU_DUMP_FPU);
>      }
>  }
> -- 
> 2.20.1
> 
-- 
Dr. David Alan Gilbert / dgilbert@redhat.com / Manchester, UK



^ permalink raw reply	[flat|nested] 7+ messages in thread

* PING: Re: [PATCH v4 1/1] monitor: Support specified vCPU registers
  2022-08-15 12:00   ` Dr. David Alan Gilbert
@ 2022-09-07  3:22     ` zhenwei pi
  2022-09-07 13:36       ` Dr. David Alan Gilbert
  0 siblings, 1 reply; 7+ messages in thread
From: zhenwei pi @ 2022-09-07  3:22 UTC (permalink / raw)
  To: Dr. David Alan Gilbert, armbru; +Cc: qemu-devel, darren.kenny

PING!

On 8/15/22 20:00, Dr. David Alan Gilbert wrote:
> * zhenwei pi (pizhenwei@bytedance.com) wrote:
>> Originally we have to get all the vCPU registers and parse the
>> specified one. To improve the performance of this usage, allow user
>> specified vCPU id to query registers.
>>
>> Run a VM with 16 vCPU, use bcc tool to track the latency of
>> 'hmp_info_registers':
>> 'info registers -a' uses about 3ms;
>> 'info registers 12' uses about 150us.
>>
>> Cc: Darren Kenny <darren.kenny@oracle.com>
>> Reviewed-by: Markus Armbruster <armbru@redhat.com>
>> Signed-off-by: zhenwei pi <pizhenwei@bytedance.com>
> 
> Reviewed-by: Dr. David Alan Gilbert <dgilbert@redhat.com>
> 
>> ---
>>   hmp-commands-info.hx |  8 +++++---
>>   monitor/misc.c       | 10 ++++++++--
>>   2 files changed, 13 insertions(+), 5 deletions(-)
>>
>> diff --git a/hmp-commands-info.hx b/hmp-commands-info.hx
>> index 188d9ece3b..e012035541 100644
>> --- a/hmp-commands-info.hx
>> +++ b/hmp-commands-info.hx
>> @@ -100,9 +100,11 @@ ERST
>>   
>>       {
>>           .name       = "registers",
>> -        .args_type  = "cpustate_all:-a",
>> -        .params     = "[-a]",
>> -        .help       = "show the cpu registers (-a: all - show register info for all cpus)",
>> +        .args_type  = "cpustate_all:-a,vcpu:i?",
>> +        .params     = "[-a|vcpu]",
>> +        .help       = "show the cpu registers (-a: show register info for all cpus;"
>> +                      " vcpu: specific vCPU to query; show the current CPU's registers if"
>> +                      " no argument is specified)",
>>           .cmd        = hmp_info_registers,
>>       },
>>   
>> diff --git a/monitor/misc.c b/monitor/misc.c
>> index 3d2312ba8d..6436a8786b 100644
>> --- a/monitor/misc.c
>> +++ b/monitor/misc.c
>> @@ -307,6 +307,7 @@ int monitor_get_cpu_index(Monitor *mon)
>>   static void hmp_info_registers(Monitor *mon, const QDict *qdict)
>>   {
>>       bool all_cpus = qdict_get_try_bool(qdict, "cpustate_all", false);
>> +    int vcpu = qdict_get_try_int(qdict, "vcpu", -1);
>>       CPUState *cs;
>>   
>>       if (all_cpus) {
>> @@ -315,13 +316,18 @@ static void hmp_info_registers(Monitor *mon, const QDict *qdict)
>>               cpu_dump_state(cs, NULL, CPU_DUMP_FPU);
>>           }
>>       } else {
>> -        cs = mon_get_cpu(mon);
>> +        cs = vcpu >= 0 ? qemu_get_cpu(vcpu) : mon_get_cpu(mon);
>>   
>>           if (!cs) {
>> -            monitor_printf(mon, "No CPU available\n");
>> +            if (vcpu >= 0) {
>> +                monitor_printf(mon, "CPU#%d not available\n", vcpu);
>> +            } else {
>> +                monitor_printf(mon, "No CPU available\n");
>> +            }
>>               return;
>>           }
>>   
>> +        monitor_printf(mon, "\nCPU#%d\n", cs->cpu_index);
>>           cpu_dump_state(cs, NULL, CPU_DUMP_FPU);
>>       }
>>   }
>> -- 
>> 2.20.1
>>

-- 
zhenwei pi


^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: PING: Re: [PATCH v4 1/1] monitor: Support specified vCPU registers
  2022-09-07  3:22     ` PING: " zhenwei pi
@ 2022-09-07 13:36       ` Dr. David Alan Gilbert
  0 siblings, 0 replies; 7+ messages in thread
From: Dr. David Alan Gilbert @ 2022-09-07 13:36 UTC (permalink / raw)
  To: zhenwei pi; +Cc: armbru, qemu-devel, darren.kenny

* zhenwei pi (pizhenwei@bytedance.com) wrote:
> PING!

It's OK, I've got it lined up for a pull I'll do in a few days time.

Dave

> On 8/15/22 20:00, Dr. David Alan Gilbert wrote:
> > * zhenwei pi (pizhenwei@bytedance.com) wrote:
> > > Originally we have to get all the vCPU registers and parse the
> > > specified one. To improve the performance of this usage, allow user
> > > specified vCPU id to query registers.
> > > 
> > > Run a VM with 16 vCPU, use bcc tool to track the latency of
> > > 'hmp_info_registers':
> > > 'info registers -a' uses about 3ms;
> > > 'info registers 12' uses about 150us.
> > > 
> > > Cc: Darren Kenny <darren.kenny@oracle.com>
> > > Reviewed-by: Markus Armbruster <armbru@redhat.com>
> > > Signed-off-by: zhenwei pi <pizhenwei@bytedance.com>
> > 
> > Reviewed-by: Dr. David Alan Gilbert <dgilbert@redhat.com>
> > 
> > > ---
> > >   hmp-commands-info.hx |  8 +++++---
> > >   monitor/misc.c       | 10 ++++++++--
> > >   2 files changed, 13 insertions(+), 5 deletions(-)
> > > 
> > > diff --git a/hmp-commands-info.hx b/hmp-commands-info.hx
> > > index 188d9ece3b..e012035541 100644
> > > --- a/hmp-commands-info.hx
> > > +++ b/hmp-commands-info.hx
> > > @@ -100,9 +100,11 @@ ERST
> > >       {
> > >           .name       = "registers",
> > > -        .args_type  = "cpustate_all:-a",
> > > -        .params     = "[-a]",
> > > -        .help       = "show the cpu registers (-a: all - show register info for all cpus)",
> > > +        .args_type  = "cpustate_all:-a,vcpu:i?",
> > > +        .params     = "[-a|vcpu]",
> > > +        .help       = "show the cpu registers (-a: show register info for all cpus;"
> > > +                      " vcpu: specific vCPU to query; show the current CPU's registers if"
> > > +                      " no argument is specified)",
> > >           .cmd        = hmp_info_registers,
> > >       },
> > > diff --git a/monitor/misc.c b/monitor/misc.c
> > > index 3d2312ba8d..6436a8786b 100644
> > > --- a/monitor/misc.c
> > > +++ b/monitor/misc.c
> > > @@ -307,6 +307,7 @@ int monitor_get_cpu_index(Monitor *mon)
> > >   static void hmp_info_registers(Monitor *mon, const QDict *qdict)
> > >   {
> > >       bool all_cpus = qdict_get_try_bool(qdict, "cpustate_all", false);
> > > +    int vcpu = qdict_get_try_int(qdict, "vcpu", -1);
> > >       CPUState *cs;
> > >       if (all_cpus) {
> > > @@ -315,13 +316,18 @@ static void hmp_info_registers(Monitor *mon, const QDict *qdict)
> > >               cpu_dump_state(cs, NULL, CPU_DUMP_FPU);
> > >           }
> > >       } else {
> > > -        cs = mon_get_cpu(mon);
> > > +        cs = vcpu >= 0 ? qemu_get_cpu(vcpu) : mon_get_cpu(mon);
> > >           if (!cs) {
> > > -            monitor_printf(mon, "No CPU available\n");
> > > +            if (vcpu >= 0) {
> > > +                monitor_printf(mon, "CPU#%d not available\n", vcpu);
> > > +            } else {
> > > +                monitor_printf(mon, "No CPU available\n");
> > > +            }
> > >               return;
> > >           }
> > > +        monitor_printf(mon, "\nCPU#%d\n", cs->cpu_index);
> > >           cpu_dump_state(cs, NULL, CPU_DUMP_FPU);
> > >       }
> > >   }
> > > -- 
> > > 2.20.1
> > > 
> 
> -- 
> zhenwei pi
> 
-- 
Dr. David Alan Gilbert / dgilbert@redhat.com / Manchester, UK



^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH v4 0/1] monitor: Support specified vCPU registers
  2022-08-02  7:37 [PATCH v4 0/1] monitor: Support specified vCPU registers zhenwei pi
  2022-08-02  7:37 ` [PATCH v4 1/1] " zhenwei pi
@ 2022-09-15 11:00 ` Dr. David Alan Gilbert
  1 sibling, 0 replies; 7+ messages in thread
From: Dr. David Alan Gilbert @ 2022-09-15 11:00 UTC (permalink / raw)
  To: zhenwei pi; +Cc: armbru, qemu-devel, darren.kenny

* zhenwei pi (pizhenwei@bytedance.com) wrote:
> v3 -> v4: 
> - Tweake a few document and output '\n' prefix.
> 
> v2 -> v3: 
> - Add more document in help info.
> - Use 'qemu_get_cpu()' to simplify code.
> 
> v1 -> v2: 
> - Typo fix in commit message.
> - Suggested by Darren, use '[-a|vcpu]' instead of '[-a] [vcpu]',
>   becase only one of these may be specified at a time.
> 
> v1:
> - Support specified vCPU registers for monitor command.
> 
> Zhenwei Pi (1):
>   monitor: Support specified vCPU registers
> 
>  hmp-commands-info.hx |  8 +++++---
>  monitor/misc.c       | 10 ++++++++--
>  2 files changed, 13 insertions(+), 5 deletions(-)

Queued.  Sorry for the delay.

Dave

> 
> -- 
> 2.20.1
> 
> 
-- 
Dr. David Alan Gilbert / dgilbert@redhat.com / Manchester, UK



^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2022-09-15 11:04 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-08-02  7:37 [PATCH v4 0/1] monitor: Support specified vCPU registers zhenwei pi
2022-08-02  7:37 ` [PATCH v4 1/1] " zhenwei pi
2022-08-02 10:55   ` Darren Kenny
2022-08-15 12:00   ` Dr. David Alan Gilbert
2022-09-07  3:22     ` PING: " zhenwei pi
2022-09-07 13:36       ` Dr. David Alan Gilbert
2022-09-15 11:00 ` [PATCH v4 0/1] " Dr. David Alan Gilbert

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.