mbox series

[0/4] Export APICv-related state via binary stats interface

Message ID 20240429155738.990025-1-alejandro.j.jimenez@oracle.com (mailing list archive)
Headers show
Series Export APICv-related state via binary stats interface | expand

Message

Alejandro Jimenez April 29, 2024, 3:57 p.m. UTC
After discussion in the RFC thread[0], the following items were identified as
desirable to expose via the stats interface:

- APICv status: (apicv_enabled, boolean, per-vCPU)

- Guest using SynIC's AutoEOI: (synic_auto_eoi_used, boolean, per-VM)

- KVM PIT in reinject mode inhibits AVIC: (pit_reinject_mode, boolean, per-VM)

- APICv unaccelerated injections causing a vmexit (i.e. AVIC_INCOMPLETE_IPI,
  AVIC_UNACCELERATED_ACCESS, APIC_WRITE): (apicv_unaccelerated_inj, counter,
  per-vCPU)

Example retrieving the newly introduced stats for guest running on AMD Genoa
host, with AVIC enabled:

(QEMU) query-stats target=vcpu vcpus=['/machine/unattached/device[0]'] providers=[{'provider':'kvm','names':['apicv_unaccelerated_inj','apicv_active']}]
{
    "return": [
        {
            "provider": "kvm",
            "qom-path": "/machine/unattached/device[0]",
            "stats": [
                {
                    "name": "apicv_unaccelerated_inj",
                    "value": 2561
                },
                {
                    "name": "apicv_active",
                    "value": true
                }
            ]
        }
    ]
}
(QEMU) query-stats target=vm providers=[{'provider':'kvm','names':['pit_reinject_mode','synic_auto_eoi_used']}]
{
    "return": [
        {
            "provider": "kvm",
            "stats": [
                {
                    "name": "pit_reinject_mode",
                    "value": false
                },
                {
                    "name": "synic_auto_eoi_used",
                    "value": false
                }
            ]
        }
    ]
}

Changes were also sanity tested on Intel Sapphire Rapids platform, with/without
IPI virtualization.

Regards,
Alejandro

[0] https://lore.kernel.org/all/20240215160136.1256084-1-alejandro.j.jimenez@oracle.com/

Alejandro Jimenez (4):
  KVM: x86: Expose per-vCPU APICv status
  KVM: x86: Add a VM stat exposing when SynIC AutoEOI is in use
  KVM: x86: Add a VM stat exposing when KVM PIT is set to reinject mode
  KVM: x86: Add vCPU stat for APICv interrupt injections causing #VMEXIT

 arch/x86/include/asm/kvm_host.h | 4 ++++
 arch/x86/kvm/hyperv.c           | 2 ++
 arch/x86/kvm/i8254.c            | 2 ++
 arch/x86/kvm/lapic.c            | 1 +
 arch/x86/kvm/svm/avic.c         | 7 +++++++
 arch/x86/kvm/vmx/vmx.c          | 2 ++
 arch/x86/kvm/x86.c              | 7 ++++++-
 7 files changed, 24 insertions(+), 1 deletion(-)


base-commit: 7b076c6a308ec5bce9fc96e2935443ed228b9148

Comments

Alejandro Jimenez May 23, 2024, 6:49 p.m. UTC | #1
On 4/29/24 11:57, Alejandro Jimenez wrote:
> After discussion in the RFC thread[0], the following items were identified as
> desirable to expose via the stats interface:
> 
> - APICv status: (apicv_enabled, boolean, per-vCPU)
> 
> - Guest using SynIC's AutoEOI: (synic_auto_eoi_used, boolean, per-VM)
> 
> - KVM PIT in reinject mode inhibits AVIC: (pit_reinject_mode, boolean, per-VM)
> 
> - APICv unaccelerated injections causing a vmexit (i.e. AVIC_INCOMPLETE_IPI,
>    AVIC_UNACCELERATED_ACCESS, APIC_WRITE): (apicv_unaccelerated_inj, counter,
>    per-vCPU)
> 
> Example retrieving the newly introduced stats for guest running on AMD Genoa
> host, with AVIC enabled:
> 
> (QEMU) query-stats target=vcpu vcpus=['/machine/unattached/device[0]'] providers=[{'provider':'kvm','names':['apicv_unaccelerated_inj','apicv_active']}]
> {
>      "return": [
>          {
>              "provider": "kvm",
>              "qom-path": "/machine/unattached/device[0]",
>              "stats": [
>                  {
>                      "name": "apicv_unaccelerated_inj",
>                      "value": 2561
>                  },
>                  {
>                      "name": "apicv_active",
>                      "value": true
>                  }
>              ]
>          }
>      ]
> }
> (QEMU) query-stats target=vm providers=[{'provider':'kvm','names':['pit_reinject_mode','synic_auto_eoi_used']}]
> {
>      "return": [
>          {
>              "provider": "kvm",
>              "stats": [
>                  {
>                      "name": "pit_reinject_mode",
>                      "value": false
>                  },
>                  {
>                      "name": "synic_auto_eoi_used",
>                      "value": false
>                  }
>              ]
>          }
>      ]
> }
> 
> Changes were also sanity tested on Intel Sapphire Rapids platform, with/without
> IPI virtualization.

