diff mbox

[1/2] KVM: MMU: make __kvm_mmu_free_some_pages handle empty list

Message ID 20090728182726.079993317@amt.cnet (mailing list archive)
State New, archived
Headers show

Commit Message

Marcelo Tosatti July 28, 2009, 6:26 p.m. UTC
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>



--
To unsubscribe from this list: send the line "unsubscribe kvm" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Comments

Izik Eidus July 28, 2009, 7:05 p.m. UTC | #1
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
--
To unsubscribe from this list: send the line "unsubscribe kvm" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
diff mbox

Patch

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,