[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Xen-devel] [PATCH v2 2/5] vcpu: track hvm vcpu number on the system



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

Signed-off-by: Chao Gao <chao.gao@xxxxxxxxx>
---
 xen/common/domain.c     | 8 ++++++++
 xen/include/xen/sched.h | 2 ++
 2 files changed, 10 insertions(+)

diff --git a/xen/common/domain.c b/xen/common/domain.c
index b22aacc..d433d9e 100644
--- a/xen/common/domain.c
+++ b/xen/common/domain.c
@@ -71,6 +71,9 @@ struct vcpu *idle_vcpu[NR_CPUS] __read_mostly;
 
 vcpu_info_t dummy_vcpu_info;
 
+/* how many hvm vcpu on this system? */
+atomic_t num_hvm_vcpus;
+
 static void __domain_finalise_shutdown(struct domain *d)
 {
     struct vcpu *v;
@@ -193,6 +196,9 @@ struct vcpu *alloc_vcpu(
     if ( !is_idle_domain(d) )
         domain_update_node_affinity(d);
 
+    if ( is_hvm_domain(d) )
+        atomic_inc(&num_hvm_vcpus);
+
     return v;
 }
 
@@ -803,6 +809,8 @@ static void complete_domain_destroy(struct rcu_head *head)
         vcpu_destroy(v);
         sched_destroy_vcpu(v);
         destroy_waitqueue_vcpu(v);
+        if ( is_hvm_domain(d) )
+            atomic_dec(&num_hvm_vcpus);
     }
 
     grant_table_destroy(d);
diff --git a/xen/include/xen/sched.h b/xen/include/xen/sched.h
index 1127ca9..5fb492d 100644
--- a/xen/include/xen/sched.h
+++ b/xen/include/xen/sched.h
@@ -139,6 +139,8 @@ void evtchn_destroy_final(struct domain *d); /* from 
complete_domain_destroy */
 
 struct waitqueue_vcpu;
 
+extern atomic_t num_hvm_vcpus;
+
 struct vcpu
 {
     int              vcpu_id;
-- 
1.8.3.1


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

 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.