From: David Stevens <stevensd@chromium.org>
To: kvm@vger.kernel.org
Cc: Paolo Bonzini <pbonzini@redhat.com>,
Sean Christopherson <seanjc@google.com>,
Vitaly Kuznetsov <vkuznets@redhat.com>,
Wanpeng Li <wanpengli@tencent.com>,
Jim Mattson <jmattson@google.com>, Joerg Roedel <joro@8bytes.org>,
David Stevens <stevensd@chromium.org>
Subject: [PATCH 0/3] KVM: x86: skip gfn_track allocation when possible
Date: Tue, 21 Sep 2021 17:10:07 +0900 [thread overview]
Message-ID: <20210921081010.457591-1-stevensd@google.com> (raw)
From: David Stevens <stevensd@chromium.org>
Skip allocating gfn_track arrays when tracking of guest write access to
pages is not required. For VMs where the allocation can be avoided, this
saves 2 bytes per 4KB of guest memory.
Write tracking is used to manage shadow page tables in three cases -
when tdp is not supported, when nested virtualization is used, and for
GVT-g. By combining the existing tdp_enable flag and nested module param
with a new config that indicates when something outside of KVM (i.e.
GVT-g) needs write tracking, KVM can determine when initializing a VM
if gfn_track arrays are definitely not necessary.
This straightforward approach has the downside that for VMs where nested
virtualization is enabled but never used, gfn_track arrays are still
allocated. Instead of going so far as to try to initialize things on
demand, key off of whether or not X86_FEATURE_VMX is set in the guest's
cpuid to support per-VM configuration instead of system wide
configuration based on the nested module param.
David Stevens (3):
KVM: x86: add config for non-kvm users of page tracking
KVM: x86/mmu: skip page tracking when possible
KVM: VMX: skip page tracking based on cpuid
arch/x86/include/asm/kvm-x86-ops.h | 1 +
arch/x86/include/asm/kvm_host.h | 4 +-
arch/x86/include/asm/kvm_page_track.h | 7 ++-
arch/x86/kvm/Kconfig | 3 ++
arch/x86/kvm/cpuid.c | 55 +++++++++++++++-----
arch/x86/kvm/mmu/page_track.c | 74 +++++++++++++++++++++++++--
arch/x86/kvm/svm/svm.c | 10 +++-
arch/x86/kvm/vmx/vmx.c | 13 ++++-
arch/x86/kvm/x86.c | 5 +-
drivers/gpu/drm/i915/Kconfig | 1 +
10 files changed, 150 insertions(+), 23 deletions(-)
--
2.33.0.464.g1972c5931b-goog
next reply other threads:[~2021-09-21 8:10 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-09-21 8:10 David Stevens [this message]
2021-09-21 8:10 ` [PATCH 1/3] KVM: x86: add config for non-kvm users of page tracking David Stevens
2021-09-21 8:10 ` [PATCH 2/3] KVM: x86/mmu: skip page tracking when possible David Stevens
2021-09-21 8:10 ` [PATCH 3/3] KVM: VMX: skip page tracking based on cpuid David Stevens
2021-09-21 10:27 ` [PATCH 0/3] KVM: x86: skip gfn_track allocation when possible Paolo Bonzini
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=20210921081010.457591-1-stevensd@google.com \
--to=stevensd@chromium.org \
--cc=jmattson@google.com \
--cc=joro@8bytes.org \
--cc=kvm@vger.kernel.org \
--cc=pbonzini@redhat.com \
--cc=seanjc@google.com \
--cc=vkuznets@redhat.com \
--cc=wanpengli@tencent.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 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.