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-changelog

[Xen-changelog] Merge freefall.cl.cam.ac.uk:/auto/groups/xeno/users/iap1

To: xen-changelog@xxxxxxxxxxxxxxxxxxx
Subject: [Xen-changelog] Merge freefall.cl.cam.ac.uk:/auto/groups/xeno/users/iap10/xeno-clone/xen-2.0-testing.bk
From: BitKeeper Bot <riel@xxxxxxxxxxx>
Date: Mon, 18 Apr 2005 21:30:15 +0000
Delivery-date: Tue, 19 Apr 2005 01:04:47 +0000
Envelope-to: www-data@xxxxxxxxxxxxxxxxxxx
List-help: <mailto:xen-changelog-request@lists.xensource.com?subject=help>
List-id: BK change log <xen-changelog.lists.xensource.com>
List-post: <mailto:xen-changelog@lists.xensource.com>
List-subscribe: <http://lists.xensource.com/cgi-bin/mailman/listinfo/xen-changelog>, <mailto:xen-changelog-request@lists.xensource.com?subject=subscribe>
List-unsubscribe: <http://lists.xensource.com/cgi-bin/mailman/listinfo/xen-changelog>, <mailto:xen-changelog-request@lists.xensource.com?subject=unsubscribe>
Reply-to: Xen Development List <xen-devel@xxxxxxxxxxxxxxxxxxx>
Sender: xen-changelog-bounces@xxxxxxxxxxxxxxxxxxx
ChangeSet 1.1317, 2005/04/18 22:30:15+01:00, iap10@xxxxxxxxxxxxxxxxxxxxx

        Merge 
freefall.cl.cam.ac.uk:/auto/groups/xeno/users/iap10/xeno-clone/xen-2.0-testing.bk
        into 
freefall.cl.cam.ac.uk:/auto/groups/xeno/users/iap10/xeno-clone/xen-unstable.bk



 schedule.c |  314 +++++++++++++++++++++++++++++++++----------------------------
 1 files changed, 173 insertions(+), 141 deletions(-)


diff -Nru a/xen/common/schedule.c b/xen/common/schedule.c
--- a/xen/common/schedule.c     2005-04-18 21:05:03 -04:00
+++ b/xen/common/schedule.c     2005-04-18 21:05:03 -04:00
@@ -1,5 +1,4 @@
-/* -*-  Mode:C; c-basic-offset:4; tab-width:4 -*-
- ****************************************************************************
+/****************************************************************************
  * (C) 2002-2003 - Rolf Neugebauer - Intel Research Cambridge
  * (C) 2002-2003 University of Cambridge
  * (C) 2004      - Mark Williamson - Intel Research Cambridge
@@ -14,6 +13,15 @@
  *
  */
 
+/*#define WAKE_HISTO*/
+/*#define BLOCKTIME_HISTO*/
+
+#if defined(WAKE_HISTO)
+#define BUCKETS 31
+#elif defined(BLOCKTIME_HISTO)
+#define BUCKETS 200
+#endif
+
 #include <xen/config.h>
 #include <xen/init.h>
 #include <xen/lib.h>
@@ -32,50 +40,19 @@
 static char opt_sched[10] = "bvt";
 string_param("sched", opt_sched);
 
-/*#define WAKE_HISTO*/
-/*#define BLOCKTIME_HISTO*/
-
-#if defined(WAKE_HISTO)
-#define BUCKETS 31
-#elif defined(BLOCKTIME_HISTO)
-#define BUCKETS 200
-#endif
-
 #define TIME_SLOP      (s32)MICROSECS(50)     /* allow time to slip a bit */
 
-/*
- * TODO MAW pull trace-related #defines out of here and into an auto-generated
- * header file later on!
- */
-#define TRC_SCHED_DOM_ADD             0x00010000
-#define TRC_SCHED_DOM_REM             0x00010001
-#define TRC_SCHED_WAKE                0x00010002
-#define TRC_SCHED_BLOCK               0x00010003
-#define TRC_SCHED_YIELD               0x00010004
-#define TRC_SCHED_SET_TIMER           0x00010005
-#define TRC_SCHED_CTL                 0x00010006
-#define TRC_SCHED_ADJDOM              0x00010007
-#define TRC_SCHED_RESCHED             0x00010008
-#define TRC_SCHED_SWITCH              0x00010009
-#define TRC_SCHED_S_TIMER_FN          0x0001000A
-#define TRC_SCHED_T_TIMER_FN          0x0001000B
-#define TRC_SCHED_DOM_TIMER_FN        0x0001000C
-
 /* Various timer handlers. */
 static void s_timer_fn(unsigned long unused);
 static void t_timer_fn(unsigned long unused);
 static void dom_timer_fn(unsigned long data);
 
 /* This is global for now so that private implementations can reach it */
-schedule_data_t schedule_data[NR_CPUS];
+struct schedule_data schedule_data[NR_CPUS];
 
 extern struct scheduler sched_bvt_def;
-extern struct scheduler sched_rrobin_def;
-extern struct scheduler sched_atropos_def;
 static struct scheduler *schedulers[] = { 
     &sched_bvt_def,
-    &sched_rrobin_def,
-    &sched_atropos_def,
     NULL
 };
 
