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] [PATCH 13 of 16] credit2: Use loadavg to pick cpus, instead

To: <xen-devel@xxxxxxxxxxxxxxxxxxx>
Subject: [Xen-devel] [PATCH 13 of 16] credit2: Use loadavg to pick cpus, instead of instantaneous load
From: George Dunlap <george.dunlap@xxxxxxxxxxxxx>
Date: Thu, 23 Dec 2010 12:38:45 +0000
Cc: george.dunlap@xxxxxxxxxxxxx
Delivery-date: Thu, 23 Dec 2010 04:52:40 -0800
Envelope-to: www-data@xxxxxxxxxxxxxxxxxxx
In-reply-to: <patchbomb.1293107912@xxxxxxxxxxxxxxxxxxxxxxx>
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: <patchbomb.1293107912@xxxxxxxxxxxxxxxxxxxxxxx>
Sender: xen-devel-bounces@xxxxxxxxxxxxxxxxxxx
User-agent: Mercurial-patchbomb/1.6.3
Signed-off-by: George Dunlap <george.dunlap@xxxxxxxxxxxxx>

diff -r 97c754b8c144 -r 648a4a86b8c8 xen/common/sched_credit2.c
--- a/xen/common/sched_credit2.c        Thu Dec 23 12:26:43 2010 +0000
+++ b/xen/common/sched_credit2.c        Thu Dec 23 12:26:58 2010 +0000
@@ -996,13 +996,14 @@
     vcpu_schedule_unlock_irq(vc);
 }
 
-#define MAX_LOAD (1<<30);
+#define MAX_LOAD (1ULL<<60);
 static int
 choose_cpu(const struct scheduler *ops, struct vcpu *vc)
 {
     struct csched_private *prv = CSCHED_PRIV(ops);
-    int i, min_load, min_rqi = -1, new_cpu;
+    int i, min_rqi = -1, new_cpu;
     struct csched_vcpu *svc = CSCHED_VCPU(vc);
+    s_time_t min_avgload;
 
     BUG_ON(cpus_empty(prv->active_queues));
 
@@ -1053,27 +1054,39 @@
 
     /* FIXME: Pay attention to cpu affinity */                                 
                                                     
 
-    min_load = MAX_LOAD;
+    min_avgload = MAX_LOAD;
 
     /* Find the runqueue with the lowest instantaneous load */
     for_each_cpu_mask(i, prv->active_queues)
     {
         struct csched_runqueue_data *rqd;
+        s_time_t rqd_avgload;
 
         rqd = prv->rqd + i;
 
         /* If checking a different runqueue, grab the lock,
-         * read the avg, and then release the lock. */
-        if ( rqd != svc->rqd
-             && ! spin_trylock(&rqd->lock) )
+         * read the avg, and then release the lock.
+         *
+         * If on our own runqueue, don't grab or release the lock;
+         * but subtract our own load from the runqueue load to simulate
+         * impartiality */
+        if ( rqd == svc->rqd )
+        {
+            rqd_avgload = rqd->b_avgload - svc->avgload;
+        }
+        else if ( spin_trylock(&rqd->lock) )
+        {
+            rqd_avgload = rqd->b_avgload;
+            spin_unlock(&rqd->lock);
+        }
+        else
             continue;
-        if ( prv->rqd[i].load < min_load )
+
+        if ( rqd_avgload < min_avgload )
         {
-            min_load=prv->rqd[i].load;
+            min_avgload = rqd_avgload;
             min_rqi=i;
         }
-        if ( rqd != svc->rqd )
-            spin_unlock(&rqd->lock);
     }
 
     /* We didn't find anyone (most likely because of spinlock contention); 
leave it where it is */

_______________________________________________
Xen-devel mailing list
Xen-devel@xxxxxxxxxxxxxxxxxxx
http://lists.xensource.com/xen-devel