public inbox for kvm@vger.kernel.org
 help / color / mirror / Atom feed
From: Sean Christopherson <seanjc@google.com>
To: Yan Zhao <yan.y.zhao@intel.com>
Cc: kvm@vger.kernel.org, linux-kernel@vger.kernel.org,
	pbonzini@redhat.com, intel-gfx@lists.freedesktop.org,
	intel-gvt-dev@lists.freedesktop.org, zhenyuw@linux.intel.com
Subject: Re: [PATCH v2 1/3] KVM: x86: add a new page track hook track_remove_slot
Date: Sat, 12 Nov 2022 00:43:07 +0000	[thread overview]
Message-ID: <Y27sG3AqVX8yLUgR@google.com> (raw)
In-Reply-To: <Y27ivXea5SjR5lat@yzhao56-desk.sh.intel.com>

On Sat, Nov 12, 2022, Yan Zhao wrote:
> And I'm also not sure if a slots_arch_lock is required for
> kvm_slot_page_track_add_page() and kvm_slot_page_track_remove_page().

It's not required.  slots_arch_lock protects interaction between memslot updates
mmu_first_shadow_root_alloc().  When CONFIG_KVM_EXTERNAL_WRITE_TRACKING=y, then
the mmu_first_shadow_root_alloc() doesn't touch the memslots because everything
is pre-allocated:

bool kvm_page_track_write_tracking_enabled(struct kvm *kvm)
{
	return IS_ENABLED(CONFIG_KVM_EXTERNAL_WRITE_TRACKING) ||
	       !tdp_enabled || kvm_shadow_root_allocated(kvm);
}

int kvm_page_track_create_memslot(struct kvm *kvm,
				  struct kvm_memory_slot *slot,
				  unsigned long npages)
{
	if (!kvm_page_track_write_tracking_enabled(kvm)) <== always true
		return 0;

	return __kvm_page_track_write_tracking_alloc(slot, npages);
}

Though now that you point it out, it's tempting to #ifdef out some of those hooks
so that's basically impossible for mmu_first_shadow_root_alloc() to cause problems.
Not sure the extra #ideffery would be worth while though.

slots_arch_lock also protects shadow_root_allocated, but that's a KVM-internal
detail that isn't relevant to the page-tracking machinery when
CONFIG_KVM_EXTERNAL_WRITE_TRACKING=y.

  reply	other threads:[~2022-11-12  0:43 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-11-11 10:32 [PATCH v2 0/3] add track_remove_slot and remove track_flush_slot Yan Zhao
2022-11-11 10:33 ` [PATCH v2 1/3] KVM: x86: add a new page track hook track_remove_slot Yan Zhao
2022-11-11 18:19   ` Sean Christopherson
2022-11-12  0:03     ` Yan Zhao
2022-11-12  0:43       ` Sean Christopherson [this message]
2022-11-14  1:05         ` Yan Zhao
2022-11-14 16:32           ` Sean Christopherson
2022-11-14 22:42             ` Yan Zhao
2022-11-14 23:24               ` Sean Christopherson
2022-11-14 23:22                 ` Yan Zhao
2022-11-15  0:55                   ` Sean Christopherson
2022-11-15  1:08                     ` Yan Zhao
2022-11-11 10:34 ` [PATCH v2 2/3] drm/i915/gvt: switch from track_flush_slot to track_remove_slot Yan Zhao
2022-11-11 17:07   ` Sean Christopherson
2022-11-12  0:05     ` Yan Zhao
2022-11-11 10:35 ` [PATCH v2 3/3] KVM: x86: Remove the unused page track hook track_flush_slot Yan Zhao

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=Y27sG3AqVX8yLUgR@google.com \
    --to=seanjc@google.com \
    --cc=intel-gfx@lists.freedesktop.org \
    --cc=intel-gvt-dev@lists.freedesktop.org \
    --cc=kvm@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=pbonzini@redhat.com \
    --cc=yan.y.zhao@intel.com \
    --cc=zhenyuw@linux.intel.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