From patchwork Wed May 4 13:31:04 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Gleb Natapov X-Patchwork-Id: 753662 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by demeter1.kernel.org (8.14.4/8.14.3) with ESMTP id p44DVkFG019426 for ; Wed, 4 May 2011 13:31:46 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753610Ab1EDNbS (ORCPT ); Wed, 4 May 2011 09:31:18 -0400 Received: from mx1.redhat.com ([209.132.183.28]:25778 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753561Ab1EDNbQ (ORCPT ); Wed, 4 May 2011 09:31:16 -0400 Received: from int-mx01.intmail.prod.int.phx2.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id p44DV5kb014642 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Wed, 4 May 2011 09:31:05 -0400 Received: from dhcp-1-237.tlv.redhat.com (dhcp-1-237.tlv.redhat.com [10.35.1.237]) by int-mx01.intmail.prod.int.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id p44DV412021180; Wed, 4 May 2011 09:31:05 -0400 Received: by dhcp-1-237.tlv.redhat.com (Postfix, from userid 13519) id 6E56C18D412; Wed, 4 May 2011 16:31:04 +0300 (IDT) From: Gleb Natapov To: linux-kernel@vger.kernel.org Cc: avi@redhat.com, mtosatti@redhat.com, kvm@vger.kernel.org, paulmck@linux.vnet.ibm.com Subject: [PATCH 2/2] KVM: make guest mode entry to be rcu quiescent state Date: Wed, 4 May 2011 16:31:04 +0300 Message-Id: <1304515864-17105-3-git-send-email-gleb@redhat.com> In-Reply-To: <1304515864-17105-1-git-send-email-gleb@redhat.com> References: <1304515864-17105-1-git-send-email-gleb@redhat.com> X-Scanned-By: MIMEDefang 2.67 on 10.5.11.11 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.6 (demeter1.kernel.org [140.211.167.41]); Wed, 04 May 2011 13:31:47 +0000 (UTC) KVM does not hold any references to rcu protected data when it switches CPU into a guest mode. In fact switching to a guest mode is very similar to exiting to userspase from rcu point of view. In addition CPU may stay in a guest mode for quite a long time (up to one time slice). Lets treat guest mode as quiescent state, just like we do with user-mode execution. Signed-off-by: Gleb Natapov --- include/linux/kvm_host.h | 9 +++++++++ 1 files changed, 9 insertions(+), 0 deletions(-) diff --git a/include/linux/kvm_host.h b/include/linux/kvm_host.h index 0bc3d37..244413f 100644 --- a/include/linux/kvm_host.h +++ b/include/linux/kvm_host.h @@ -591,8 +591,17 @@ static inline int kvm_deassign_device(struct kvm *kvm, static inline void kvm_guest_enter(void) { + BUG_ON(preemptible()); account_system_vtime(current); current->flags |= PF_VCPU; + /* KVM does not hold any references to rcu protected data when it + * switches CPU into a guest mode. In fact switching to a guest mode + * is very similar to exiting to userspase from rcu point of view. In + * addition CPU may stay in a guest mode for quite a long time (up to + * one time slice). Lets treat guest mode as quiescent state, just like + * we do with user-mode execution. + */ + rcu_virt_note_context_switch(smp_processor_id()); } static inline void kvm_guest_exit(void)