All of lore.kernel.org
 help / color / mirror / Atom feed
* [patch 0/2] mmu fixes
@ 2009-07-28 18:26 Marcelo Tosatti
  2009-07-28 18:26 ` [patch 1/2] KVM: MMU: make __kvm_mmu_free_some_pages handle empty list Marcelo Tosatti
                   ` (2 more replies)
  0 siblings, 3 replies; 6+ messages in thread
From: Marcelo Tosatti @ 2009-07-28 18:26 UTC (permalink / raw)
  To: Avi Kivity; +Cc: Izik Eidus, kvm

See patches for details.



^ permalink raw reply	[flat|nested] 6+ messages in thread

* [patch 1/2] KVM: MMU: make __kvm_mmu_free_some_pages handle empty list
  2009-07-28 18:26 [patch 0/2] mmu fixes Marcelo Tosatti
@ 2009-07-28 18:26 ` Marcelo Tosatti
  2009-07-28 19:05   ` Izik Eidus
  2009-07-28 18:26 ` [patch 2/2] KVM: MMU: fix bogus alloc_mmu_pages assignment Marcelo Tosatti
  2009-07-29 10:09 ` [patch 0/2] mmu fixes Avi Kivity
  2 siblings, 1 reply; 6+ messages in thread
From: Marcelo Tosatti @ 2009-07-28 18:26 UTC (permalink / raw)
  To: Avi Kivity; +Cc: Izik Eidus, kvm, Marcelo Tosatti

