Takuya Yoshikawa <takuya.yoshikawa@xxxxxxxxx> wrote: > @@ -2010,17 +2032,11 @@ static void kvm_mmu_commit_zap_page(struct kvm *kvm, > void kvm_mmu_change_mmu_pages(struct kvm *kvm, unsigned int goal_nr_mmu_pages) > { > LIST_HEAD(invalid_list); > - /* > - * If we set the number of mmu pages to be smaller be than the > - * number of actived pages , we must to free some mmu pages before we > - * change the value > - */ > + int nr_to_zap = kvm->arch.n_used_mmu_pages > goal_nr_mmu_pages; Sorry, should have been: int nr_to_zap = kvm->arch.n_used_mmu_pages - goal_nr_mmu_pages; I will fix this after getting some comments. Takuya > > - if (kvm->arch.n_used_mmu_pages > goal_nr_mmu_pages) { > - while (kvm->arch.n_used_mmu_pages > goal_nr_mmu_pages && > - !list_empty(&kvm->arch.active_mmu_pages)) { > - pre_zap_one_sp(kvm, &invalid_list); > - } > + if (nr_to_zap > 0) { > + /* free some shadow pages to make the number fit the goal */ > + pre_zap_some_sp(kvm, &invalid_list, nr_to_zap); > kvm_mmu_commit_zap_page(kvm, &invalid_list); > goal_nr_mmu_pages = kvm->arch.n_used_mmu_pages; > } > -- > 1.7.5.4 > -- Takuya Yoshikawa <yoshikawa.takuya@xxxxxxxxxxxxx> -- To unsubscribe from this list: send the line "unsubscribe kvm" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html