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

[Xen-devel] [RFC][PATCH 3/4] sched: balance credits of each vcpu of a domain



By applying this patch, the credit scheduler balances credits of each active vcpu of a domain.

There is no change in this patch.

Best regards,
Naoki Nishiguchi
diff -r 1aec7bbd0ffc xen/common/sched_credit.c
--- a/xen/common/sched_credit.c Wed Dec 17 16:01:52 2008 +0900
+++ b/xen/common/sched_credit.c Wed Dec 17 16:02:29 2008 +0900
@@ -838,7 +838,8 @@ csched_acct(void)
     int credit_balance;
     int credit_xtra;
     int credit;
-
+    int64_t credit_sum;
+    int credit_average;
 
     spin_lock_irqsave(&csched_priv.lock, flags);
 
@@ -887,6 +888,18 @@ csched_acct(void)
         BUG_ON( sdom->active_vcpu_count == 0 );
         BUG_ON( sdom->weight == 0 );
         BUG_ON( sdom->weight > weight_left );
+
+        /* Compute the average of active VCPUs. */
+        credit_sum = 0;
+        list_for_each_safe( iter_vcpu, next_vcpu, &sdom->active_vcpu )
+        {
+            svc = list_entry(iter_vcpu, struct csched_vcpu, active_vcpu_elem);
+            BUG_ON( sdom != svc->sdom );
+
+            credit_sum += atomic_read(&svc->credit);
+        }
+        credit_average = ( credit_sum + (sdom->active_vcpu_count - 1)
+                         ) / sdom->active_vcpu_count;
 
         weight_left -= sdom->weight;
 
@@ -959,8 +972,9 @@ csched_acct(void)
             svc = list_entry(iter_vcpu, struct csched_vcpu, active_vcpu_elem);
             BUG_ON( sdom != svc->sdom );
 
-            /* Increment credit */
-            atomic_add(credit_fair, &svc->credit);
+            /* Balance and increment credit */
+            credit = atomic_read(&svc->credit);
+            atomic_add(credit_average - credit + credit_fair, &svc->credit);
             credit = atomic_read(&svc->credit);
 
             /*
_______________________________________________
Xen-devel mailing list
Xen-devel@xxxxxxxxxxxxxxxxxxx
http://lists.xensource.com/xen-devel

 


Rackspace

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