mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Gleb Natapov <gleb@redhat.com>
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	[thread overview]
Message-ID: <1304515864-17105-3-git-send-email-gleb@redhat.com> (raw)
In-Reply-To: <1304515864-17105-1-git-send-email-gleb@redhat.com>

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 <gleb@redhat.com>
---
 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)
-- 
1.7.4.4


  parent reply	other threads:[~2011-05-04 13:31 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-05-04 13:31 [PATCH 0/2] make kvm guest mode " Gleb Natapov
2011-05-04 13:31 ` [PATCH 1/2] rcu: provide rcu_virt_note_context_switch() function Gleb Natapov
2011-05-04 16:35   ` Paul E. McKenney
2011-05-09  8:51     ` Avi Kivity
2011-05-09 12:16       ` Paul E. McKenney
2011-05-04 13:31 ` Gleb Natapov [this message]
2011-05-11  9:57   ` [PATCH 2/2] KVM: make guest mode entry to be rcu quiescent state Avi Kivity
  -- strict thread matches above, loose matches on Subject: below --
2011-04-28  9:52 [PATCH 0/2] make kvm guest mode " Gleb Natapov
2011-04-28  9:52 ` [PATCH 2/2] KVM: make guest mode entry " Gleb Natapov
2011-05-03 13:13   ` Marcelo Tosatti
2011-05-03 13:20     ` Avi Kivity
2011-05-03 13:21     ` Gleb Natapov
2011-05-03 13:29       ` Marcelo Tosatti
2011-05-03 13:39         ` Gleb Natapov
2011-05-03 15:42           ` Marcelo Tosatti

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1304515864-17105-3-git-send-email-gleb@redhat.com \
    --to=gleb@redhat.com \
    --cc=avi@redhat.com \
    --cc=kvm@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mtosatti@redhat.com \
    --cc=paulmck@linux.vnet.ibm.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®