From: Paolo Bonzini <pbonzini@redhat.com>
To: Takuya Yoshikawa <yoshikawa_takuya_b1@lab.ntt.co.jp>
Cc: kvm@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH 4/5] KVM: x86: MMU: Remove mapping_level_dirty_bitmap()
Date: Thu, 15 Oct 2015 17:35:27 +0200 [thread overview]
Message-ID: <561FC7BF.8040902@redhat.com> (raw)
In-Reply-To: <20151015194320.b184ec92049ef7e597f57851@lab.ntt.co.jp>
On 15/10/2015 12:43, Takuya Yoshikawa wrote:
> +static inline bool memslot_invalid(struct kvm_memory_slot *slot)
Can you make this function memslot_valid_for_gpte(struct kvm_memory_slot
*slot, bool no_dirty_log), and have it return
slot && !(slot->flags & KVM_MEMSLOT_INVALID) &&
(!no_dirty_log || !slot->dirty_bitmap)
? If gfn_to_memslot_dirty_bitmap and mapping_level call the same
function, it helps highlighting the similarity between them. Your
optimization loses that similarity in the name, but I think we can bring
it back somehow.
Otherwise, the patches are great. Thanks!
Paolo
> +{
> + if (!slot || slot->flags & KVM_MEMSLOT_INVALID)
> + return true;
> +
> + return false;
> +}
> +
> static struct kvm_memory_slot *
> gfn_to_memslot_dirty_bitmap(struct kvm_vcpu *vcpu, gfn_t gfn,
> bool no_dirty_log)
> @@ -858,25 +866,22 @@ gfn_to_memslot_dirty_bitmap(struct kvm_vcpu *vcpu, gfn_t gfn,
> struct kvm_memory_slot *slot;
>
> slot = kvm_vcpu_gfn_to_memslot(vcpu, gfn);
> - if (!slot || slot->flags & KVM_MEMSLOT_INVALID ||
> - (no_dirty_log && slot->dirty_bitmap))
> + if (memslot_invalid(slot) || (no_dirty_log && slot->dirty_bitmap))
> slot = NULL;
>
> return slot;
> }
>
> -static bool mapping_level_dirty_bitmap(struct kvm_vcpu *vcpu, gfn_t large_gfn)
> -{
> - return !gfn_to_memslot_dirty_bitmap(vcpu, large_gfn, true);
> -}
> -
> static int mapping_level(struct kvm_vcpu *vcpu, gfn_t large_gfn,
> bool *force_pt_level)
> {
> int host_level, level, max_level;
> + struct kvm_memory_slot *slot;
> +
> + slot = kvm_vcpu_gfn_to_memslot(vcpu, large_gfn);
>
> if (likely(!*force_pt_level))
> - *force_pt_level = mapping_level_dirty_bitmap(vcpu, large_gfn);
> + *force_pt_level = memslot_invalid(slot) || slot->dirty_bitmap;
next prev parent reply other threads:[~2015-10-15 15:35 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-10-15 10:39 [PATCH 0/5] KVM: x86: MMU: Eliminate extra memory slot searches in page fault handlers Takuya Yoshikawa
2015-10-15 10:40 ` [PATCH 1/5] KVM: x86: MMU: Make force_pt_level bool Takuya Yoshikawa
2015-10-15 10:41 ` [PATCH 2/5] KVM: x86: MMU: Simplify force_pt_level calculation code in FNAME(page_fault)() Takuya Yoshikawa
2015-10-15 10:42 ` [PATCH 3/5] KVM: x86: MMU: Merge mapping_level_dirty_bitmap() into mapping_level() Takuya Yoshikawa
2015-10-15 10:43 ` [PATCH 4/5] KVM: x86: MMU: Remove mapping_level_dirty_bitmap() Takuya Yoshikawa
2015-10-15 15:35 ` Paolo Bonzini [this message]
2015-10-15 10:44 ` [PATCH 5/5] KVM: x86: MMU: Eliminate an extra memory slot search in mapping_level() Takuya Yoshikawa
-- strict thread matches above, loose matches on Subject: below --
2015-10-16 8:03 [PATCH 0/5 v2] KVM: x86: MMU: Eliminate extra memory slot searches in page fault handlers Takuya Yoshikawa
2015-10-16 8:07 ` [PATCH 4/5] KVM: x86: MMU: Remove mapping_level_dirty_bitmap() Takuya Yoshikawa
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=561FC7BF.8040902@redhat.com \
--to=pbonzini@redhat.com \
--cc=kvm@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=yoshikawa_takuya_b1@lab.ntt.co.jp \
/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).