All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v2 1/1] hmp: synchronize cpu state for lapic info
@ 2021-07-01 21:40 Dongli Zhang
  2021-07-22 22:15 ` Dongli Zhang
  0 siblings, 1 reply; 2+ messages in thread
From: Dongli Zhang @ 2021-07-01 21:40 UTC (permalink / raw)
  To: qemu-devel; +Cc: kwolf, brijesh.singh, ehabkost, jejb, joe.jin, dgilbert

While the default "info lapic" always synchronizes cpu state ...

mon_get_cpu()
-> mon_get_cpu_sync(mon, true)
   -> cpu_synchronize_state(cpu)
      -> ioctl KVM_GET_LAPIC (taking KVM as example)

... the cpu state is not synchronized when the apic-id is available as
argument.

The cpu state should be synchronized when apic-id is available. Otherwise
the "info lapic <apic-id>" always returns stale data.

Signed-off-by: Dongli Zhang <dongli.zhang@oracle.com>
---
Changed since v1:
  - I sent out wrong patch version in v1

 target/i386/monitor.c | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/target/i386/monitor.c b/target/i386/monitor.c
index 119211f0b0..d833ab5b8e 100644
--- a/target/i386/monitor.c
+++ b/target/i386/monitor.c
@@ -28,6 +28,7 @@
 #include "monitor/hmp-target.h"
 #include "monitor/hmp.h"
 #include "qapi/qmp/qdict.h"
+#include "sysemu/hw_accel.h"
 #include "sysemu/kvm.h"
 #include "sysemu/sev.h"
 #include "qapi/error.h"
@@ -656,7 +657,11 @@ void hmp_info_local_apic(Monitor *mon, const QDict *qdict)
 
     if (qdict_haskey(qdict, "apic-id")) {
         int id = qdict_get_try_int(qdict, "apic-id", 0);
+
         cs = cpu_by_arch_id(id);
+        if (cs) {
+            cpu_synchronize_state(cs);
+        }
     } else {
         cs = mon_get_cpu(mon);
     }
-- 
2.17.1



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

* Re: [PATCH v2 1/1] hmp: synchronize cpu state for lapic info
  2021-07-01 21:40 [PATCH v2 1/1] hmp: synchronize cpu state for lapic info Dongli Zhang
@ 2021-07-22 22:15 ` Dongli Zhang
  0 siblings, 0 replies; 2+ messages in thread
From: Dongli Zhang @ 2021-07-22 22:15 UTC (permalink / raw)
  To: qemu-devel; +Cc: kwolf, brijesh.singh, ehabkost, jejb, joe.jin, dgilbert

May I get feedback for this bugfix?

So far the "info lapic <id>" returns stale data and could not accurate reflect
the status in KVM.

Thank you very much!

Dongli Zhang

On 7/1/21 2:40 PM, Dongli Zhang wrote:
> While the default "info lapic" always synchronizes cpu state ...
> 
> mon_get_cpu()
> -> mon_get_cpu_sync(mon, true)
>    -> cpu_synchronize_state(cpu)
>       -> ioctl KVM_GET_LAPIC (taking KVM as example)
> 
> ... the cpu state is not synchronized when the apic-id is available as
> argument.
> 
> The cpu state should be synchronized when apic-id is available. Otherwise
> the "info lapic <apic-id>" always returns stale data.
> 
> Signed-off-by: Dongli Zhang <dongli.zhang@oracle.com>
> ---
> Changed since v1:
>   - I sent out wrong patch version in v1
> 
>  target/i386/monitor.c | 5 +++++
>  1 file changed, 5 insertions(+)
> 
> diff --git a/target/i386/monitor.c b/target/i386/monitor.c
> index 119211f0b0..d833ab5b8e 100644
> --- a/target/i386/monitor.c
> +++ b/target/i386/monitor.c
> @@ -28,6 +28,7 @@
>  #include "monitor/hmp-target.h"
>  #include "monitor/hmp.h"
>  #include "qapi/qmp/qdict.h"
> +#include "sysemu/hw_accel.h"
>  #include "sysemu/kvm.h"
>  #include "sysemu/sev.h"
>  #include "qapi/error.h"
> @@ -656,7 +657,11 @@ void hmp_info_local_apic(Monitor *mon, const QDict *qdict)
>  
>      if (qdict_haskey(qdict, "apic-id")) {
>          int id = qdict_get_try_int(qdict, "apic-id", 0);
> +
>          cs = cpu_by_arch_id(id);
> +        if (cs) {
> +            cpu_synchronize_state(cs);
> +        }
>      } else {
>          cs = mon_get_cpu(mon);
>      }
> 


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

end of thread, other threads:[~2021-07-22 22:17 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-07-01 21:40 [PATCH v2 1/1] hmp: synchronize cpu state for lapic info Dongli Zhang
2021-07-22 22:15 ` Dongli Zhang

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.