[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <ZBQaFRdRawenuEan@yzhao56-desk.sh.intel.com>
Date: Fri, 17 Mar 2023 15:43:17 +0800
From: Yan Zhao <yan.y.zhao@...el.com>
To: Sean Christopherson <seanjc@...gle.com>
CC: Paolo Bonzini <pbonzini@...hat.com>,
Zhenyu Wang <zhenyuw@...ux.intel.com>,
Zhi Wang <zhi.a.wang@...el.com>, <kvm@...r.kernel.org>,
<intel-gvt-dev@...ts.freedesktop.org>,
<intel-gfx@...ts.freedesktop.org>, <linux-kernel@...r.kernel.org>,
Ben Gardon <bgardon@...gle.com>
Subject: Re: [PATCH v2 16/27] KVM: x86: Add a new page-track hook to handle
memslot deletion
On Fri, Mar 10, 2023 at 04:22:47PM -0800, Sean Christopherson wrote:
> From: Yan Zhao <yan.y.zhao@...el.com>
>
> Add a new page-track hook, track_remove_region(), that is called when a
> memslot DELETE operation is about to be committed. The "remove" hook
> will be used by KVMGT and will effectively replace the existing
> track_flush_slot() altogether now that KVM itself doesn't rely on the
> "flush" hook either.
>
> The "flush" hook is flawed as it's invoked before the memslot operation
> is guaranteed to succeed, i.e. KVM might ultimately keep the existing
> memslot without notifying external page track users, a.k.a. KVMGT. In
> practice, this can't currently happen on x86, but there are no guarantees
> that won't change in the future, not to mention that "flush" does a very
> poor job of describing what is happening.
>
> Pass in the gfn+nr_pages instead of the slot itself so external users,
> i.e. KVMGT, don't need to exposed to KVM internals (memslots). This will
> help set the stage for additional cleanups to the page-track APIs.
>
> Cc: Zhenyu Wang <zhenyuw@...ux.intel.com>
> Signed-off-by: Yan Zhao <yan.y.zhao@...el.com>
> Co-developed-by: Sean Christopherson <seanjc@...gle.com>
> Signed-off-by: Sean Christopherson <seanjc@...gle.com>
...
> +void kvm_page_track_delete_slot(struct kvm *kvm, struct kvm_memory_slot *slot)
> +{
> + struct kvm_page_track_notifier_head *head;
> + struct kvm_page_track_notifier_node *n;
> + int idx;
> +
> + head = &kvm->arch.track_notifier_head;
> +
> + if (hlist_empty(&head->track_notifier_list))
> + return;
> +
> + idx = srcu_read_lock(&head->track_srcu);
> + hlist_for_each_entry_srcu(n, &head->track_notifier_list, node,
> + srcu_read_lock_held(&head->track_srcu))
Sorry, not sure why the alignment here is not right.
Patchwork just sent me a mail to complain about it.
Would you mind helping fix it in the next version?
Thanks a lot!
> + if (n->track_remove_region)
> + n->track_remove_region(slot->base_gfn, slot->npages, n);
> + srcu_read_unlock(&head->track_srcu, idx);
> +}
> +
Powered by blists - more mailing lists