ping...

This series implements the suggestions from earlier RFC discussion [0]. Additional comments/reviews are appreciated.

Thank you,
Alejandro

> 
> [0] https://lore.kernel.org/all/20240215160136.1256084-1-alejandro.j.jimenez@oracle.com/
> 
> Alejandro Jimenez (4):
>    KVM: x86: Expose per-vCPU APICv status
>    KVM: x86: Add a VM stat exposing when SynIC AutoEOI is in use
>    KVM: x86: Add a VM stat exposing when KVM PIT is set to reinject mode
>    KVM: x86: Add vCPU stat for APICv interrupt injections causing #VMEXIT
> 
>   arch/x86/include/asm/kvm_host.h | 4 ++++
>   arch/x86/kvm/hyperv.c           | 2 ++
>   arch/x86/kvm/i8254.c            | 2 ++
>   arch/x86/kvm/lapic.c            | 1 +
>   arch/x86/kvm/svm/avic.c         | 7 +++++++
>   arch/x86/kvm/vmx/vmx.c          | 2 ++
>   arch/x86/kvm/x86.c              | 7 ++++++-
>   7 files changed, 24 insertions(+), 1 deletion(-)
> 
> 
> base-commit: 7b076c6a308ec5bce9fc96e2935443ed228b9148
Vasant Hegde May 31, 2024, 9:19 a.m. UTC | #2
Hi,



On 4/29/2024 9:27 PM, Alejandro Jimenez wrote:
> After discussion in the RFC thread[0], the following items were identified as
> desirable to expose via the stats interface:
> 
> - APICv status: (apicv_enabled, boolean, per-vCPU)
> 
> - Guest using SynIC's AutoEOI: (synic_auto_eoi_used, boolean, per-VM)
> 
> - KVM PIT in reinject mode inhibits AVIC: (pit_reinject_mode, boolean, per-VM)
> 
> - APICv unaccelerated injections causing a vmexit (i.e. AVIC_INCOMPLETE_IPI,
>   AVIC_UNACCELERATED_ACCESS, APIC_WRITE): (apicv_unaccelerated_inj, counter,
>   per-vCPU)
> 
> Example retrieving the newly introduced stats for guest running on AMD Genoa
> host, with AVIC enabled:


I have reviewed generic and AMD driver related code. Also tested this series on
AMD systems and its working fine.

Tested-by: Vasant Hegde <vasant.hegde@amd.com>

-Vasant


> 
> (QEMU) query-stats target=vcpu vcpus=['/machine/unattached/device[0]'] providers=[{'provider':'kvm','names':['apicv_unaccelerated_inj','apicv_active']}]
> {
>     "return": [
>         {
>             "provider": "kvm",
>             "qom-path": "/machine/unattached/device[0]",
>             "stats": [
>                 {
>                     "name": "apicv_unaccelerated_inj",
>                     "value": 2561
>                 },
>                 {
>                     "name": "apicv_active",
>                     "value": true
>                 }
>             ]
>         }
>     ]
> }
> (QEMU) query-stats target=vm providers=[{'provider':'kvm','names':['pit_reinject_mode','synic_auto_eoi_used']}]
> {
>     "return": [
>         {
>             "provider": "kvm",
>             "stats": [
>                 {
>                     "name": "pit_reinject_mode",
>                     "value": false
>                 },
>                 {
>                     "name": "synic_auto_eoi_used",
>                     "value": false
>                 }
>             ]
>         }
>     ]
> }
> 
> Changes were also sanity tested on Intel Sapphire Rapids platform, with/without
> IPI virtualization.
> 
> Regards,
> Alejandro
> 
> [0] https://lore.kernel.org/all/20240215160136.1256084-1-alejandro.j.jimenez@oracle.com/
> 
> Alejandro Jimenez (4):
>   KVM: x86: Expose per-vCPU APICv status
>   KVM: x86: Add a VM stat exposing when SynIC AutoEOI is in use
>   KVM: x86: Add a VM stat exposing when KVM PIT is set to reinject mode
>   KVM: x86: Add vCPU stat for APICv interrupt injections causing #VMEXIT
> 
>  arch/x86/include/asm/kvm_host.h | 4 ++++
>  arch/x86/kvm/hyperv.c           | 2 ++
>  arch/x86/kvm/i8254.c            | 2 ++
>  arch/x86/kvm/lapic.c            | 1 +
>  arch/x86/kvm/svm/avic.c         | 7 +++++++
>  arch/x86/kvm/vmx/vmx.c          | 2 ++
>  arch/x86/kvm/x86.c              | 7 ++++++-
>  7 files changed, 24 insertions(+), 1 deletion(-)
> 
> 
> base-commit: 7b076c6a308ec5bce9fc96e2935443ed228b9148