All of lore.kernel.org
 help / color / mirror / Atom feed
From: Boris Ostrovsky <boris.ostrovsky@oracle.com>
To: xen-devel@lists.xen.org
Cc: andrew.cooper3@citrix.com,
	Boris Ostrovsky <boris.ostrovsky@oracle.com>,
	jbeulich@suse.com
Subject: [PATCH 2/3] x86/vpmu: Decrement vpmu_count early in vpmu_destroy()
Date: Sun, 12 Feb 2017 21:29:56 -0500	[thread overview]
Message-ID: <1486952997-19445-3-git-send-email-boris.ostrovsky@oracle.com> (raw)
In-Reply-To: <1486952997-19445-1-git-send-email-boris.ostrovsky@oracle.com>

vpmu_count should be decremented even if VPMU_CONTEXT_ALLOCATED
is not set because on Intel processors the context is allocated
lazily and, in fact, might never happen.

Signed-off-by: Boris Ostrovsky <boris.ostrovsky@oracle.com>
---
 xen/arch/x86/cpu/vpmu.c | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/xen/arch/x86/cpu/vpmu.c b/xen/arch/x86/cpu/vpmu.c
index 0252171..9fa8a18 100644
--- a/xen/arch/x86/cpu/vpmu.c
+++ b/xen/arch/x86/cpu/vpmu.c
@@ -536,6 +536,11 @@ void vpmu_destroy(struct vcpu *v)
 {
     struct vpmu_struct *vpmu = vcpu_vpmu(v);
 
+    spin_lock(&vpmu_lock);
+    if ( !is_hardware_domain(v->domain) )
+        vpmu_count--;
+    spin_unlock(&vpmu_lock);
+
     if ( !vpmu_is_set(vpmu, VPMU_CONTEXT_ALLOCATED) )
         return;
 
@@ -557,11 +562,6 @@ void vpmu_destroy(struct vcpu *v)
                          vpmu_save_force, v, 1);
          vpmu->arch_vpmu_ops->arch_vpmu_destroy(v);
     }
-
-    spin_lock(&vpmu_lock);
-    if ( !is_hardware_domain(v->domain) )
-        vpmu_count--;
-    spin_unlock(&vpmu_lock);
 }
 
 static int pvpmu_init(struct domain *d, xen_pmu_params_t *params)
-- 
1.8.3.1


_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xen.org
https://lists.xen.org/xen-devel

  parent reply	other threads:[~2017-02-13  2:29 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-02-13  2:29 [PATCH 0/3] VPMU fixes Boris Ostrovsky
2017-02-13  2:29 ` [PATCH 1/3] x86/vpmu: Calculate vpmu_enabled() based on vpmu_mode value Boris Ostrovsky
2017-02-13 10:33   ` Andrew Cooper
2017-02-13 12:50   ` Jan Beulich
2017-02-13 14:38     ` Boris Ostrovsky
2017-02-13 14:44       ` Jan Beulich
2017-02-13 15:02         ` Boris Ostrovsky
2017-02-13  2:29 ` Boris Ostrovsky [this message]
2017-02-13 10:38   ` [PATCH 2/3] x86/vpmu: Decrement vpmu_count early in vpmu_destroy() Andrew Cooper
2017-02-13 14:22     ` Boris Ostrovsky
2017-02-13  2:29 ` [PATCH 3/3] x86: Adjust which files need vpmu.h Boris Ostrovsky
2017-02-13  2:46   ` Tian, Kevin
2017-02-13 10:38   ` Andrew Cooper

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=1486952997-19445-3-git-send-email-boris.ostrovsky@oracle.com \
    --to=boris.ostrovsky@oracle.com \
    --cc=andrew.cooper3@citrix.com \
    --cc=jbeulich@suse.com \
    --cc=xen-devel@lists.xen.org \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.