xen-devel.lists.xenproject.org archive mirror
 help / color / mirror / Atom feed
From: Chao Gao <chao.gao@intel.com>
To: xen-devel@lists.xen.org
Cc: Andrew Cooper <andrew.cooper3@citrix.com>,
	Jan Beulich <jbeulich@suse.com>, Chao Gao <chao.gao@intel.com>
Subject: [PATCH v3 2/3] vcpu: track hvm vcpu number on the system
Date: Wed, 24 May 2017 14:56:16 +0800	[thread overview]
Message-ID: <1495608977-15921-3-git-send-email-chao.gao@intel.com> (raw)
In-Reply-To: <1495608977-15921-1-git-send-email-chao.gao@intel.com>

This number is used to calculate how many hvm vcpu on a pcpu on average.
This counting is x86 specific.

Signed-off-by: Chao Gao <chao.gao@intel.com>
---
 xen/arch/x86/domain.c        | 10 ++++++++++
 xen/include/asm-x86/domain.h |  2 ++
 2 files changed, 12 insertions(+)

diff --git a/xen/arch/x86/domain.c b/xen/arch/x86/domain.c
index 13cdc50..050fe0e 100644
--- a/xen/arch/x86/domain.c
+++ b/xen/arch/x86/domain.c
@@ -66,6 +66,9 @@
 
 DEFINE_PER_CPU(struct vcpu *, curr_vcpu);
 
+/* how many hvm vcpu on this system? */
+atomic_t num_hvm_vcpus;
+
 static void default_idle(void);
 void (*pm_idle) (void) __read_mostly = default_idle;
 void (*dead_idle) (void) __read_mostly = default_dead_idle;
@@ -467,7 +470,11 @@ int vcpu_initialise(struct vcpu *v)
             xfree(v->arch.pv_vcpu.trap_ctxt);
     }
     else if ( !is_idle_domain(v->domain) )
+    {
         vpmu_initialise(v);
+        if ( is_hvm_domain(v->domain) )
+            atomic_inc(&num_hvm_vcpus);
+    }
 
     return rc;
 }
@@ -489,7 +496,10 @@ void vcpu_destroy(struct vcpu *v)
         vpmu_destroy(v);
 
     if ( is_hvm_vcpu(v) )
+    {
         hvm_vcpu_destroy(v);
+        atomic_dec(&num_hvm_vcpus);
+    }
     else
         xfree(v->arch.pv_vcpu.trap_ctxt);
 }
diff --git a/xen/include/asm-x86/domain.h b/xen/include/asm-x86/domain.h
index 924caac..769cde2 100644
--- a/xen/include/asm-x86/domain.h
+++ b/xen/include/asm-x86/domain.h
@@ -31,6 +31,8 @@
 #define nmi_pending            nmi_state.pending
 #define mce_pending            mce_state.pending
 
+extern atomic_t num_hvm_vcpus;
+
 struct trap_bounce {
     uint32_t      error_code;
     uint8_t       flags; /* TBF_ */
-- 
1.8.3.1


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

  parent reply	other threads:[~2017-05-24  6:56 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-05-24  6:56 [PATCH v3 0/3] mitigate the per-pCPU blocking list may be too long Chao Gao
2017-05-24  6:56 ` [PATCH v3] VT-d PI: track the vcpu number in pi blocking list Chao Gao
2017-06-16 14:34   ` Jan Beulich
2017-06-22  5:16     ` Chao Gao
2017-06-22  6:51       ` Jan Beulich
2017-05-24  6:56 ` Chao Gao [this message]
2017-06-16 14:44   ` [PATCH v3 2/3] vcpu: track hvm vcpu number on the system Jan Beulich
2017-05-24  6:56 ` [PATCH v3 3/3] VT-d PI: restrict the vcpu number on a given pcpu Chao Gao
2017-06-16 15:09   ` Jan Beulich
2017-06-23  4:22     ` Chao Gao
2017-06-23  7:58       ` Jan Beulich
2017-06-23  8:33         ` Chao Gao
2017-06-23  9:05           ` Jan Beulich

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=1495608977-15921-3-git-send-email-chao.gao@intel.com \
    --to=chao.gao@intel.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).