From: Alejandro Jimenez <alejandro.j.jimenez@oracle.com>
To: Sean Christopherson <seanjc@google.com>
Cc: kvm@vger.kernel.org, pbonzini@redhat.com,
linux-kernel@vger.kernel.org, joao.m.martins@oracle.com,
boris.ostrovsky@oracle.com, mark.kanda@oracle.com,
suravee.suthikulpanit@amd.com, mlevitsk@redhat.com
Subject: Re: [RFC 1/3] x86: KVM: stats: Add a stat to report status of APICv inhibition
Date: Tue, 16 Apr 2024 15:59:31 -0400 [thread overview]
Message-ID: <812f62bc-6a2f-4226-995b-ed8fd8673a12@oracle.com> (raw)
In-Reply-To: <Zh7BOkOf0i_KZVNO@google.com>
On 4/16/24 14:19, Sean Christopherson wrote:
> On Thu, Feb 15, 2024, Alejandro Jimenez wrote:
>> The inhibition status of APICv can currently be checked using the
>> 'kvm_apicv_inhibit_changed' tracepoint, but this is not accessible if
>> tracefs is not available (e.g. kernel lockdown, non-root user). Export
>> inhibition status as a binary stat that can be monitored from userspace
>> without elevated privileges.
>>
>> Signed-off-by: Alejandro Jimenez <alejandro.j.jimenez@oracle.com>
>> ---
>> arch/x86/include/asm/kvm_host.h | 1 +
>> arch/x86/kvm/x86.c | 10 +++++++++-
>> 2 files changed, 10 insertions(+), 1 deletion(-)
>>
>> diff --git a/arch/x86/include/asm/kvm_host.h b/arch/x86/include/asm/kvm_host.h
>> index ad5319a503f0..9b960a523715 100644
>> --- a/arch/x86/include/asm/kvm_host.h
>> +++ b/arch/x86/include/asm/kvm_host.h
>> @@ -1524,6 +1524,7 @@ struct kvm_vm_stat {
>> u64 nx_lpage_splits;
>> u64 max_mmu_page_hash_collisions;
>> u64 max_mmu_rmap_size;
>> + u64 apicv_inhibited;
I was about to send v2 based on the earlier feedback. I think the changes would
partially address your comments, but there are still wrinkles. In short, I ended
up with:
per-vCPU:
apicv_active (bool) --> tracks vcpu apic.apicv_active
per-VM:
apicv_inhibited (u64) --> exposes kvm apicv_inhibit_reasons
>
> Tracking the negative is odd, i.e. if we add a stat, KVM should probably track
> if APICv is fully enabled, not if it's inhibited>
> This also should be a boolean, not a u64. Precisely enumerating _why_ APICv is
> inhibited is firmly in debug territory, i.e. not in scope for "official" stats.
From that perspective I am perhaps stretching the stats official purpose,
by exposing "too much info", showing _why_ APICv is inhibited (i.e. new
VM-wide apicv_inhibited).
It is true that I am approaching this with a "debugging" bias, but _if_ we do
expose a stat related to inhibition state, I don't think it would be overloading
its meaning to encode relevant inhibit reason information on it.
It would be need to be documented, of course, which is something I can do once
we reach an agreement.
>
> Oh, and this should be a per-vCPU stat, not a VM-wide stat.
>
> As for whether or not we should add a stat for this, I'm leaning towards "yes".
> APICv can have such a profound impact on performance (and functionality) that
> definitively knowing that it's enabled seems justified.
The new per-vCPU apicv_active stat fills this role.
I see you don't agree with a separate stat exposing VM-wide inhibits due to scope
and ABI restrictions mentioned here and in the cover letter reply. I follow the
argument, but it also seems like we'd be handicapping this interface by not
providing inhibit reasons along with it, since they are essential in determining
whether or not AVIC in particular is working (again my debugging bias). I am aware
this is a slight overloading (hopefully not abuse) of the stats purpose, and so
it might not be acceptable.
Alejandro
next prev parent reply other threads:[~2024-04-16 19:59 UTC|newest]
Thread overview: 25+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-02-15 16:01 [RFC 0/3] Export APICv-related state via binary stats interface Alejandro Jimenez
2024-02-15 16:01 ` [RFC 1/3] x86: KVM: stats: Add a stat to report status of APICv inhibition Alejandro Jimenez
2024-04-09 14:54 ` Suthikulpanit, Suravee
2024-04-16 18:19 ` Sean Christopherson
2024-04-16 19:53 ` Paolo Bonzini
2024-04-16 19:59 ` Alejandro Jimenez [this message]
2024-02-15 16:01 ` [RFC 2/3] x86: KVM: stats: Add stat counter for IRQs injected via APICv Alejandro Jimenez
2024-02-15 16:16 ` Dongli Zhang
2024-02-15 18:12 ` Alejandro Jimenez
2024-04-16 18:25 ` Sean Christopherson
2024-02-15 16:01 ` [RFC 3/3] x86: KVM: stats: Add a stat counter for GALog events Alejandro Jimenez
2024-04-09 6:45 ` Chao Gao
2024-04-10 1:31 ` Alejandro Jimenez
2024-04-12 10:45 ` Chao Gao
2024-04-16 18:35 ` Sean Christopherson
2024-04-24 0:50 ` Alejandro Jimenez
2024-04-09 5:09 ` [RFC 0/3] Export APICv-related state via binary stats interface Vasant Hegde
2024-04-10 1:36 ` Alejandro Jimenez
2024-04-16 18:08 ` Sean Christopherson
2024-04-16 19:51 ` Paolo Bonzini
2024-04-16 21:29 ` Alejandro Jimenez
2024-04-16 21:36 ` Paolo Bonzini
2024-04-16 22:34 ` Sean Christopherson
2024-04-17 9:48 ` Paolo Bonzini
2024-04-23 20:43 ` Alejandro Jimenez
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=812f62bc-6a2f-4226-995b-ed8fd8673a12@oracle.com \
--to=alejandro.j.jimenez@oracle.com \
--cc=boris.ostrovsky@oracle.com \
--cc=joao.m.martins@oracle.com \
--cc=kvm@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=mark.kanda@oracle.com \
--cc=mlevitsk@redhat.com \
--cc=pbonzini@redhat.com \
--cc=seanjc@google.com \
--cc=suravee.suthikulpanit@amd.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®