RFC Export APICv-related state via binary stats interface
Get series with b4
b4 am [email protected]Versions newest first
- v1 RFC Latest3 patches 21 repliesIn review
Patches in v1 No applies recorded yet
| # | Subject and files | Size | Replies | Applied |
|---|---|---|---|---|
| 1/3 | x86: KVM: stats: Add a stat to report status of APICv inhibitionarch/ arch/ | +10 | 4 replies | |
| 2/3 | x86: KVM: stats: Add stat counter for IRQs injected via APICvarch/ arch/ arch/ +1 more | +7 | 3 replies | |
| 3/3 | x86: KVM: stats: Add a stat counter for GALog eventsarch/ arch/ arch/ | +5 | 5 replies |
Reviews trailers per patch
None of the 3 patches has a Reviewed-by or Acked-by of their own; the series has one for all of them.
| Patch | Vasant Hegde |
|---|---|
| Series | R-b |
| 1/3 | |
| 2/3 | |
| 3/3 |
Trailers given in replies are filled; those carried in the patches from earlier versions are outlined with dashes.
Cover letter [RFC 0/3] Export APICv-related state via binary stats interface
The goal of this RFC is to agree on a mechanism for querying the state (and related stats) of APICv/AVIC. I clearly have an AVIC bias when approaching this topic since that is the side that I have mostly looked at, and has the greater number of possible inhibits, but I believe the argument applies for both vendor's technologies.
Currently, a user or monitoring app trying to determine if APICv is actually being used needs implementation-specific knowlegde in order to look for specific types of #VMEXIT (i.e. AVIC_INCOMPLETE_IPI/AVIC_NOACCEL), checking GALog events by watching /proc/interrupts for AMD-Vi*-GA, etc. There are existing tracepoints (e.g. kvm_apicv_accept_irq, kvm_avic_ga_log) that make this task easier, but tracefs is not viable in some scenarios. Adding kvm debugfs entries has similar downsides. Suravee has previously proposed a new IOCTL interface[0] to expose this information, but there has not been any development in that direction. Sean has mentioned a preference for using BPF to extract info from the current tracepoints, which would require reworking existing structs to access some desired data, but as far as I know there isn't any work done on that approach yet.
Recently Joao mentioned another alternative: the binary stats framework that is already supported by kernel[1] and QEMU[2]. This RFC has minimal code changes to expose the relevant info based on the existing data types the framework already supports. If there is consensus on using this approach, I can expand the fd stats subsystem to include other data types (e.g. a bitmap type for exposing the inhibit reasons), as well as adding documentation on KVM explaining which stats are relevant for APICv and how to query them.
A basic example of retrieving the stats via qmp-shell, showing both a VM and per-vCPU case:
# /usr/local/bin/qmp-shell --pretty ./qmp-sock
(QEMU) query-stats target=vm providers=[{'provider':'kvm','names':['apicv_inhibited']}]
{
"return": [
{
"provider": "kvm",
"stats": [
{
"name": "apicv_inhibited",
"value": false
}
]
}
]
}(QEMU) query-stats target=vcpu vcpus=['/machine/unattached/device[0]'] providers=[{'provider':'kvm','names':['apicv_accept_irq','ga_log_event']}]
{
"return": [
{
"provider": "kvm",
"qom-path": "/machine/unattached/device[0]",
"stats": [
{
"name": "ga_log_event",
"value": 98
},
{
"name": "apicv_accept_irq",
"value": 166920
}
]
}
]
}If other alternatives are preferred, please let's use this thread to discuss and I can take a shot at implementing the desired solution.
Regards,
Alejandro
[0] https://lore.kernel.org/qemu-devel/[email protected]/
[1] https://lore.kernel.org/all/[email protected]/
[2] https://lore.kernel.org/qemu-devel/[email protected]/
Alejandro Jimenez (3):
x86: KVM: stats: Add a stat to report status of APICv inhibition
x86: KVM: stats: Add stat counter for IRQs injected via APICv
x86: KVM: stats: Add a stat counter for GALog events
arch/x86/include/asm/kvm_host.h | 3 +++ arch/x86/kvm/svm/avic.c | 4 +++- arch/x86/kvm/svm/svm.c | 3 +++ arch/x86/kvm/vmx/vmx.c | 2 ++ arch/x86/kvm/x86.c | 12 +++++++++++- 5 files changed, 22 insertions(+), 2 deletions(-)
base-commit: 7455665a3521aa7b56245c0a2810f748adc5fdd4
Signature · 1 line
2.39.3