[-- Attachment #1: izik-fix --]
[-- Type: text/plain, Size: 774 bytes --]

From: Izik Eidus <ieidus@redhat.com>

First check if the list is empty before attempting to look at list
entries.

Signed-off-by: Izik Eidus <ieidus@redhat.com>
Signed-off-by: Marcelo Tosatti <mtosatti@redhat.com>

Index: kvm/arch/x86/kvm/mmu.c
===================================================================
--- kvm.orig/arch/x86/kvm/mmu.c
+++ kvm/arch/x86/kvm/mmu.c
@@ -2625,7 +2625,8 @@ EXPORT_SYMBOL_GPL(kvm_mmu_unprotect_page
 
 void __kvm_mmu_free_some_pages(struct kvm_vcpu *vcpu)
 {
-	while (vcpu->kvm->arch.n_free_mmu_pages < KVM_REFILL_PAGES) {
+	while (vcpu->kvm->arch.n_free_mmu_pages < KVM_REFILL_PAGES &&
+	       !list_empty(&vcpu->kvm->arch.active_mmu_pages)) {
 		struct kvm_mmu_page *sp;
 
 		sp = container_of(vcpu->kvm->arch.active_mmu_pages.prev,



^ permalink raw reply	[flat|nested] 6+ messages in thread

* [patch 2/2] KVM: MMU: fix bogus alloc_mmu_pages assignment
  2009-07-28 18:26 [patch 0/2] mmu fixes Marcelo Tosatti
  2009-07-28 18:26 ` [patch 1/2] KVM: MMU: make __kvm_mmu_free_some_pages handle empty list Marcelo Tosatti
@ 2009-07-28 18:26 ` Marcelo Tosatti
  2009-07-28 19:05   ` Izik Eidus
  2009-07-29 10:09 ` [patch 0/2] mmu fixes Avi Kivity
  2 siblings, 1 reply; 6+ messages in thread
From: Marcelo Tosatti @ 2009-07-28 18:26 UTC (permalink / raw)
  To: Avi Kivity; +Cc: Izik Eidus, kvm, Marcelo Tosatti

[-- Attachment #1: alloc-mmu-pages-patch --]
[-- Type: text/plain, Size: 910 bytes --]

Remove the bogus n_free_mmu_pages assignment from alloc_mmu_pages.

It breaks accounting of mmu pages, since n_free_mmu_pages is modified
but the real number of pages remains the same.

Signed-off-by: Marcelo Tosatti <mtosatti@redhat.com>

Index: kvm/arch/x86/kvm/mmu.c
===================================================================
--- kvm.orig/arch/x86/kvm/mmu.c
+++ kvm/arch/x86/kvm/mmu.c
@@ -2706,14 +2706,6 @@ static int alloc_mmu_pages(struct kvm_vc
 
 	ASSERT(vcpu);
 
-	spin_lock(&vcpu->kvm->mmu_lock);
-	if (vcpu->kvm->arch.n_requested_mmu_pages)
-		vcpu->kvm->arch.n_free_mmu_pages =
-					vcpu->kvm->arch.n_requested_mmu_pages;
-	else
-		vcpu->kvm->arch.n_free_mmu_pages =
-					vcpu->kvm->arch.n_alloc_mmu_pages;
-	spin_unlock(&vcpu->kvm->mmu_lock);
 	/*
 	 * When emulating 32-bit mode, cr3 is only 32 bits even on x86_64.
 	 * Therefore we need to allocate shadow page tables in the first



^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [patch 1/2] KVM: MMU: make __kvm_mmu_free_some_pages handle empty list
  2009-07-28 18:26 ` [patch 1/2] KVM: MMU: make __kvm_mmu_free_some_pages handle empty list Marcelo Tosatti
@ 2009-07-28 19:05   ` Izik Eidus
  0 siblings, 0 replies; 6+ messages in thread
From: Izik Eidus @ 2009-07-28 19:05 UTC (permalink / raw)
  To: Marcelo Tosatti; +Cc: Avi Kivity, kvm

Marcelo Tosatti wrote:
> From: Izik Eidus <ieidus@redhat.com>
>
> First check if the list is empty before attempting to look at list
> entries.
>
> Signed-off-by: Izik Eidus <ieidus@redhat.com>
> Signed-off-by: Marcelo Tosatti <mtosatti@redhat.com>
>
> Index: kvm/arch/x86/kvm/mmu.c
> ===================================================================
> --- kvm.orig/arch/x86/kvm/mmu.c
> +++ kvm/arch/x86/kvm/mmu.c
> @@ -2625,7 +2625,8 @@ EXPORT_SYMBOL_GPL(kvm_mmu_unprotect_page
>  
>  void __kvm_mmu_free_some_pages(struct kvm_vcpu *vcpu)
>  {
> -	while (vcpu->kvm->arch.n_free_mmu_pages < KVM_REFILL_PAGES) {
> +	while (vcpu->kvm->arch.n_free_mmu_pages < KVM_REFILL_PAGES &&
> +	       !list_empty(&vcpu->kvm->arch.active_mmu_pages)) {
>  		struct kvm_mmu_page *sp;
>  
>  		sp = container_of(vcpu->kvm->arch.active_mmu_pages.prev,
>
>
>   
ack

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [patch 2/2] KVM: MMU: fix bogus alloc_mmu_pages assignment
  2009-07-28 18:26 ` [patch 2/2] KVM: MMU: fix bogus alloc_mmu_pages assignment Marcelo Tosatti
@ 2009-07-28 19:05   ` Izik Eidus
  0 siblings, 0 replies; 6+ messages in thread
From: Izik Eidus @ 2009-07-28 19:05 UTC (permalink / raw)
  To: Marcelo Tosatti; +Cc: Avi Kivity, kvm

Marcelo Tosatti wrote:
> Remove the bogus n_free_mmu_pages assignment from alloc_mmu_pages.
>
> It breaks accounting of mmu pages, since n_free_mmu_pages is modified
> but the real number of pages remains the same.
>
> Signed-off-by: Marcelo Tosatti <mtosatti@redhat.com>
>
> Index: kvm/arch/x86/kvm/mmu.c
> ===================================================================
> --- kvm.orig/arch/x86/kvm/mmu.c
> +++ kvm/arch/x86/kvm/mmu.c
> @@ -2706,14 +2706,6 @@ static int alloc_mmu_pages(struct kvm_vc
>  
>  	ASSERT(vcpu);
>  
> -	spin_lock(&vcpu->kvm->mmu_lock);
> -	if (vcpu->kvm->arch.n_requested_mmu_pages)
> -		vcpu->kvm->arch.n_free_mmu_pages =
> -					vcpu->kvm->arch.n_requested_mmu_pages;
> -	else
> -		vcpu->kvm->arch.n_free_mmu_pages =
> -					vcpu->kvm->arch.n_alloc_mmu_pages;
> -	spin_unlock(&vcpu->kvm->mmu_lock);
>  	/*
>  	 * When emulating 32-bit mode, cr3 is only 32 bits even on x86_64.
>  	 * Therefore we need to allocate shadow page tables in the first
>
>
>   
ack

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [patch 0/2] mmu fixes
  2009-07-28 18:26 [patch 0/2] mmu fixes Marcelo Tosatti
  2009-07-28 18:26 ` [patch 1/2] KVM: MMU: make __kvm_mmu_free_some_pages handle empty list Marcelo Tosatti
  2009-07-28 18:26 ` [patch 2/2] KVM: MMU: fix bogus alloc_mmu_pages assignment Marcelo Tosatti
@ 2009-07-29 10:09 ` Avi Kivity
  2 siblings, 0 replies; 6+ messages in thread
From: Avi Kivity @ 2009-07-29 10:09 UTC (permalink / raw)
  To: Marcelo Tosatti; +Cc: Izik Eidus, kvm

On 07/28/2009 09:26 PM, Marcelo Tosatti wrote:
> See patches for details.
>
>    

Applied, thanks.

Please add the failure scenario to the changelog in the future.

-- 
error compiling committee.c: too many arguments to function


^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2009-07-29 10:05 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2009-07-28 18:26 [patch 0/2] mmu fixes Marcelo Tosatti
2009-07-28 18:26 ` [patch 1/2] KVM: MMU: make __kvm_mmu_free_some_pages handle empty list Marcelo Tosatti
2009-07-28 19:05   ` Izik Eidus
2009-07-28 18:26 ` [patch 2/2] KVM: MMU: fix bogus alloc_mmu_pages assignment Marcelo Tosatti
2009-07-28 19:05   ` Izik Eidus
2009-07-29 10:09 ` [patch 0/2] mmu fixes Avi Kivity

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.