From patchwork Tue Jun 15 13:55:30 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Hansen X-Patchwork-Id: 106201 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by demeter.kernel.org (8.14.3/8.14.3) with ESMTP id o5FDukLe012639 for ; Tue, 15 Jun 2010 13:56:47 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1757783Ab0FONzs (ORCPT ); Tue, 15 Jun 2010 09:55:48 -0400 Received: from e38.co.us.ibm.com ([32.97.110.159]:42268 "EHLO e38.co.us.ibm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1757779Ab0FONzq (ORCPT ); Tue, 15 Jun 2010 09:55:46 -0400 Received: from d03relay01.boulder.ibm.com (d03relay01.boulder.ibm.com [9.17.195.226]) by e38.co.us.ibm.com (8.14.4/8.13.1) with ESMTP id o5FDn4RX008722; Tue, 15 Jun 2010 07:49:04 -0600 Received: from d03av01.boulder.ibm.com (d03av01.boulder.ibm.com [9.17.195.167]) by d03relay01.boulder.ibm.com (8.13.8/8.13.8/NCO v10.0) with ESMTP id o5FDtWF4177996; Tue, 15 Jun 2010 07:55:32 -0600 Received: from d03av01.boulder.ibm.com (loopback [127.0.0.1]) by d03av01.boulder.ibm.com (8.14.4/8.13.1/NCO v10.0 AVout) with ESMTP id o5FDtVjN030145; Tue, 15 Jun 2010 07:55:31 -0600 Received: from kernel.beaverton.ibm.com (kernel.beaverton.ibm.com [9.47.67.96]) by d03av01.boulder.ibm.com (8.14.4/8.13.1/NCO v10.0 AVin) with ESMTP id o5FDtU7V029544; Tue, 15 Jun 2010 07:55:31 -0600 Received: from localhost.localdomain (localhost [127.0.0.1]) by kernel.beaverton.ibm.com (Postfix) with ESMTP id 6E6DC1E74F9; Tue, 15 Jun 2010 06:55:30 -0700 (PDT) Subject: [RFC][PATCH 9/9] make kvm mmu shrinker more aggressive To: linux-kernel@vger.kernel.org Cc: kvm@vger.kernel.org, Dave Hansen From: Dave Hansen Date: Tue, 15 Jun 2010 06:55:30 -0700 References: <20100615135518.BC244431@kernel.beaverton.ibm.com> In-Reply-To: <20100615135518.BC244431@kernel.beaverton.ibm.com> Message-Id: <20100615135530.4565745D@kernel.beaverton.ibm.com> Sender: kvm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org X-Greylist: IP, sender and recipient auto-whitelisted, not delayed by milter-greylist-4.2.3 (demeter.kernel.org [140.211.167.41]); Tue, 15 Jun 2010 13:56:47 +0000 (UTC) diff -puN arch/x86/kvm/mmu.c~make-shrinker-more-aggressive arch/x86/kvm/mmu.c --- linux-2.6.git/arch/x86/kvm/mmu.c~make-shrinker-more-aggressive 2010-06-14 11:30:44.000000000 -0700 +++ linux-2.6.git-dave/arch/x86/kvm/mmu.c 2010-06-14 11:38:04.000000000 -0700 @@ -2935,8 +2935,10 @@ static int shrink_kvm_mmu(struct kvm *kv idx = srcu_read_lock(&kvm->srcu); spin_lock(&kvm->mmu_lock); - if (kvm->arch.n_used_mmu_pages > 0) - freed_pages = kvm_mmu_remove_some_alloc_mmu_pages(kvm); + while (nr_to_scan > 0 && kvm->arch.n_used_mmu_pages > 0) { + freed_pages += kvm_mmu_remove_some_alloc_mmu_pages(kvm); + nr_to_scan--; + } spin_unlock(&kvm->mmu_lock); srcu_read_unlock(&kvm->srcu, idx); @@ -2952,7 +2954,6 @@ static int shrink_kvm_mmu(struct kvm *kv static int mmu_shrink(int nr_to_scan, gfp_t gfp_mask) { int err; - int freed; struct kvm *kvm; if (nr_to_scan == 0) @@ -2989,11 +2990,11 @@ retry: * operation itself. */ spin_unlock(&kvm_lock); - freed = shrink_kvm_mmu(kvm, nr_to_scan); + nr_to_scan -= shrink_kvm_mmu(kvm, nr_to_scan); kvm_put_kvm(kvm); - if (!freed && nr_to_scan > 0) + if (nr_to_scan > 0) goto retry; out: