[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Xen-changelog] [xen-unstable] Point per-vcpu vcpu_info at a dummy structure by default, avoiding



# HG changeset patch
# User Keir Fraser <keir.fraser@xxxxxxxxxx>
# Date 1256814894 0
# Node ID f74f0c1ae8ab2ae4b0683856730ac7f1b4283115
# Parent  e1fd971ec20ed1299fd7324e3a71305b7f129099
Point per-vcpu vcpu_info at a dummy structure by default, avoiding
need for scattered NULL-pointer checks.

Signed-off-by: Keir Fraser <keir.fraser@xxxxxxxxxx>
---
 xen/arch/x86/domain.c        |   11 ++---------
 xen/common/domain.c          |   10 +++++-----
 xen/common/event_channel.c   |   12 ------------
 xen/common/keyhandler.c      |    6 ++----
 xen/include/asm-x86/shared.h |    4 +---
 xen/include/xen/shared.h     |    2 ++
 6 files changed, 12 insertions(+), 33 deletions(-)

diff -r e1fd971ec20e -r f74f0c1ae8ab xen/arch/x86/domain.c
--- a/xen/arch/x86/domain.c     Thu Oct 29 08:34:51 2009 +0000
+++ b/xen/arch/x86/domain.c     Thu Oct 29 11:14:54 2009 +0000
@@ -832,7 +832,6 @@ static void
 static void
 unmap_vcpu_info(struct vcpu *v)
 {
-    struct domain *d = v->domain;
     unsigned long mfn;
 
     if ( v->arch.vcpu_info_mfn == INVALID_MFN )
@@ -841,7 +840,7 @@ unmap_vcpu_info(struct vcpu *v)
     mfn = v->arch.vcpu_info_mfn;
     unmap_domain_page_global(v->vcpu_info);
 
-    v->vcpu_info = (void *)&shared_info(d, vcpu_info[v->vcpu_id]);
+    v->vcpu_info = &dummy_vcpu_info;
     v->arch.vcpu_info_mfn = INVALID_MFN;
 
     put_page_and_type(mfn_to_page(mfn));
@@ -885,13 +884,7 @@ map_vcpu_info(struct vcpu *v, unsigned l
 
     new_info = (vcpu_info_t *)(mapping + offset);
 
-    if ( v->vcpu_info )
-        memcpy(new_info, v->vcpu_info, sizeof(*new_info));
-    else
-    {
-        memset(new_info, 0, sizeof(*new_info));
-        __vcpu_info(v, new_info, evtchn_upcall_mask) = 1;
-    }
+    memcpy(new_info, v->vcpu_info, sizeof(*new_info));
 
     v->vcpu_info = new_info;
     v->arch.vcpu_info_mfn = mfn;
diff -r e1fd971ec20e -r f74f0c1ae8ab xen/common/domain.c
--- a/xen/common/domain.c       Thu Oct 29 08:34:51 2009 +0000
+++ b/xen/common/domain.c       Thu Oct 29 11:14:54 2009 +0000
@@ -87,6 +87,8 @@ struct domain *dom0;
 
 struct vcpu *idle_vcpu[NR_CPUS] __read_mostly;
 
+vcpu_info_t dummy_vcpu_info;
+
 int current_domain_id(void)
 {
     return current->domain->domain_id;
@@ -154,8 +156,9 @@ struct vcpu *alloc_vcpu(
         v->runstate.state = RUNSTATE_offline;        
         v->runstate.state_entry_time = NOW();
         set_bit(_VPF_down, &v->pause_flags);
-        if ( vcpu_id < XEN_LEGACY_MAX_VCPUS )
-            v->vcpu_info = (void *)&shared_info(d, vcpu_info[vcpu_id]);
+        v->vcpu_info = ((vcpu_id < XEN_LEGACY_MAX_VCPUS)
+                        ? (vcpu_info_t *)&shared_info(d, vcpu_info[vcpu_id])
+                        : &dummy_vcpu_info);
     }
 
     if ( sched_init_vcpu(v, cpu_id) != 0 )
@@ -754,9 +757,6 @@ long do_vcpu_op(int cmd, int vcpuid, XEN
     switch ( cmd )
     {
     case VCPUOP_initialise:
-        if ( !v->vcpu_info )
-            return -EINVAL;
-
         if ( (ctxt = xmalloc(struct vcpu_guest_context)) == NULL )
             return -ENOMEM;
 
diff -r e1fd971ec20e -r f74f0c1ae8ab xen/common/event_channel.c
--- a/xen/common/event_channel.c        Thu Oct 29 08:34:51 2009 +0000
+++ b/xen/common/event_channel.c        Thu Oct 29 11:14:54 2009 +0000
@@ -244,9 +244,6 @@ static long evtchn_bind_virq(evtchn_bind
          ((v = d->vcpu[vcpu]) == NULL) )
         return -ENOENT;
 
-    if ( unlikely(!v->vcpu_info) )
-        return -EAGAIN;
-
     spin_lock(&d->event_lock);
 
     if ( v->virq_to_evtchn[virq] != 0 )
@@ -279,9 +276,6 @@ static long evtchn_bind_ipi(evtchn_bind_
     if ( (vcpu < 0) || (vcpu >= d->max_vcpus) ||
          (d->vcpu[vcpu] == NULL) )
         return -ENOENT;
-
-    if ( unlikely(!d->vcpu[vcpu]->vcpu_info) )
-        return -EAGAIN;
 
     spin_lock(&d->event_lock);
 
@@ -726,9 +720,6 @@ long evtchn_bind_vcpu(unsigned int port,
     if ( (vcpu_id >= d->max_vcpus) || (d->vcpu[vcpu_id] == NULL) )
         return -ENOENT;
 
-    if ( unlikely(!d->vcpu[vcpu_id]->vcpu_info) )
-        return -EAGAIN;
-
     spin_lock(&d->event_lock);
 
     if ( !port_is_valid(d, port) )
@@ -951,9 +942,6 @@ int alloc_unbound_xen_event_channel(
     struct evtchn *chn;
     struct domain *d = local_vcpu->domain;
     int            port;
-
-    if ( unlikely(!local_vcpu->vcpu_info) )
-        return -EAGAIN;
 
     spin_lock(&d->event_lock);
 
diff -r e1fd971ec20e -r f74f0c1ae8ab xen/common/keyhandler.c
--- a/xen/common/keyhandler.c   Thu Oct 29 08:34:51 2009 +0000
+++ b/xen/common/keyhandler.c   Thu Oct 29 11:14:54 2009 +0000
@@ -209,8 +209,8 @@ static void dump_domains(unsigned char k
                    v->vcpu_id, v->processor,
                    v->is_running ? 'T':'F',
                    v->pause_flags, v->poll_evtchn,
-                   v->vcpu_info ? vcpu_info(v, evtchn_upcall_pending) : 0,
-                   v->vcpu_info ? vcpu_info(v, evtchn_upcall_mask) : 1);
+                   vcpu_info(v, evtchn_upcall_pending),
+                   vcpu_info(v, evtchn_upcall_mask));
             cpuset_print(tmpstr, sizeof(tmpstr), v->vcpu_dirty_cpumask);
             printk("dirty_cpus=%s ", tmpstr);
             cpuset_print(tmpstr, sizeof(tmpstr), v->cpu_affinity);
@@ -218,8 +218,6 @@ static void dump_domains(unsigned char k
             arch_dump_vcpu_info(v);
             periodic_timer_print(tmpstr, sizeof(tmpstr), v->periodic_period);
             printk("    %s\n", tmpstr);
-            if ( !v->vcpu_info )
-                continue;
             printk("    Notifying guest (virq %d, port %d, stat %d/%d/%d)\n",
                    VIRQ_DEBUG, v->virq_to_evtchn[VIRQ_DEBUG],
                    test_bit(v->virq_to_evtchn[VIRQ_DEBUG], 
diff -r e1fd971ec20e -r f74f0c1ae8ab xen/include/asm-x86/shared.h
--- a/xen/include/asm-x86/shared.h      Thu Oct 29 08:34:51 2009 +0000
+++ b/xen/include/asm-x86/shared.h      Thu Oct 29 11:14:54 2009 +0000
@@ -26,8 +26,6 @@ static inline void arch_set_##field(stru
 #define GET_SET_VCPU(type, field)                               \
 static inline type arch_get_##field(const struct vcpu *v)       \
 {                                                               \
-    if ( unlikely(!v->vcpu_info) )                              \
-        return 0;                                               \
     return !has_32bit_shinfo(v->domain) ?                       \
            v->vcpu_info->native.arch.field :                    \
            v->vcpu_info->compat.arch.field;                     \
@@ -59,7 +57,7 @@ static inline void arch_set_##field(stru
 #define GET_SET_VCPU(type, field)                               \
 static inline type arch_get_##field(const struct vcpu *v)       \
 {                                                               \
-    return v->vcpu_info ? v->vcpu_info->arch.field : 0;         \
+    return v->vcpu_info->arch.field;                            \
 }                                                               \
 static inline void arch_set_##field(struct vcpu *v,             \
                                     type val)                   \
diff -r e1fd971ec20e -r f74f0c1ae8ab xen/include/xen/shared.h
--- a/xen/include/xen/shared.h  Thu Oct 29 08:34:51 2009 +0000
+++ b/xen/include/xen/shared.h  Thu Oct 29 11:14:54 2009 +0000
@@ -43,6 +43,8 @@ typedef struct vcpu_info vcpu_info_t;
 
 #endif
 
+extern vcpu_info_t dummy_vcpu_info;
+
 #define shared_info(d, field)      __shared_info(d, (d)->shared_info, field)
 #define vcpu_info(v, field)        __vcpu_info(v, (v)->vcpu_info, field)
 

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


 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.