From patchwork Sat Apr 17 09:02:07 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lai Jiangshan X-Patchwork-Id: 93292 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 o3H92PkE002688 for ; Sat, 17 Apr 2010 09:02:25 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755233Ab0DQJCE (ORCPT ); Sat, 17 Apr 2010 05:02:04 -0400 Received: from cn.fujitsu.com ([222.73.24.84]:55363 "EHLO song.cn.fujitsu.com" rhost-flags-OK-FAIL-OK-OK) by vger.kernel.org with ESMTP id S1755142Ab0DQJCB (ORCPT ); Sat, 17 Apr 2010 05:02:01 -0400 Received: from tang.cn.fujitsu.com (tang.cn.fujitsu.com [10.167.250.3]) by song.cn.fujitsu.com (Postfix) with ESMTP id 8AEED17003F; Sat, 17 Apr 2010 17:02:00 +0800 (CST) Received: from fnst.cn.fujitsu.com (tang.cn.fujitsu.com [127.0.0.1]) by tang.cn.fujitsu.com (8.14.3/8.13.1) with ESMTP id o3H90MmF004876; Sat, 17 Apr 2010 17:00:23 +0800 Received: from [10.167.141.204] (unknown [10.167.141.204]) by fnst.cn.fujitsu.com (Postfix) with ESMTPA id 62305DC2A3; Sat, 17 Apr 2010 17:04:54 +0800 (CST) Message-ID: <4BC9790F.1070403@cn.fujitsu.com> Date: Sat, 17 Apr 2010 17:02:07 +0800 From: Lai Jiangshan User-Agent: Thunderbird 2.0.0.6 (Windows/20070728) MIME-Version: 1.0 To: Avi Kivity , Marcelo Tosatti , LKML , kvm@vger.kernel.org Subject: [PATCH] kvm: don not fail when cache is sufficient 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]); Sat, 17 Apr 2010 09:02:25 +0000 (UTC) diff --git a/arch/x86/kvm/mmu.c b/arch/x86/kvm/mmu.c index c8c074c..90f666e 100644 --- a/arch/x86/kvm/mmu.c +++ b/arch/x86/kvm/mmu.c @@ -304,7 +304,7 @@ static int mmu_topup_memory_cache(struct kvm_mmu_memory_cache *cache, while (cache->nobjs < ARRAY_SIZE(cache->objects)) { obj = kmem_cache_zalloc(base_cache, GFP_KERNEL); if (!obj) - return -ENOMEM; + return cache->nobjs >= min ? 0 : -ENOMEM; cache->objects[cache->nobjs++] = obj; } return 0; @@ -326,7 +326,7 @@ static int mmu_topup_memory_cache_page(struct kvm_mmu_memory_cache *cache, while (cache->nobjs < ARRAY_SIZE(cache->objects)) { page = alloc_page(GFP_KERNEL); if (!page) - return -ENOMEM; + return cache->nobjs >= min ? 0 : -ENOMEM; set_page_private(page, 0); cache->objects[cache->nobjs++] = page_address(page); }