From patchwork Thu May 6 09:31:40 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Xiao Guangrong X-Patchwork-Id: 97324 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 o46AfFox024690 for ; Thu, 6 May 2010 10:45:36 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1757183Ab0EFJey (ORCPT ); Thu, 6 May 2010 05:34:54 -0400 Received: from cn.fujitsu.com ([222.73.24.84]:54114 "EHLO song.cn.fujitsu.com" rhost-flags-OK-FAIL-OK-OK) by vger.kernel.org with ESMTP id S1756840Ab0EFJex (ORCPT ); Thu, 6 May 2010 05:34:53 -0400 Received: from tang.cn.fujitsu.com (tang.cn.fujitsu.com [10.167.250.3]) by song.cn.fujitsu.com (Postfix) with ESMTP id 41B3C170121; Thu, 6 May 2010 17:34:49 +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 o469Wvpi032656; Thu, 6 May 2010 17:32:57 +0800 Received: from [10.167.141.99] (unknown [10.167.141.99]) by fnst.cn.fujitsu.com (Postfix) with ESMTPA id F10E7DC2FF; Thu, 6 May 2010 17:38:06 +0800 (CST) Message-ID: <4BE28C7C.3060806@cn.fujitsu.com> Date: Thu, 06 May 2010 17:31:40 +0800 From: Xiao Guangrong User-Agent: Thunderbird 2.0.0.24 (Windows/20100228) MIME-Version: 1.0 To: Avi Kivity CC: Marcelo Tosatti , KVM list , LKML Subject: [PATCH v4 8/9] KVM MMU: no need atomic operation for 'invlpg_counter' References: <4BE2818A.5000301@cn.fujitsu.com> In-Reply-To: <4BE2818A.5000301@cn.fujitsu.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]); Thu, 06 May 2010 10:45:37 +0000 (UTC) diff --git a/arch/x86/include/asm/kvm_host.h b/arch/x86/include/asm/kvm_host.h index 86a8550..f4e8973 100644 --- a/arch/x86/include/asm/kvm_host.h +++ b/arch/x86/include/asm/kvm_host.h @@ -387,7 +387,7 @@ struct kvm_arch { unsigned int n_free_mmu_pages; unsigned int n_requested_mmu_pages; unsigned int n_alloc_mmu_pages; - atomic_t invlpg_counter; + unsigned int invlpg_counter; struct hlist_head mmu_page_hash[KVM_NUM_MMU_PAGES]; /* * Hash table of struct kvm_mmu_page. diff --git a/arch/x86/kvm/paging_tmpl.h b/arch/x86/kvm/paging_tmpl.h index 93ee2d9..ceaac55 100644 --- a/arch/x86/kvm/paging_tmpl.h +++ b/arch/x86/kvm/paging_tmpl.h @@ -466,7 +466,8 @@ static void FNAME(invlpg)(struct kvm_vcpu *vcpu, gva_t gva) struct kvm_shadow_walk_iterator iterator; gfn_t gfn = -1; u64 *sptep = NULL, gentry; - int invlpg_counter, level, offset = 0, need_flush = 0; + unsigned int invlpg_counter; + int level, offset = 0, need_flush = 0; spin_lock(&vcpu->kvm->mmu_lock); @@ -502,7 +503,7 @@ static void FNAME(invlpg)(struct kvm_vcpu *vcpu, gva_t gva) if (need_flush) kvm_flush_remote_tlbs(vcpu->kvm); - invlpg_counter = atomic_add_return(1, &vcpu->kvm->arch.invlpg_counter); + invlpg_counter = ++vcpu->kvm->arch.invlpg_counter; spin_unlock(&vcpu->kvm->mmu_lock); if (gfn == -1) @@ -522,7 +523,7 @@ static void FNAME(invlpg)(struct kvm_vcpu *vcpu, gva_t gva) kvm_mmu_free_page(vcpu->kvm, sp); goto unlock_exit; } - if (atomic_read(&vcpu->kvm->arch.invlpg_counter) == invlpg_counter && + if (vcpu->kvm->arch.invlpg_counter == invlpg_counter && sp->role.level == PT_PAGE_TABLE_LEVEL) { ++vcpu->kvm->stat.mmu_pte_updated; FNAME(update_pte)(vcpu, sp, sptep, &gentry);