From patchwork Thu May 16 12:17:53 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Xiao Guangrong X-Patchwork-Id: 2577671 Return-Path: X-Original-To: patchwork-kvm@patchwork.kernel.org Delivered-To: patchwork-process-083081@patchwork1.kernel.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by patchwork1.kernel.org (Postfix) with ESMTP id 29D2B3FE37 for ; Thu, 16 May 2013 12:19:15 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753566Ab3EPMS1 (ORCPT ); Thu, 16 May 2013 08:18:27 -0400 Received: from e28smtp03.in.ibm.com ([122.248.162.3]:59074 "EHLO e28smtp03.in.ibm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753435Ab3EPMSP (ORCPT ); Thu, 16 May 2013 08:18:15 -0400 Received: from /spool/local by e28smtp03.in.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Thu, 16 May 2013 17:43:19 +0530 Received: from d28dlp01.in.ibm.com (9.184.220.126) by e28smtp03.in.ibm.com (192.168.1.133) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; Thu, 16 May 2013 17:43:16 +0530 Received: from d28relay03.in.ibm.com (d28relay03.in.ibm.com [9.184.220.60]) by d28dlp01.in.ibm.com (Postfix) with ESMTP id 7925DE004C; Thu, 16 May 2013 17:50:36 +0530 (IST) Received: from d28av03.in.ibm.com (d28av03.in.ibm.com [9.184.220.65]) by d28relay03.in.ibm.com (8.13.8/8.13.8/NCO v10.0) with ESMTP id r4GCI1Ka11731350; Thu, 16 May 2013 17:48:01 +0530 Received: from d28av03.in.ibm.com (loopback [127.0.0.1]) by d28av03.in.ibm.com (8.14.4/8.13.1/NCO v10.0 AVout) with ESMTP id r4GCI83i024668; Thu, 16 May 2013 22:18:08 +1000 Received: from localhost (dhcp-9-111-29-61.cn.ibm.com [9.111.29.61]) by d28av03.in.ibm.com (8.14.4/8.13.1/NCO v10.0 AVin) with ESMTP id r4GCI7DT024638; Thu, 16 May 2013 22:18:07 +1000 From: Xiao Guangrong To: gleb@redhat.com Cc: avi.kivity@gmail.com, mtosatti@redhat.com, pbonzini@redhat.com, linux-kernel@vger.kernel.org, kvm@vger.kernel.org, Xiao Guangrong Subject: [PATCH v5 8/8] KVM: MMU: zap pages in batch Date: Thu, 16 May 2013 20:17:53 +0800 Message-Id: <1368706673-8530-9-git-send-email-xiaoguangrong@linux.vnet.ibm.com> X-Mailer: git-send-email 1.7.7.6 In-Reply-To: <1368706673-8530-1-git-send-email-xiaoguangrong@linux.vnet.ibm.com> References: <1368706673-8530-1-git-send-email-xiaoguangrong@linux.vnet.ibm.com> X-TM-AS-MML: No X-Content-Scanned: Fidelis XPS MAILER x-cbid: 13051612-3864-0000-0000-0000082D9AB3 Sender: kvm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org Zap at lease 10 pages before releasing mmu-lock to reduce the overload caused by requiring lock [ It improves kernel building 0.6% ~ 1% ] Signed-off-by: Xiao Guangrong --- arch/x86/kvm/mmu.c | 11 ++++++++--- 1 files changed, 8 insertions(+), 3 deletions(-) diff --git a/arch/x86/kvm/mmu.c b/arch/x86/kvm/mmu.c index e12f431..9c27fda 100644 --- a/arch/x86/kvm/mmu.c +++ b/arch/x86/kvm/mmu.c @@ -4216,10 +4216,12 @@ restart: spin_unlock(&kvm->mmu_lock); } +#define BATCH_ZAP_PAGES 10 static void zap_invalid_pages(struct kvm *kvm) { struct kvm_mmu_page *sp, *node; LIST_HEAD(invalid_list); + int batch = 0; restart: list_for_each_entry_safe(sp, node, &kvm->arch.active_mmu_pages, link) { @@ -4256,11 +4258,14 @@ restart: * Need not flush tlb since we only zap the sp with invalid * generation number. */ - if (cond_resched_lock(&kvm->mmu_lock)) + if ((batch >= BATCH_ZAP_PAGES) && + cond_resched_lock(&kvm->mmu_lock)) { + batch = 0; goto restart; + } - if (kvm_mmu_prepare_zap_page(kvm, sp, &invalid_list)) - goto restart; + batch += kvm_mmu_prepare_zap_page(kvm, sp, &invalid_list); + goto restart; } /*