From: David Matlack <dmatlack@google.com>
To: Paolo Bonzini <pbonzini@redhat.com>
Cc: kvm@vger.kernel.org, Ben Gardon <bgardon@google.com>,
Joerg Roedel <joro@8bytes.org>, Jim Mattson <jmattson@google.com>,
Wanpeng Li <wanpengli@tencent.com>,
Vitaly Kuznetsov <vkuznets@redhat.com>,
Sean Christopherson <seanjc@google.com>,
Junaid Shahid <junaids@google.com>,
Andrew Jones <drjones@redhat.com>
Subject: Re: [PATCH 3/6] KVM: x86/mmu: Speed up dirty logging in tdp_mmu_map_handle_target_level
Date: Mon, 2 Aug 2021 16:31:34 +0000 [thread overview]
Message-ID: <YQgd5qBbn/1NKGOn@google.com> (raw)
In-Reply-To: <279056b0-38c0-6ee4-c581-e2328c120b2e@redhat.com>
On Mon, Aug 02, 2021 at 04:58:17PM +0200, Paolo Bonzini wrote:
> On 31/07/21 00:37, David Matlack wrote:
> > - if (new_spte == iter->old_spte)
> > + if (new_spte == iter->old_spte) {
> > ret = RET_PF_SPURIOUS;
> > - else if (!tdp_mmu_set_spte_atomic(vcpu->kvm, iter, new_spte))
> > - return RET_PF_RETRY;
> > + } else {
> > + if (!tdp_mmu_set_spte_atomic_no_dirty_log(vcpu->kvm, iter, new_spte))
> > + return RET_PF_RETRY;
> > +
> > + /*
> > + * Mark the gfn dirty here rather that through the vcpu-agnostic
> > + * handle_changed_spte_dirty_log to leverage vcpu->lru_slot_index.
> > + */
> > + if (is_writable_pte(new_spte))
> > + kvm_vcpu_mark_page_dirty(vcpu, iter->gfn);
> > + }
>
> Looking at the remaining callers of tdp_mmu_set_spte_atomic we have:
>
> * tdp_mmu_zap_spte_atomic calls it with REMOVED_SPTE as the new_spte, which
> is never writable
>
> * kvm_tdp_mmu_map calls it for nonleaf SPTEs, which are always writable but
> should not be dirty.
>
>
> So I think you should:
>
> * change those two to tdp_mmu_set_spte_atomic_no_dirty_log
>
> * add a WARN_ON_ONCE(iter->level > PG_LEVEL_4K) to tdp_mmu_set_spte_atomic
>
> * put the kvm_vcpu_mark_page_dirty code directly in tdp_mmu_set_spte_atomic,
> instead of the call to handle_changed_spte_dirty_log
>
> (I can't exclude I'm missing something though).
Makes sense. I'll take a look to confirm and make those changes in v2.
>
> Paolo
>
next prev parent reply other threads:[~2021-08-02 16:31 UTC|newest]
Thread overview: 18+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-07-30 22:37 [PATCH 0/6] Improve gfn-to-memslot performance during page faults David Matlack
2021-07-30 22:37 ` [PATCH 1/6] KVM: Cache the least recently used slot index per vCPU David Matlack
2021-08-02 14:36 ` Paolo Bonzini
2021-08-02 16:27 ` David Matlack
2021-08-02 16:38 ` Sean Christopherson
2021-07-30 22:37 ` [PATCH 2/6] KVM: Avoid VM-wide lru_slot lookup in kvm_vcpu_gfn_to_memslot David Matlack
2021-07-30 22:37 ` [PATCH 3/6] KVM: x86/mmu: Speed up dirty logging in tdp_mmu_map_handle_target_level David Matlack
2021-08-02 14:58 ` Paolo Bonzini
2021-08-02 16:31 ` David Matlack [this message]
2021-07-30 22:37 ` [PATCH 4/6] KVM: x86/mmu: Leverage vcpu->lru_slot_index for rmap_add and rmap_recycle David Matlack
2021-08-02 14:58 ` Paolo Bonzini
2021-07-30 22:37 ` [PATCH 5/6] KVM: x86/mmu: Rename __gfn_to_rmap to gfn_to_rmap David Matlack
2021-07-31 9:41 ` kernel test robot
2021-07-31 9:41 ` kernel test robot
2021-07-31 12:22 ` kernel test robot
2021-07-31 12:22 ` kernel test robot
2021-08-02 14:59 ` Paolo Bonzini
2021-07-30 22:37 ` [PATCH 6/6] KVM: selftests: Support multiple slots in dirty_log_perf_test David Matlack
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=YQgd5qBbn/1NKGOn@google.com \
--to=dmatlack@google.com \
--cc=bgardon@google.com \
--cc=drjones@redhat.com \
--cc=jmattson@google.com \
--cc=joro@8bytes.org \
--cc=junaids@google.com \
--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.