From patchwork Tue Apr 16 06:32:52 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Xiao Guangrong X-Patchwork-Id: 2447891 Return-Path: X-Original-To: patchwork-kvm@patchwork.kernel.org Delivered-To: patchwork-process-083081@patchwork2.kernel.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by patchwork2.kernel.org (Postfix) with ESMTP id 93B0EDF230 for ; Tue, 16 Apr 2013 06:36:13 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755078Ab3DPGfz (ORCPT ); Tue, 16 Apr 2013 02:35:55 -0400 Received: from e28smtp09.in.ibm.com ([122.248.162.9]:56528 "EHLO e28smtp09.in.ibm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754888Ab3DPGfa (ORCPT ); Tue, 16 Apr 2013 02:35:30 -0400 Received: from /spool/local by e28smtp09.in.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Tue, 16 Apr 2013 12:02:21 +0530 Received: from d28dlp02.in.ibm.com (9.184.220.127) by e28smtp09.in.ibm.com (192.168.1.139) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; Tue, 16 Apr 2013 12:02:19 +0530 Received: from d28relay03.in.ibm.com (d28relay03.in.ibm.com [9.184.220.60]) by d28dlp02.in.ibm.com (Postfix) with ESMTP id 5DB96394005B; Tue, 16 Apr 2013 12:05:25 +0530 (IST) Received: from d28av04.in.ibm.com (d28av04.in.ibm.com [9.184.220.66]) by d28relay03.in.ibm.com (8.13.8/8.13.8/NCO v10.0) with ESMTP id r3G6ZI0311272624; Tue, 16 Apr 2013 12:05:19 +0530 Received: from d28av04.in.ibm.com (loopback [127.0.0.1]) by d28av04.in.ibm.com (8.14.4/8.13.1/NCO v10.0 AVout) with ESMTP id r3G6ZO0g024402; Tue, 16 Apr 2013 16:35:24 +1000 Received: from localhost (dhcp-9-111-29-110.cn.ibm.com [9.111.29.110]) by d28av04.in.ibm.com (8.14.4/8.13.1/NCO v10.0 AVin) with ESMTP id r3G6ZNMs024326; Tue, 16 Apr 2013 16:35:23 +1000 From: Xiao Guangrong To: mtosatti@redhat.com Cc: gleb@redhat.com, avi.kivity@gmail.com, linux-kernel@vger.kernel.org, kvm@vger.kernel.org, Xiao Guangrong Subject: [PATCH v3 14/15] KVM: move srcu_read_lock/srcu_read_unlock to arch-specified code Date: Tue, 16 Apr 2013 14:32:52 +0800 Message-Id: <1366093973-2617-15-git-send-email-xiaoguangrong@linux.vnet.ibm.com> X-Mailer: git-send-email 1.7.7.6 In-Reply-To: <1366093973-2617-1-git-send-email-xiaoguangrong@linux.vnet.ibm.com> References: <1366093973-2617-1-git-send-email-xiaoguangrong@linux.vnet.ibm.com> X-TM-AS-MML: No X-Content-Scanned: Fidelis XPS MAILER x-cbid: 13041606-2674-0000-0000-0000089D0B21 Sender: kvm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org Move srcu_read_lock/srcu_read_unlock in kvm_mmu_notifier_release to kvm_arch_flush_shadow_all since we will hold slot-lock instead of srcu Only ARM, POWERPC and x86 are using mmu-notify and kvm_arch_flush_shadow_all on ARM and POWERPC does nothing, so we only need to modify the code on x86 Signed-off-by: Xiao Guangrong --- arch/x86/kvm/x86.c | 4 ++++ virt/kvm/kvm_main.c | 3 --- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/arch/x86/kvm/x86.c b/arch/x86/kvm/x86.c index 6e7c85b..d3dd0d5 100644 --- a/arch/x86/kvm/x86.c +++ b/arch/x86/kvm/x86.c @@ -7056,7 +7056,11 @@ void kvm_arch_commit_memory_region(struct kvm *kvm, void kvm_arch_flush_shadow_all(struct kvm *kvm) { + int idx; + + idx = srcu_read_lock(&kvm->srcu); kvm_mmu_zap_all(kvm); + srcu_read_unlock(&kvm->srcu, idx); } void kvm_arch_flush_shadow_memslot(struct kvm *kvm, diff --git a/virt/kvm/kvm_main.c b/virt/kvm/kvm_main.c index acc9f30..f48eef9 100644 --- a/virt/kvm/kvm_main.c +++ b/virt/kvm/kvm_main.c @@ -418,11 +418,8 @@ static void kvm_mmu_notifier_release(struct mmu_notifier *mn, struct mm_struct *mm) { struct kvm *kvm = mmu_notifier_to_kvm(mn); - int idx; - idx = srcu_read_lock(&kvm->srcu); kvm_arch_flush_shadow_all(kvm); - srcu_read_unlock(&kvm->srcu, idx); } static const struct mmu_notifier_ops kvm_mmu_notifier_ops = {