@@ -92,59 +69,113 @@
 
 void free_domain_struct(struct domain *d)
 {
+    int i;
+
     SCHED_OP(free_task, d);
-    arch_free_domain_struct(d);
+    for (i = 0; i < MAX_VIRT_CPUS; i++)
+        if ( d->exec_domain[i] )
+            arch_free_exec_domain_struct(d->exec_domain[i]);
+
+    xfree(d);
+}
+
+struct exec_domain *alloc_exec_domain_struct(struct domain *d,
+                                             unsigned long vcpu)
+{
+    struct exec_domain *ed, *edc;
+
+    ASSERT( d->exec_domain[vcpu] == NULL );
+
+    if ( (ed = arch_alloc_exec_domain_struct()) == NULL )
+        return NULL;
+
+    memset(ed, 0, sizeof(*ed));
+
+    d->exec_domain[vcpu] = ed;
+    ed->domain = d;
+    ed->eid = vcpu;
+
+    if ( SCHED_OP(alloc_task, ed) < 0 )
+        goto out;
+
+    if (vcpu != 0) {
+        ed->vcpu_info = &d->shared_info->vcpu_data[ed->eid];
+
+        for_each_exec_domain(d, edc) {
+            if (edc->ed_next_list == NULL || edc->ed_next_list->eid > vcpu)
+                break;
+        }
+        ed->ed_next_list = edc->ed_next_list;
+        edc->ed_next_list = ed;
+
+        if (test_bit(EDF_CPUPINNED, &edc->ed_flags)) {
+            ed->processor = (edc->processor + 1) % smp_num_cpus;
+            set_bit(EDF_CPUPINNED, &ed->ed_flags);
+        } else {
+            ed->processor = (edc->processor + 1) % smp_num_cpus;  /* XXX */
+        }
+    }
+
+    return ed;
+
+ out:
+    d->exec_domain[vcpu] = NULL;
+    arch_free_exec_domain_struct(ed);
+
+    return NULL;
 }
 
 struct domain *alloc_domain_struct(void)
 {
     struct domain *d;
 
-    if ( (d = arch_alloc_domain_struct()) == NULL )
+    if ( (d = xmalloc(struct domain)) == NULL )
         return NULL;
     
     memset(d, 0, sizeof(*d));
 
-    if ( SCHED_OP(alloc_task, d) < 0 )
-    {
-        arch_free_domain_struct(d);
-        return NULL;
-    }
+    if ( alloc_exec_domain_struct(d, 0) == NULL )
+        goto out;
 
     return d;
+
+ out:
+    xfree(d);
+    return NULL;
 }
 
 /*
  * Add and remove a domain
  */
-void sched_add_domain(struct domain *d) 
+void sched_add_domain(struct exec_domain *ed) 
 {
+    struct domain *d = ed->domain;
+
     /* Must be unpaused by control software to start execution. */
-    set_bit(DF_CTRLPAUSE, &d->flags);
+    set_bit(EDF_CTRLPAUSE, &ed->ed_flags);
 
     if ( d->id != IDLE_DOMAIN_ID )
     {
         /* Initialise the per-domain timer. */
-        init_ac_timer(&d->timer);
-        d->timer.cpu      = d->processor;
-        d->timer.data     = (unsigned long)d;
-        d->timer.function = &dom_timer_fn;
+        init_ac_timer(&ed->timer);
+        ed->timer.cpu      = ed->processor;
+        ed->timer.data     = (unsigned long)ed;
+        ed->timer.function = &dom_timer_fn;
     }
     else
     {
-        schedule_data[d->processor].idle = d;
+        schedule_data[ed->processor].idle = ed;
     }
 
-    SCHED_OP(add_task, d);
-
-    TRACE_2D(TRC_SCHED_DOM_ADD, d->id, d);
+    SCHED_OP(add_task, ed);
+    TRACE_2D(TRC_SCHED_DOM_ADD, d->id, ed->eid);
 }
 
-void sched_rem_domain(struct domain *d) 
+void sched_rem_domain(struct exec_domain *ed) 
 {
-    rem_ac_timer(&d->timer);
-    SCHED_OP(rem_task, d);
-    TRACE_2D(TRC_SCHED_DOM_REM, d->id, d);
+    rem_ac_timer(&ed->timer);
+    SCHED_OP(rem_task, ed);
+    TRACE_2D(TRC_SCHED_DOM_REM, ed->domain->id, ed->eid);
 }
 
 void init_idle_task(void)
@@ -153,57 +184,64 @@
         BUG();
 }
 
-void domain_sleep(struct domain *d)
+void domain_sleep(struct exec_domain *ed)
 {
     unsigned long flags;
 
-    spin_lock_irqsave(&schedule_data[d->processor].schedule_lock, flags);
+    spin_lock_irqsave(&schedule_data[ed->processor].schedule_lock, flags);
+    if ( likely(!domain_runnable(ed)) )
+        SCHED_OP(sleep, ed);
+    spin_unlock_irqrestore(&schedule_data[ed->processor].schedule_lock, flags);
 
-    if ( likely(!domain_runnable(d)) )
-        SCHED_OP(sleep, d);
-
-    spin_unlock_irqrestore(&schedule_data[d->processor].schedule_lock, flags);
+    TRACE_2D(TRC_SCHED_SLEEP, ed->domain->id, ed->eid);
  
     /* Synchronous. */
-    while ( test_bit(DF_RUNNING, &d->flags) && !domain_runnable(d) )
+    while ( test_bit(EDF_RUNNING, &ed->ed_flags) && !domain_runnable(ed) )
         cpu_relax();
 }
 
-void domain_wake(struct domain *d)
+void domain_wake(struct exec_domain *ed)
 {
     unsigned long flags;
 
-    spin_lock_irqsave(&schedule_data[d->processor].schedule_lock, flags);
-
-    if ( likely(domain_runnable(d)) )
+    spin_lock_irqsave(&schedule_data[ed->processor].schedule_lock, flags);
+    if ( likely(domain_runnable(ed)) )

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