WARNING - OLD ARCHIVES

This is an archived copy of the Xen.org mailing list, which we have preserved to ensure that existing links to archives are not broken. The live archive, which contains the latest emails, can be found at http://lists.xen.org/
   
 
 
Xen 
 
Home Products Support Community News
 
   
 

xen-devel

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

To: George Dunlap <George.Dunlap@xxxxxxxxxxxxx>, xen-devel@xxxxxxxxxxxxxxxxxxx
Subject: [Xen-devel] [RFC][PATCH 3/4] sched: balance credits of each vcpu of a domain
From: NISHIGUCHI Naoki <nisiguti@xxxxxxxxxxxxxx>
Date: Fri, 05 Dec 2008 19:07:00 +0900
Cc: Ian.Pratt@xxxxxxxxxxxxx, disheng.su@xxxxxxxxx, keir.fraser@xxxxxxxxxxxxx
Delivery-date: Fri, 05 Dec 2008 02:07:46 -0800
Envelope-to: www-data@xxxxxxxxxxxxxxxxxxx
In-reply-to: <4938FC06.9080008@xxxxxxxxxxxxxx>
List-help: <mailto:xen-devel-request@lists.xensource.com?subject=help>
List-id: Xen developer discussion <xen-devel.lists.xensource.com>
List-post: <mailto:xen-devel@lists.xensource.com>
List-subscribe: <http://lists.xensource.com/mailman/listinfo/xen-devel>, <mailto:xen-devel-request@lists.xensource.com?subject=subscribe>
List-unsubscribe: <http://lists.xensource.com/mailman/listinfo/xen-devel>, <mailto:xen-devel-request@lists.xensource.com?subject=unsubscribe>
References: <4938FC06.9080008@xxxxxxxxxxxxxx>
Sender: xen-devel-bounces@xxxxxxxxxxxxxxxxxxx
User-agent: Thunderbird 2.0.0.18 (Windows/20081105)
By applying this patch, the credit scheduler balances credits of each
active vcpu of a domain.

Best regards,
Naoki Nishiguchi

diff -r a00eb6595d3c xen/common/sched_credit.c
--- a/xen/common/sched_credit.c Sat Nov 29 09:07:52 2008 +0000
+++ b/xen/common/sched_credit.c Fri Dec 05 18:16:34 2008 +0900
@@ -835,7 +835,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);
 
@@ -872,6 +873,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;
 
@@ -944,8 +957,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