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: Thu, 18 Dec 2008 12:04:08 +0900
Cc: Ian.Pratt@xxxxxxxxxxxxx, disheng.su@xxxxxxxxx, aviv@xxxxxxxxxxxx, keir.fraser@xxxxxxxxxxxxx, sakaia@xxxxxxxxxxxxxx
Delivery-date: Wed, 17 Dec 2008 19:04:37 -0800
Envelope-to: www-data@xxxxxxxxxxxxxxxxxxx
In-reply-to: <4949BC2C.4060302@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: <4949BC2C.4060302@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.

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