kvm.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Dongli Zhang <dongli.zhang@oracle.com>
To: Sean Christopherson <seanjc@google.com>,
	Krish Sadhukhan <krish.sadhukhan@oracle.com>
Cc: kvm@vger.kernel.org, pbonzini@redhat.com, jmattson@google.com
Subject: Re: [PATCH 1/3] KVM: nVMX: Move 'nested_run' counter to enter_guest_mode()
Date: Thu, 13 May 2021 09:02:26 -0700	[thread overview]
Message-ID: <ed4a8dae-be99-0d88-a8dd-510afe7cb956@oracle.com> (raw)
In-Reply-To: <YJweqOAxMITSmKs2@google.com>



On 5/12/21 11:30 AM, Sean Christopherson wrote:
> On Tue, May 11, 2021, Krish Sadhukhan wrote:
>> Move 'nested_run' counter to enter_guest_mode() because,
>>     i) This counter is common to both Intel and AMD and can be incremented
>>        from a common place,
>>     ii) guest mode is a more finer-grained state than the beginning of
>> 	nested_svm_vmrun() and nested_vmx_run().
> 
> Hooking enter_guest_mode() makes the name a misnomer since it will count cases
> such as setting nested state and resuming from SMI, neither of which is a nested
> run in the sense of L1 deliberately choosing to run L2.
> 
> And while bumping nested_run at the very beginning of VMLAUNCH/VMRESUME/VMRUN is
> arguably wrong in that it counts _attempts_ instead of successful VM-Enters, it's

Yes, the original purpose was to track the attempt. That's why the counter is
incremented at the beginning. It helps tell if there is any attempt to run L2 VM
(and also if VM is actively running L2 VM by monitoring the counter).

This helps as sometimes VM owner does not realize software like jailhouse will
involve the L2 VM.

Without the counter, we may need to temporarily use
"/sys/kernel/debug/kvm/mmu_unsync" assuming shadow page table is not used by
host if L2 VM is not involved.

Dongli Zhang

> at least consistent.  Moving this to enter_guest_mode() means it's arbitrarily
> counting VM-Enter that fails late, but not those that fail early.
> 
> If we really want it to mean "successful VM-Enter", then we should wait until
> after VM-Enter actual succeeds, and do it only for actual VM-Enter.
> 

  reply	other threads:[~2021-05-13 16:03 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-05-12  1:47 [PATCH 0/3] KVM: nVMX: Add more statistics to KVM debugfs Krish Sadhukhan
2021-05-12  1:47 ` [PATCH 1/3] KVM: nVMX: Move 'nested_run' counter to enter_guest_mode() Krish Sadhukhan
2021-05-12 18:30   ` Sean Christopherson
2021-05-13 16:02     ` Dongli Zhang [this message]
2021-05-12  1:47 ` [PATCH 2/3] KVM: nVMX: Add a new VCPU statistic to show if VCPU is running nested guest Krish Sadhukhan
2021-05-12 16:01   ` Jim Mattson
2021-05-12 17:56     ` Krish Sadhukhan
2021-05-12 17:59       ` Jim Mattson
2021-05-12 18:19       ` Sean Christopherson
2021-05-12  1:47 ` [PATCH 3/3] KVM: x86: Add a new VM statistic to show number of VCPUs created in a given VM Krish Sadhukhan

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=ed4a8dae-be99-0d88-a8dd-510afe7cb956@oracle.com \
    --to=dongli.zhang@oracle.com \
    --cc=jmattson@google.com \
    --cc=krish.sadhukhan@oracle.com \
    --cc=kvm@vger.kernel.org \
    --cc=pbonzini@redhat.com \
    --cc=seanjc@google.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;
as well as URLs for NNTP newsgroup(s).