Thread (51 messages) 51 messages, 3 authors, 2012-02-28

RE: [PATCH 24/37] KVM: PPC: booke: rework rescheduling checks

flat view

From: Bhushan Bharat-R65777 <hidden>
Date: 2012-02-27 18:29:15
Also in: kvm

-----Original Message-----
From: Alexander Graf [mailto:agraf@suse.de]
Sent: Monday, February 27, 2012 11:53 PM
To: Bhushan Bharat-R65777
Cc: kvm-ppc@vger.kernel.org; kvm@vger.kernel.org; linuxppc-dev@lists.ozla=
bs.org;
quoted hunk ↗ jump to hunk
Wood Scott-B07421
Subject: Re: [PATCH 24/37] KVM: PPC: booke: rework rescheduling checks
=20
On 02/27/2012 06:33 PM, Alexander Graf wrote:
quoted
On 02/27/2012 05:34 PM, Bhushan Bharat-R65777 wrote:
quoted
quoted
+}
+
+/*
+ * Common checks before entering the guest world.  Call with
interrupts
+ * disabled.
+ *
+ * returns !0 if a signal is pending and check_signal is true  */
+static int kvmppc_prepare_to_enter(struct kvm_vcpu *vcpu, bool
+check_signal) {
+    int r =3D 0;
+
+    WARN_ON_ONCE(!irqs_disabled());
+    while (true) {
+        if (need_resched()) {
+            local_irq_enable();
+            cond_resched();
+            local_irq_disable();
+            continue;
+        }
+
+        if (kvmppc_core_prepare_to_enter(vcpu)) {
kvmppc_prepare_to_enter() is called even on heavyweight_exit. Should
not this be called only on lightweight_exit?
Yeah, we don't need to call it when exiting anyways. That's a
functional change though, which this patch is trying not to introduce.
So we should rather do that as a patch on top.
=20
So how about this (warning! broken whitespace)?
=20
=20
diff --git a/arch/powerpc/kvm/booke.c b/arch/powerpc/kvm/booke.c index
7a16b56..616aa2d 100644
--- a/arch/powerpc/kvm/booke.c
+++ b/arch/powerpc/kvm/booke.c
@@ -464,7 +464,7 @@ int kvmppc_core_prepare_to_enter(struct kvm_vcpu *vcp=
u)
quoted hunk ↗ jump to hunk
   *
   * returns !0 if a signal is pending and check_signal is true
   */
-static int kvmppc_prepare_to_enter(struct kvm_vcpu *vcpu, bool
check_signal)
+static int kvmppc_prepare_to_enter(struct kvm_vcpu *vcpu)
  {
         int r =3D 0;
=20
@@ -483,7 +483,7 @@ static int kvmppc_prepare_to_enter(struct kvm_vcpu *v=
cpu,
quoted hunk ↗ jump to hunk
bool check_signal)
                         continue;
                 }
=20
-               if (check_signal && signal_pending(current))
+               if (signal_pending(current))
                         r =3D 1;
=20
                 break;
@@ -507,7 +507,7 @@ int kvmppc_vcpu_run(struct kvm_run *kvm_run, struct k=
vm_vcpu
quoted hunk ↗ jump to hunk
*vcpu)
         }
=20
         local_irq_disable();
-       if (kvmppc_prepare_to_enter(vcpu, true)) {
+       if (kvmppc_prepare_to_enter(vcpu)) {
                 kvm_run->exit_reason =3D KVM_EXIT_INTR;
                 ret =3D -EINTR;
                 goto out;
@@ -941,13 +941,16 @@ int kvmppc_handle_exit(struct kvm_run *run, struct
kvm_vcpu *vcpu,
          * To avoid clobbering exit_reason, only check for signals if we
          * aren't already exiting to userspace for some other reason.
          */
-       local_irq_disable();
-       if (kvmppc_prepare_to_enter(vcpu, !(r & RESUME_HOST))) {
-               run->exit_reason =3D KVM_EXIT_INTR;
-               r =3D (-EINTR << 2) | RESUME_HOST | (r & RESUME_FLAG_NV);
-               kvmppc_account_exit(vcpu, SIGNAL_EXITS);
+       if (!(r & RESUME_HOST)) {
+               local_irq_disable();
+               if (kvmppc_prepare_to_enter(vcpu)) {
+                       run->exit_reason =3D KVM_EXIT_INTR;
+                       r =3D (-EINTR << 2) | RESUME_HOST | (r &
RESUME_FLAG_NV);
+                       kvmppc_account_exit(vcpu, SIGNAL_EXITS);
+               }
         }
=20
+out:
Why?
Otherwise looks ok to me.

Thanks
-Bharat
         return r;
  }
=20
=20
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help