Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1247908

Re: [PATCH 4/5] KVM: x86: MMU: Remove mapping_level_dirty_bitmap()

From Paolo Bonzini <pbonzini@redhat.com>
Newsgroups linux.kernel
Subject Re: [PATCH 4/5] KVM: x86: MMU: Remove mapping_level_dirty_bitmap()
Date 2015-10-15 17:40 +0200
Message-ID <qjSNk-2aP-33@gated-at.bofh.it> (permalink)
References <qjNXj-3zl-5@gated-at.bofh.it> <qjO70-3Ld-13@gated-at.bofh.it>
Organization linux.* mail to news gateway

Show all headers | View raw



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;
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Back to linux.kernel | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

[PATCH 0/5] KVM: x86: MMU: Eliminate extra memory slot searches in  page fault handlers Takuya Yoshikawa <yoshikawa_takuya_b1@lab.ntt.co.jp> - 2015-10-15 12:30 +0200
  [PATCH 2/5] KVM: x86: MMU: Simplify force_pt_level calculation code  in FNAME(page_fault)() Takuya Yoshikawa <yoshikawa_takuya_b1@lab.ntt.co.jp> - 2015-10-15 12:30 +0200
  [PATCH 4/5] KVM: x86: MMU: Remove mapping_level_dirty_bitmap() Takuya Yoshikawa <yoshikawa_takuya_b1@lab.ntt.co.jp> - 2015-10-15 12:40 +0200
    Re: [PATCH 4/5] KVM: x86: MMU: Remove mapping_level_dirty_bitmap() Paolo Bonzini <pbonzini@redhat.com> - 2015-10-15 17:40 +0200
  [PATCH 5/5] KVM: x86: MMU: Eliminate an extra memory slot search in  mapping_level() Takuya Yoshikawa <yoshikawa_takuya_b1@lab.ntt.co.jp> - 2015-10-15 12:40 +0200

csiph-web