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] Refactor domain/vcpu allocation to be more separated.

To: xen-changelog@xxxxxxxxxxxxxxxxxxx
Subject: [Xen-changelog] Refactor domain/vcpu allocation to be more separated.
From: Xen patchbot -unstable <patchbot-unstable@xxxxxxxxxxxxxxxxxxx>
Date: Thu, 13 Oct 2005 12:30:13 +0000
Delivery-date: Thu, 13 Oct 2005 12:27:56 +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-devel@xxxxxxxxxxxxxxxxxxx
Sender: xen-changelog-bounces@xxxxxxxxxxxxxxxxxxx
# HG changeset patch
# User kaf24@xxxxxxxxxxxxxxxxxxxx
# Node ID d6e99066959acf9f25b5515a67a2d15a7946a510
# Parent  af38c6b205f6f1bfb13310647b95b7557ab0e574
Refactor domain/vcpu allocation to be more separated.
Signed-off-by: Keir Fraser <keir@xxxxxxxxxxxxx>

diff -r af38c6b205f6 -r d6e99066959a xen/arch/x86/domain_build.c
--- a/xen/arch/x86/domain_build.c       Wed Oct 12 16:00:29 2005
+++ b/xen/arch/x86/domain_build.c       Wed Oct 12 16:01:38 2005
@@ -560,7 +560,7 @@
     d->shared_info->n_vcpu = num_online_cpus();
 
     for ( i = 1; i < d->shared_info->n_vcpu; i++ )
-        (void)alloc_vcpu(d, i);
+        (void)alloc_vcpu(d, i, i % num_online_cpus());
 
     /* Set up monitor table */
     update_pagetables(v);
diff -r af38c6b205f6 -r d6e99066959a xen/common/dom0_ops.c
--- a/xen/common/dom0_ops.c     Wed Oct 12 16:00:29 2005
+++ b/xen/common/dom0_ops.c     Wed Oct 12 16:01:38 2005
@@ -224,7 +224,7 @@
     case DOM0_MAX_VCPUS:
     {
         struct domain *d;
-        unsigned int i, max = op->u.max_vcpus.max;
+        unsigned int i, max = op->u.max_vcpus.max, cpu;
 
         ret = -EINVAL;
         if ( max > MAX_VIRT_CPUS )
@@ -250,8 +250,14 @@
 
         ret = -ENOMEM;
         for ( i = 0; i < max; i++ )
-            if ( (d->vcpu[i] == NULL) && (alloc_vcpu(d, i) == NULL) )
-                goto maxvcpu_out;
+        {
+            if ( d->vcpu[i] == NULL )
+            {
+                cpu = (d->vcpu[i-1]->processor + 1) % num_online_cpus();
+                if ( alloc_vcpu(d, i, cpu) == NULL )
+                    goto maxvcpu_out;
+            }
+        }
 
         ret = 0;
 
diff -r af38c6b205f6 -r d6e99066959a xen/common/domain.c
--- a/xen/common/domain.c       Wed Oct 12 16:00:29 2005
+++ b/xen/common/domain.c       Wed Oct 12 16:01:38 2005
@@ -36,16 +36,11 @@
     if ( (d = alloc_domain()) == NULL )
         return NULL;
 
-    v = d->vcpu[0];
+    d->domain_id = dom_id;
 
     atomic_set(&d->refcnt, 1);
-    atomic_set(&v->pausecnt, 0);
-
-    d->domain_id = dom_id;
-    v->processor = cpu;
 
     spin_lock_init(&d->big_lock);
-
     spin_lock_init(&d->page_alloc_lock);
     INIT_LIST_HEAD(&d->page_list);
     INIT_LIST_HEAD(&d->xenpage_list);
@@ -63,10 +58,16 @@
         return NULL;
     }
     
+    if ( (v = alloc_vcpu(d, 0, cpu)) == NULL )
+    {
+        grant_table_destroy(d);
+        evtchn_destroy(d);
+        free_domain(d);
+        return NULL;
+    }
+
     arch_do_createdomain(v);
     
-    sched_add_domain(v);
-
     if ( !is_idle_task(d) )
     {
         write_lock(&domlist_lock);
@@ -370,8 +371,6 @@
     if ( (rc = arch_set_info_guest(v, ctxt)) != 0 )
         return rc;
 
-    sched_add_domain(v);
-
     return rc;
 }
 
diff -r af38c6b205f6 -r d6e99066959a xen/common/schedule.c
--- a/xen/common/schedule.c     Wed Oct 12 16:00:29 2005
+++ b/xen/common/schedule.c     Wed Oct 12 16:01:38 2005
@@ -93,7 +93,8 @@
     xfree(d);
 }
 
-struct vcpu *alloc_vcpu(struct domain *d, unsigned int vcpu_id)
+struct vcpu *alloc_vcpu(
+    struct domain *d, unsigned int vcpu_id, unsigned int cpu_id)
 {
     struct vcpu *v;
 
@@ -104,6 +105,7 @@
 
     v->domain = d;
     v->vcpu_id = vcpu_id;
+    v->processor = cpu_id;
     atomic_set(&v->pausecnt, 0);
     v->cpumap = CPUMAP_RUNANYWHERE;
 
@@ -116,18 +118,14 @@
         return NULL;
     }
 
-    if ( vcpu_id == 0 )
-        return v;
-
-    v->vcpu_info = &d->shared_info->vcpu_data[vcpu_id];
-
-    d->vcpu[v->vcpu_id-1]->next_in_list = v;
-
-    v->processor = (d->vcpu[0]->processor + 1) % num_online_cpus();
-    if ( test_bit(_VCPUF_cpu_pinned, &d->vcpu[0]->vcpu_flags) )
-        set_bit(_VCPUF_cpu_pinned, &v->vcpu_flags);
-
-    set_bit(_VCPUF_down, &v->vcpu_flags);
+    sched_add_domain(v);
+
+    if ( vcpu_id != 0 )
+    {
+        v->vcpu_info = &d->shared_info->vcpu_data[vcpu_id];
+        d->vcpu[v->vcpu_id-1]->next_in_list = v;
+        set_bit(_VCPUF_down, &v->vcpu_flags);
+    }
 
     return v;
 }
@@ -136,19 +134,10 @@
 {
     struct domain *d;
 
-    if ( (d = xmalloc(struct domain)) == NULL )
-        return NULL;
-    
-    memset(d, 0, sizeof(*d));
-
-    if ( alloc_vcpu(d, 0) == NULL )
-        goto out;
+    if ( (d = xmalloc(struct domain)) != NULL )
+        memset(d, 0, sizeof(*d));
 
     return d;
-
- out:
-    xfree(d);
-    return NULL;
 }
 
 /*
diff -r af38c6b205f6 -r d6e99066959a xen/include/xen/sched.h
--- a/xen/include/xen/sched.h   Wed Oct 12 16:00:29 2005
+++ b/xen/include/xen/sched.h   Wed Oct 12 16:01:38 2005
@@ -167,7 +167,8 @@
 #define IDLE_DOMAIN_ID   (0x7FFFU)
 #define is_idle_task(_d) (test_bit(_DOMF_idle_domain, &(_d)->domain_flags))
 
-struct vcpu *alloc_vcpu(struct domain *d, unsigned int vcpu_id);
+struct vcpu *alloc_vcpu(
+    struct domain *d, unsigned int vcpu_id, unsigned int cpu_id);
 
 struct domain *alloc_domain(void);
 void free_domain(struct domain *d);

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

<Prev in Thread] Current Thread [Next in Thread>
  • [Xen-changelog] Refactor domain/vcpu allocation to be more separated., Xen patchbot -unstable <=