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] [xen-unstable] xen: Use RCU-based domain-locking functio

To: xen-changelog@xxxxxxxxxxxxxxxxxxx
Subject: [Xen-changelog] [xen-unstable] xen: Use RCU-based domain-locking functions where appropriate.
From: Xen patchbot-unstable <patchbot-unstable@xxxxxxxxxxxxxxxxxxx>
Date: Thu, 01 Mar 2007 08:10:13 -0800
Delivery-date: Thu, 01 Mar 2007 08:10:07 -0800
Envelope-to: www-data@xxxxxxxxxxxxxxxxxx
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 kfraser@xxxxxxxxxxxxxxxxxxxxx
# Date 1172745880 0
# Node ID 09a9b6d6c35684cdcf9cb0afa7ad6b5183a37b38
# Parent  a5b5279d2ba37fef5cb85adb15f83d077a5a6747
xen: Use RCU-based domain-locking functions where appropriate.
Signed-off-by: Jose Renato Santos <jsantos@xxxxxxxxxx>
---
 xen/acm/acm_core.c                          |    8 +--
 xen/acm/acm_simple_type_enforcement_hooks.c |   24 ++++-----
 xen/arch/x86/domctl.c                       |   44 +++++++++---------
 xen/arch/x86/hvm/hvm.c                      |   16 +++---
 xen/arch/x86/mm.c                           |   10 ++--
 xen/common/acm_ops.c                        |   46 +++++++++---------
 xen/common/domctl.c                         |   68 ++++++++++++++--------------
 xen/common/event_channel.c                  |   16 +++---
 xen/common/grant_table.c                    |   42 ++++++++---------
 xen/common/memory.c                         |   20 ++++----
 xen/include/acm/acm_hooks.h                 |    6 +-
 11 files changed, 149 insertions(+), 151 deletions(-)

diff -r a5b5279d2ba3 -r 09a9b6d6c356 xen/acm/acm_core.c
--- a/xen/acm/acm_core.c        Thu Mar 01 10:32:52 2007 +0000
+++ b/xen/acm/acm_core.c        Thu Mar 01 10:44:40 2007 +0000
@@ -260,7 +260,7 @@ acm_init_domain_ssid(domid_t id, ssidref
 acm_init_domain_ssid(domid_t id, ssidref_t ssidref)
 {
     struct acm_ssid_domain *ssid;
-    struct domain *subj = get_domain_by_id(id);
+    struct domain *subj = rcu_lock_domain_by_id(id);
     int ret1, ret2;
  
     if (subj == NULL)
@@ -270,7 +270,7 @@ acm_init_domain_ssid(domid_t id, ssidref
     }
     if ((ssid = xmalloc(struct acm_ssid_domain)) == NULL)
     {
-        put_domain(subj);
+        rcu_unlock_domain(subj);
         return ACM_INIT_SSID_ERROR;
     }
 
@@ -302,12 +302,12 @@ acm_init_domain_ssid(domid_t id, ssidref
         printk("%s: ERROR instantiating individual ssids for domain 0x%02x.\n",
                __func__, subj->domain_id);
         acm_free_domain_ssid(ssid);
-        put_domain(subj);
+        rcu_unlock_domain(subj);
         return ACM_INIT_SSID_ERROR;
     }
     printkd("%s: assigned domain %x the ssidref=%x.\n",
            __func__, id, ssid->ssidref);
-    put_domain(subj);
+    rcu_unlock_domain(subj);
     return ACM_OK;
 }
 
diff -r a5b5279d2ba3 -r 09a9b6d6c356 xen/acm/acm_simple_type_enforcement_hooks.c
--- a/xen/acm/acm_simple_type_enforcement_hooks.c       Thu Mar 01 10:32:52 
2007 +0000
+++ b/xen/acm/acm_simple_type_enforcement_hooks.c       Thu Mar 01 10:44:40 
2007 +0000
@@ -230,7 +230,7 @@ ste_init_state(struct acm_ste_policy_buf
                         __func__, d->domain_id, i, sha_copy.flags, 
sha_copy.domid, 
                         (unsigned long)sha_copy.frame);
                 rdomid = sha_copy.domid;
-                if ((rdom = get_domain_by_id(rdomid)) == NULL) {
+                if ((rdom = rcu_lock_domain_by_id(rdomid)) == NULL) {
                     spin_unlock(&d->grant_table->lock);
                     printkd("%s: domain not found ERROR!\n", __func__);
                     goto out;
@@ -239,7 +239,7 @@ ste_init_state(struct acm_ste_policy_buf
                 ste_rssid = GET_SSIDP(ACM_SIMPLE_TYPE_ENFORCEMENT_POLICY, 
                                       (struct acm_ssid_domain *)(rdom->ssid));
                 ste_rssidref = ste_rssid->ste_ssidref;
-                put_domain(rdom);
+                rcu_unlock_domain(rdom);
                 if (!have_common_type(ste_ssidref, ste_rssidref)) {
                     spin_unlock(&d->grant_table->lock);
                     printkd("%s: Policy violation in grant table sharing 
domain %x -> domain %x.\n",
@@ -494,8 +494,8 @@ ste_pre_eventchannel_unbound(domid_t id1
     if (id1 == DOMID_SELF) id1 = current->domain->domain_id;
     if (id2 == DOMID_SELF) id2 = current->domain->domain_id;
 
-    subj = get_domain_by_id(id1);
-    obj  = get_domain_by_id(id2);
+    subj = rcu_lock_domain_by_id(id1);
+    obj  = rcu_lock_domain_by_id(id2);
     if ((subj == NULL) || (obj == NULL)) {
         ret = ACM_ACCESS_DENIED;
         goto out;
@@ -517,9 +517,9 @@ ste_pre_eventchannel_unbound(domid_t id1
     }
   out:
     if (obj != NULL)
-        put_domain(obj);
+        rcu_unlock_domain(obj);
     if (subj != NULL)
-        put_domain(subj);
+        rcu_unlock_domain(subj);
     return ret;
 }
 
@@ -539,7 +539,7 @@ ste_pre_eventchannel_interdomain(domid_t
     if (id == DOMID_SELF) id = current->domain->domain_id;
 
     subj = current->domain;
-    obj  = get_domain_by_id(id);
+    obj  = rcu_lock_domain_by_id(id);
     if (obj == NULL) {
         ret = ACM_ACCESS_DENIED;
         goto out;
@@ -563,7 +563,7 @@ ste_pre_eventchannel_interdomain(domid_t
     }
  out:
     if (obj != NULL)
-        put_domain(obj);
+        rcu_unlock_domain(obj);
     return ret;
 }
 
@@ -582,7 +582,7 @@ ste_pre_grant_map_ref (domid_t id) {
     }
     atomic_inc(&ste_bin_pol.gt_eval_count);
     subj = current->domain;
-    obj = get_domain_by_id(id);
+    obj = rcu_lock_domain_by_id(id);
 
     if (share_common_type(subj, obj)) {
         cache_result(subj, obj);
@@ -593,7 +593,7 @@ ste_pre_grant_map_ref (domid_t id) {
         ret = ACM_ACCESS_DENIED;
     }
     if (obj != NULL)
-        put_domain(obj);
+        rcu_unlock_domain(obj);
     return ret;
 }
 
@@ -620,7 +620,7 @@ ste_pre_grant_setup (domid_t id) {
     }
     /* b) check types */
     subj = current->domain;
-    obj = get_domain_by_id(id);
+    obj = rcu_lock_domain_by_id(id);
 
     if (share_common_type(subj, obj)) {
         cache_result(subj, obj);
@@ -630,7 +630,7 @@ ste_pre_grant_setup (domid_t id) {
         ret = ACM_ACCESS_DENIED;
     }
     if (obj != NULL)
-        put_domain(obj);
+        rcu_unlock_domain(obj);
     return ret;
 }
 
diff -r a5b5279d2ba3 -r 09a9b6d6c356 xen/arch/x86/domctl.c
--- a/xen/arch/x86/domctl.c     Thu Mar 01 10:32:52 2007 +0000
+++ b/xen/arch/x86/domctl.c     Thu Mar 01 10:44:40 2007 +0000
@@ -39,13 +39,13 @@ long arch_do_domctl(
     {
         struct domain *d;
         ret = -ESRCH;
-        d = get_domain_by_id(domctl->domain);
+        d = rcu_lock_domain_by_id(domctl->domain);
         if ( d != NULL )
         {
             ret = paging_domctl(d,
                                 &domctl->u.shadow_op,
                                 guest_handle_cast(u_domctl, void));
-            put_domain(d);
+            rcu_unlock_domain(d);
             copy_to_guest(u_domctl, domctl, 1);
         } 
     }
@@ -62,7 +62,7 @@ long arch_do_domctl(
             break;
 
         ret = -ESRCH;
-        if ( unlikely((d = get_domain_by_id(domctl->domain)) == NULL) )
+        if ( unlikely((d = rcu_lock_domain_by_id(domctl->domain)) == NULL) )
             break;
 
         if ( np == 0 )
@@ -72,7 +72,7 @@ long arch_do_domctl(
         else
             ret = ioports_deny_access(d, fp, fp + np - 1);
 
-        put_domain(d);
+        rcu_unlock_domain(d);
     }
     break;
 
@@ -86,7 +86,7 @@ long arch_do_domctl(
         ret = -EINVAL;
 
         if ( unlikely(!mfn_valid(mfn)) ||
-             unlikely((d = get_domain_by_id(dom)) == NULL) )
+             unlikely((d = rcu_lock_domain_by_id(dom)) == NULL) )
             break;
 
         page = mfn_to_page(mfn);
@@ -119,7 +119,7 @@ long arch_do_domctl(
             put_page(page);
         }
 
-        put_domain(d);
+        rcu_unlock_domain(d);
 
         copy_to_guest(u_domctl, domctl, 1);
     }
@@ -134,13 +134,13 @@ long arch_do_domctl(
         uint32_t *arr32;
         ret = -ESRCH;
 
-        if ( unlikely((d = get_domain_by_id(dom)) == NULL) )
+        if ( unlikely((d = rcu_lock_domain_by_id(dom)) == NULL) )
             break;
 
         if ( unlikely(num > 1024) )
         {
             ret = -E2BIG;
-            put_domain(d);
+            rcu_unlock_domain(d);
             break;
         }
 
@@ -210,14 +210,14 @@ long arch_do_domctl(
 
         free_xenheap_page(arr32);
 
-        put_domain(d);
+        rcu_unlock_domain(d);
     }
     break;
 
     case XEN_DOMCTL_getmemlist:
     {
         int i;
-        struct domain *d = get_domain_by_id(domctl->domain);
+        struct domain *d = rcu_lock_domain_by_id(domctl->domain);
         unsigned long max_pfns = domctl->u.getmemlist.max_pfns;
         uint64_t mfn;
         struct list_head *list_ent;
@@ -248,14 +248,14 @@ long arch_do_domctl(
             domctl->u.getmemlist.num_pfns = i;
             copy_to_guest(u_domctl, domctl, 1);
 
-            put_domain(d);
+            rcu_unlock_domain(d);
         }
     }
     break;
 
     case XEN_DOMCTL_hypercall_init:
     {
-        struct domain *d = get_domain_by_id(domctl->domain);
+        struct domain *d = rcu_lock_domain_by_id(domctl->domain);
         unsigned long gmfn = domctl->u.hypercall_init.gmfn;
         unsigned long mfn;
         void *hypercall_page;
@@ -270,7 +270,7 @@ long arch_do_domctl(
         if ( !mfn_valid(mfn) ||
              !get_page_and_type(mfn_to_page(mfn), d, PGT_writable_page) )
         {
-            put_domain(d);
+            rcu_unlock_domain(d);
             break;
         }
 
@@ -282,7 +282,7 @@ long arch_do_domctl(
 
         put_page_and_type(mfn_to_page(mfn));
 
-        put_domain(d);
+        rcu_unlock_domain(d);
     }
     break;
 
@@ -296,7 +296,7 @@ long arch_do_domctl(
         c.data = NULL;
         
         ret = -ESRCH;
-        if ( (d = get_domain_by_id(domctl->domain)) == NULL )
+        if ( (d = rcu_lock_domain_by_id(domctl->domain)) == NULL )
             break;
 
         ret = -EINVAL;
@@ -317,7 +317,7 @@ long arch_do_domctl(
         if ( c.data != NULL )
             xfree(c.data);
 
-        put_domain(d);
+        rcu_unlock_domain(d);
     }
     break;
 
@@ -327,7 +327,7 @@ long arch_do_domctl(
         struct domain             *d;
 
         ret = -ESRCH;
-        if ( (d = get_domain_by_id(domctl->domain)) == NULL )
+        if ( (d = rcu_lock_domain_by_id(domctl->domain)) == NULL )
             break;
 
         ret = -EINVAL;
@@ -369,7 +369,7 @@ long arch_do_domctl(
         if ( c.data != NULL )
             xfree(c.data);
 
-        put_domain(d);
+        rcu_unlock_domain(d);
     }
     break;
 
@@ -378,7 +378,7 @@ long arch_do_domctl(
         struct domain *d;
 
         ret = -ESRCH;
-        if ( (d = get_domain_by_id(domctl->domain)) == NULL )
+        if ( (d = rcu_lock_domain_by_id(domctl->domain)) == NULL )
             break;
 
         switch ( domctl->u.address_size.size )
@@ -396,7 +396,7 @@ long arch_do_domctl(
             break;
         }
 
-        put_domain(d);
+        rcu_unlock_domain(d);
     }
     break;
 
@@ -405,13 +405,13 @@ long arch_do_domctl(
         struct domain *d;
 
         ret = -ESRCH;
-        if ( (d = get_domain_by_id(domctl->domain)) == NULL )
+        if ( (d = rcu_lock_domain_by_id(domctl->domain)) == NULL )
             break;
 
         domctl->u.address_size.size = BITS_PER_GUEST_LONG(d);
 
         ret = 0;
-        put_domain(d);
+        rcu_unlock_domain(d);
 
         if ( copy_to_guest(u_domctl, domctl, 1) )
             ret = -EFAULT;
diff -r a5b5279d2ba3 -r 09a9b6d6c356 xen/arch/x86/hvm/hvm.c
--- a/xen/arch/x86/hvm/hvm.c    Thu Mar 01 10:32:52 2007 +0000
+++ b/xen/arch/x86/hvm/hvm.c    Thu Mar 01 10:44:40 2007 +0000
@@ -711,7 +711,7 @@ static int hvmop_set_pci_intx_level(
     if ( (op.domain > 0) || (op.bus > 0) || (op.device > 31) || (op.intx > 3) )
         return -EINVAL;
 
-    d = get_domain_by_id(op.domid);
+    d = rcu_lock_domain_by_id(op.domid);
     if ( d == NULL )
         return -ESRCH;
 
@@ -734,7 +734,7 @@ static int hvmop_set_pci_intx_level(
     }
 
  out:
-    put_domain(d);
+    rcu_unlock_domain(d);
     return rc;
 }
 
@@ -754,7 +754,7 @@ static int hvmop_set_isa_irq_level(
     if ( op.isa_irq > 15 )
         return -EINVAL;
 
-    d = get_domain_by_id(op.domid);
+    d = rcu_lock_domain_by_id(op.domid);
     if ( d == NULL )
         return -ESRCH;
 
@@ -777,7 +777,7 @@ static int hvmop_set_isa_irq_level(
     }
 
  out:
-    put_domain(d);
+    rcu_unlock_domain(d);
     return rc;
 }
 
@@ -797,7 +797,7 @@ static int hvmop_set_pci_link_route(
     if ( (op.link > 3) || (op.isa_irq > 15) )
         return -EINVAL;
 
-    d = get_domain_by_id(op.domid);
+    d = rcu_lock_domain_by_id(op.domid);
     if ( d == NULL )
         return -ESRCH;
 
@@ -809,7 +809,7 @@ static int hvmop_set_pci_link_route(
     hvm_set_pci_link_route(d, op.link, op.isa_irq);
 
  out:
-    put_domain(d);
+    rcu_unlock_domain(d);
     return rc;
 }
 
@@ -842,7 +842,7 @@ long do_hvm_op(unsigned long op, XEN_GUE
         }
         else if ( IS_PRIV(current->domain) )
         {
-            d = get_domain_by_id(a.domid);
+            d = rcu_lock_domain_by_id(a.domid);
             if ( d == NULL )
                 return -ESRCH;
         }
@@ -899,7 +899,7 @@ long do_hvm_op(unsigned long op, XEN_GUE
         }
 
     param_fail:
-        put_domain(d);
+        rcu_unlock_domain(d);
         break;
     }
 
diff -r a5b5279d2ba3 -r 09a9b6d6c356 xen/arch/x86/mm.c
--- a/xen/arch/x86/mm.c Thu Mar 01 10:32:52 2007 +0000
+++ b/xen/arch/x86/mm.c Thu Mar 01 10:44:40 2007 +0000
@@ -2966,7 +2966,7 @@ long arch_memory_op(int op, XEN_GUEST_HA
         }
         else if ( !IS_PRIV(current->domain) )
             return -EPERM;
-        else if ( (d = get_domain_by_id(xatp.domid)) == NULL )
+        else if ( (d = rcu_lock_domain_by_id(xatp.domid)) == NULL )
             return -ESRCH;
 
         switch ( xatp.space )
@@ -2993,7 +2993,7 @@ long arch_memory_op(int op, XEN_GUEST_HA
 
         if ( !paging_mode_translate(d) || (mfn == 0) )
         {
-            put_domain(d);
+            rcu_unlock_domain(d);
             return -EINVAL;
         }
 
@@ -3021,7 +3021,7 @@ long arch_memory_op(int op, XEN_GUEST_HA
 
         UNLOCK_BIGLOCK(d);
 
-        put_domain(d);
+        rcu_unlock_domain(d);
 
         break;
     }
@@ -3045,14 +3045,14 @@ long arch_memory_op(int op, XEN_GUEST_HA
         }
         else if ( !IS_PRIV(current->domain) )
             return -EPERM;
-        else if ( (d = get_domain_by_id(fmap.domid)) == NULL )
+        else if ( (d = rcu_lock_domain_by_id(fmap.domid)) == NULL )
             return -ESRCH;
 
         rc = copy_from_guest(&d->arch.e820[0], fmap.map.buffer,
                              fmap.map.nr_entries) ? -EFAULT : 0;
         d->arch.nr_e820 = fmap.map.nr_entries;
 
-        put_domain(d);
+        rcu_unlock_domain(d);
         return rc;
     }
 
diff -r a5b5279d2ba3 -r 09a9b6d6c356 xen/common/acm_ops.c
--- a/xen/common/acm_ops.c      Thu Mar 01 10:32:52 2007 +0000
+++ b/xen/common/acm_ops.c      Thu Mar 01 10:44:40 2007 +0000
@@ -115,20 +115,20 @@ ret_t do_acm_op(int cmd, XEN_GUEST_HANDL
             ssidref = getssid.id.ssidref;
         else if (getssid.get_ssid_by == ACM_GETBY_domainid)
         {
-            struct domain *subj = get_domain_by_id(getssid.id.domainid);
-            if (!subj)
-            {
-                rc = -ESRCH; /* domain not found */
-                break;
-            }
-            if (subj->ssid == NULL)
-            {
-                put_domain(subj);
+            struct domain *subj = rcu_lock_domain_by_id(getssid.id.domainid);
+            if (!subj)
+            {
+                rc = -ESRCH; /* domain not found */
+                break;
+            }
+            if (subj->ssid == NULL)
+            {
+                rcu_unlock_domain(subj);
                 rc = -ESRCH;
                 break;
             }
             ssidref = ((struct acm_ssid_domain *)(subj->ssid))->ssidref;
-            put_domain(subj);
+            rcu_unlock_domain(subj);
         }
         else
         {
@@ -152,20 +152,20 @@ ret_t do_acm_op(int cmd, XEN_GUEST_HANDL
             ssidref1 = getdecision.id1.ssidref;
         else if (getdecision.get_decision_by1 == ACM_GETBY_domainid)
         {
-            struct domain *subj = get_domain_by_id(getdecision.id1.domainid);
-            if (!subj)
-            {
-                rc = -ESRCH; /* domain not found */
-                break;
-            }
-            if (subj->ssid == NULL)
-            {
-                put_domain(subj);
+            struct domain *subj = 
rcu_lock_domain_by_id(getdecision.id1.domainid);
+            if (!subj)
+            {
+                rc = -ESRCH; /* domain not found */
+                break;
+            }
+            if (subj->ssid == NULL)
+            {
+                rcu_unlock_domain(subj);
                 rc = -ESRCH;
                 break;
             }
             ssidref1 = ((struct acm_ssid_domain *)(subj->ssid))->ssidref;
-            put_domain(subj);
+            rcu_unlock_domain(subj);
         }
         else
         {
@@ -176,7 +176,7 @@ ret_t do_acm_op(int cmd, XEN_GUEST_HANDL
             ssidref2 = getdecision.id2.ssidref;
         else if (getdecision.get_decision_by2 == ACM_GETBY_domainid)
         {
-            struct domain *subj = get_domain_by_id(getdecision.id2.domainid);
+            struct domain *subj = 
rcu_lock_domain_by_id(getdecision.id2.domainid);
             if (!subj)
             {
                 rc = -ESRCH; /* domain not found */
@@ -184,12 +184,12 @@ ret_t do_acm_op(int cmd, XEN_GUEST_HANDL
             }
             if (subj->ssid == NULL)
             {
-                put_domain(subj);
+                rcu_unlock_domain(subj);
                 rc = -ESRCH;
                 break;
             }
             ssidref2 = ((struct acm_ssid_domain *)(subj->ssid))->ssidref;
-            put_domain(subj);
+            rcu_unlock_domain(subj);
         }
         else
         {
diff -r a5b5279d2ba3 -r 09a9b6d6c356 xen/common/domctl.c
--- a/xen/common/domctl.c       Thu Mar 01 10:32:52 2007 +0000
+++ b/xen/common/domctl.c       Thu Mar 01 10:44:40 2007 +0000
@@ -74,10 +74,10 @@ static inline int is_free_domid(domid_t 
     if ( dom >= DOMID_FIRST_RESERVED )
         return 0;
 
-    if ( (d = get_domain_by_id(dom)) == NULL )
+    if ( (d = rcu_lock_domain_by_id(dom)) == NULL )
         return 1;
 
-    put_domain(d);
+    rcu_unlock_domain(d);
     return 0;
 }
 
@@ -197,7 +197,7 @@ long do_domctl(XEN_GUEST_HANDLE(xen_domc
 
     case XEN_DOMCTL_setvcpucontext:
     {
-        struct domain *d = get_domain_by_id(op->domain);
+        struct domain *d = rcu_lock_domain_by_id(op->domain);
         vcpu_guest_context_u c = { .nat = NULL };
         unsigned int vcpu = op->u.vcpucontext.vcpu;
         struct vcpu *v;
@@ -243,13 +243,13 @@ long do_domctl(XEN_GUEST_HANDLE(xen_domc
 
     svc_out:
         xfree(c.nat);
-        put_domain(d);
+        rcu_unlock_domain(d);
     }
     break;
 
     case XEN_DOMCTL_pausedomain:
     {
-        struct domain *d = get_domain_by_id(op->domain);
+        struct domain *d = rcu_lock_domain_by_id(op->domain);
         ret = -ESRCH;
         if ( d != NULL )
         {
@@ -259,14 +259,14 @@ long do_domctl(XEN_GUEST_HANDLE(xen_domc
                 domain_pause_by_systemcontroller(d);
                 ret = 0;
             }
-            put_domain(d);
+            rcu_unlock_domain(d);
         }
     }
     break;
 
     case XEN_DOMCTL_unpausedomain:
     {
-        struct domain *d = get_domain_by_id(op->domain);
+        struct domain *d = rcu_lock_domain_by_id(op->domain);
         ret = -ESRCH;
         if ( d != NULL )
         {
@@ -277,14 +277,14 @@ long do_domctl(XEN_GUEST_HANDLE(xen_domc
                 domain_unpause_by_systemcontroller(d);
                 ret = 0;
             }
-            put_domain(d);
+            rcu_unlock_domain(d);
         }
     }
     break;
 
     case XEN_DOMCTL_resumedomain:
     {
-        struct domain *d = get_domain_by_id(op->domain);
+        struct domain *d = rcu_lock_domain_by_id(op->domain);
         struct vcpu *v;
 
         ret = -ESRCH;
@@ -294,7 +294,7 @@ long do_domctl(XEN_GUEST_HANDLE(xen_domc
             if ( test_and_clear_bit(_DOMF_shutdown, &d->domain_flags) )
                 for_each_vcpu ( d, v )
                     vcpu_wake(v);
-            put_domain(d);
+            rcu_unlock_domain(d);
         }
     }
     break;
@@ -363,7 +363,7 @@ long do_domctl(XEN_GUEST_HANDLE(xen_domc
             break;
 
         ret = -ESRCH;
-        if ( (d = get_domain_by_id(op->domain)) == NULL )
+        if ( (d = rcu_lock_domain_by_id(op->domain)) == NULL )
             break;
 
         /* Needed, for example, to ensure writable p.t. state is synced. */
@@ -392,13 +392,13 @@ long do_domctl(XEN_GUEST_HANDLE(xen_domc
 
     maxvcpu_out:
         domain_unpause(d);
-        put_domain(d);
+        rcu_unlock_domain(d);
     }
     break;
 
     case XEN_DOMCTL_destroydomain:
     {
-        struct domain *d = get_domain_by_id(op->domain);
+        struct domain *d = rcu_lock_domain_by_id(op->domain);
         ret = -ESRCH;
         if ( d != NULL )
         {
@@ -408,7 +408,7 @@ long do_domctl(XEN_GUEST_HANDLE(xen_domc
                 domain_kill(d);
                 ret = 0;
             }
-            put_domain(d);
+            rcu_unlock_domain(d);
         }
     }
     break;
@@ -417,7 +417,7 @@ long do_domctl(XEN_GUEST_HANDLE(xen_domc
     case XEN_DOMCTL_getvcpuaffinity:
     {
         domid_t dom = op->domain;
-        struct domain *d = get_domain_by_id(dom);
+        struct domain *d = rcu_lock_domain_by_id(dom);
         struct vcpu *v;
         cpumask_t new_affinity;
 
@@ -447,7 +447,7 @@ long do_domctl(XEN_GUEST_HANDLE(xen_domc
         }
 
     vcpuaffinity_out:
-        put_domain(d);
+        rcu_unlock_domain(d);
     }
     break;
 
@@ -456,14 +456,14 @@ long do_domctl(XEN_GUEST_HANDLE(xen_domc
         struct domain *d;
 
         ret = -ESRCH;
-        if ( (d = get_domain_by_id(op->domain)) == NULL )
+        if ( (d = rcu_lock_domain_by_id(op->domain)) == NULL )
             break;
 
         ret = sched_adjust(d, &op->u.scheduler_op);
         if ( copy_to_guest(u_domctl, op, 1) )
             ret = -EFAULT;
 
-        put_domain(d);
+        rcu_unlock_domain(d);
     }
     break;
 
@@ -510,7 +510,7 @@ long do_domctl(XEN_GUEST_HANDLE(xen_domc
         struct vcpu         *v;
 
         ret = -ESRCH;
-        if ( (d = get_domain_by_id(op->domain)) == NULL )
+        if ( (d = rcu_lock_domain_by_id(op->domain)) == NULL )
             break;
 
         ret = -EINVAL;
@@ -555,7 +555,7 @@ long do_domctl(XEN_GUEST_HANDLE(xen_domc
 
     getvcpucontext_out:
         xfree(c.nat);
-        put_domain(d);
+        rcu_unlock_domain(d);
     }
     break;
 
@@ -566,7 +566,7 @@ long do_domctl(XEN_GUEST_HANDLE(xen_domc
         struct vcpu_runstate_info runstate;
 
         ret = -ESRCH;
-        if ( (d = get_domain_by_id(op->domain)) == NULL )
+        if ( (d = rcu_lock_domain_by_id(op->domain)) == NULL )
             break;
 
         ret = -EINVAL;
@@ -590,7 +590,7 @@ long do_domctl(XEN_GUEST_HANDLE(xen_domc
             ret = -EFAULT;
 
     getvcpuinfo_out:
-        put_domain(d);
+        rcu_unlock_domain(d);
     }
     break;
 
@@ -600,7 +600,7 @@ long do_domctl(XEN_GUEST_HANDLE(xen_domc
         unsigned long new_max;
 
         ret = -ESRCH;
-        d = get_domain_by_id(op->domain);
+        d = rcu_lock_domain_by_id(op->domain);
         if ( d == NULL )
             break;
 
@@ -615,7 +615,7 @@ long do_domctl(XEN_GUEST_HANDLE(xen_domc
         }
         spin_unlock(&d->page_alloc_lock);
 
-        put_domain(d);
+        rcu_unlock_domain(d);
     }
     break;
 
@@ -623,12 +623,12 @@ long do_domctl(XEN_GUEST_HANDLE(xen_domc
     {
         struct domain *d;
         ret = -ESRCH;
-        d = get_domain_by_id(op->domain);
+        d = rcu_lock_domain_by_id(op->domain);
         if ( d != NULL )
         {
             memcpy(d->handle, op->u.setdomainhandle.handle,
                    sizeof(xen_domain_handle_t));
-            put_domain(d);
+            rcu_unlock_domain(d);
             ret = 0;
         }
     }
@@ -638,14 +638,14 @@ long do_domctl(XEN_GUEST_HANDLE(xen_domc
     {
         struct domain *d;
         ret = -ESRCH;
-        d = get_domain_by_id(op->domain);
+        d = rcu_lock_domain_by_id(op->domain);
         if ( d != NULL )
         {
             if ( op->u.setdebugging.enable )
                 set_bit(_DOMF_debugging, &d->domain_flags);
             else
                 clear_bit(_DOMF_debugging, &d->domain_flags);
-            put_domain(d);
+            rcu_unlock_domain(d);
             ret = 0;
         }
     }
@@ -661,7 +661,7 @@ long do_domctl(XEN_GUEST_HANDLE(xen_domc
             break;
 
         ret = -ESRCH;
-        d = get_domain_by_id(op->domain);
+        d = rcu_lock_domain_by_id(op->domain);
         if ( d == NULL )
             break;
 
@@ -670,7 +670,7 @@ long do_domctl(XEN_GUEST_HANDLE(xen_domc
         else
             ret = irq_deny_access(d, pirq);
 
-        put_domain(d);
+        rcu_unlock_domain(d);
     }
     break;
 
@@ -685,7 +685,7 @@ long do_domctl(XEN_GUEST_HANDLE(xen_domc
             break;
 
         ret = -ESRCH;
-        d = get_domain_by_id(op->domain);
+        d = rcu_lock_domain_by_id(op->domain);
         if ( d == NULL )
             break;
 
@@ -694,7 +694,7 @@ long do_domctl(XEN_GUEST_HANDLE(xen_domc
         else
             ret = iomem_deny_access(d, mfn, mfn + nr_mfns - 1);
 
-        put_domain(d);
+        rcu_unlock_domain(d);
     }
     break;
 
@@ -703,11 +703,11 @@ long do_domctl(XEN_GUEST_HANDLE(xen_domc
         struct domain *d;
 
         ret = -ESRCH;
-        d = get_domain_by_id(op->domain);
+        d = rcu_lock_domain_by_id(op->domain);
         if ( d != NULL )
         {
             d->time_offset_seconds = op->u.settimeoffset.time_offset_seconds;
-            put_domain(d);
+            rcu_unlock_domain(d);
             ret = 0;
         }
     }
diff -r a5b5279d2ba3 -r 09a9b6d6c356 xen/common/event_channel.c
--- a/xen/common/event_channel.c        Thu Mar 01 10:32:52 2007 +0000
+++ b/xen/common/event_channel.c        Thu Mar 01 10:44:40 2007 +0000
@@ -112,7 +112,7 @@ static long evtchn_alloc_unbound(evtchn_
     else if ( !IS_PRIV(current->domain) )
         return -EPERM;
 
-    if ( (d = get_domain_by_id(dom)) == NULL )
+    if ( (d = rcu_lock_domain_by_id(dom)) == NULL )
         return -ESRCH;
 
     spin_lock(&d->evtchn_lock);
@@ -130,7 +130,7 @@ static long evtchn_alloc_unbound(evtchn_
  out:
     spin_unlock(&d->evtchn_lock);
 
-    put_domain(d);
+    rcu_unlock_domain(d);
 
     return rc;
 }
@@ -150,7 +150,7 @@ static long evtchn_bind_interdomain(evtc
     if ( rdom == DOMID_SELF )
         rdom = current->domain->domain_id;
 
-    if ( (rd = get_domain_by_id(rdom)) == NULL )
+    if ( (rd = rcu_lock_domain_by_id(rdom)) == NULL )
         return -ESRCH;
 
     /* Avoid deadlock by first acquiring lock of domain with smaller id. */
@@ -198,7 +198,7 @@ static long evtchn_bind_interdomain(evtc
     if ( ld != rd )
         spin_unlock(&rd->evtchn_lock);
     
-    put_domain(rd);
+    rcu_unlock_domain(rd);
 
     return rc;
 }
@@ -598,7 +598,7 @@ static long evtchn_status(evtchn_status_
     else if ( !IS_PRIV(current->domain) )
         return -EPERM;
 
-    if ( (d = get_domain_by_id(dom)) == NULL )
+    if ( (d = rcu_lock_domain_by_id(dom)) == NULL )
         return -ESRCH;
 
     spin_lock(&d->evtchn_lock);
@@ -645,7 +645,7 @@ static long evtchn_status(evtchn_status_
 
  out:
     spin_unlock(&d->evtchn_lock);
-    put_domain(d);
+    rcu_unlock_domain(d);
     return rc;
 }
 
@@ -746,13 +746,13 @@ static long evtchn_reset(evtchn_reset_t 
     else if ( !IS_PRIV(current->domain) )
         return -EPERM;
 
-    if ( (d = get_domain_by_id(dom)) == NULL )
+    if ( (d = rcu_lock_domain_by_id(dom)) == NULL )
         return -ESRCH;
 
     for ( i = 0; port_is_valid(d, i); i++ )
         (void)__evtchn_close(d, i);
 
-    put_domain(d);
+    rcu_unlock_domain(d);
 
     return 0;
 }
diff -r a5b5279d2ba3 -r 09a9b6d6c356 xen/common/grant_table.c
--- a/xen/common/grant_table.c  Thu Mar 01 10:32:52 2007 +0000
+++ b/xen/common/grant_table.c  Thu Mar 01 10:44:40 2007 +0000
@@ -227,10 +227,8 @@ __gnttab_map_grant_ref(
         return;
     }
 
-    if ( unlikely((rd = get_domain_by_id(op->dom)) == NULL) )
-    {
-        if ( rd != NULL )
-            put_domain(rd);
+    if ( unlikely((rd = rcu_lock_domain_by_id(op->dom)) == NULL) )
+    {
         gdprintk(XENLOG_INFO, "Could not find domain %d\n", op->dom);
         op->status = GNTST_bad_domain;
         return;
@@ -238,7 +236,7 @@ __gnttab_map_grant_ref(
 
     if ( unlikely((handle = get_maptrack_handle(ld->grant_table)) == -1) )
     {
-        put_domain(rd);
+        rcu_unlock_domain(rd);
         gdprintk(XENLOG_INFO, "Failed to obtain maptrack handle.\n");
         op->status = GNTST_no_device_space;
         return;
@@ -368,7 +366,7 @@ __gnttab_map_grant_ref(
     op->handle       = handle;
     op->status       = GNTST_okay;
 
-    put_domain(rd);
+    rcu_unlock_domain(rd);
     return;
 
  undo_out:
@@ -395,7 +393,7 @@ __gnttab_map_grant_ref(
     spin_unlock(&rd->grant_table->lock);
     op->status = rc;
     put_maptrack_handle(ld->grant_table, handle);
-    put_domain(rd);
+    rcu_unlock_domain(rd);
 }
 
 static long
@@ -455,7 +453,7 @@ __gnttab_unmap_grant_ref(
     ref   = map->ref;
     flags = map->flags;
 
-    if ( unlikely((rd = get_domain_by_id(dom)) == NULL) )
+    if ( unlikely((rd = rcu_lock_domain_by_id(dom)) == NULL) )
     {
         /* This can happen when a grant is implicitly unmapped. */
         gdprintk(XENLOG_INFO, "Could not find domain %d\n", dom);
@@ -536,7 +534,7 @@ __gnttab_unmap_grant_ref(
  unmap_out:
     op->status = rc;
     spin_unlock(&rd->grant_table->lock);
-    put_domain(rd);
+    rcu_unlock_domain(rd);
 }
 
 static long
@@ -658,7 +656,7 @@ gnttab_setup_table(
         goto out;
     }
 
-    if ( unlikely((d = get_domain_by_id(dom)) == NULL) )
+    if ( unlikely((d = rcu_lock_domain_by_id(dom)) == NULL) )
     {
         gdprintk(XENLOG_INFO, "Bad domid %d.\n", dom);
         op.status = GNTST_bad_domain;
@@ -689,7 +687,7 @@ gnttab_setup_table(
  setup_unlock_out:
     spin_unlock(&d->grant_table->lock);
 
-    put_domain(d);
+    rcu_unlock_domain(d);
 
  out:
     if ( unlikely(copy_to_guest(uop, &op, 1)) )
@@ -726,7 +724,7 @@ gnttab_query_size(
         goto query_out;
     }
 
-    if ( unlikely((d = get_domain_by_id(dom)) == NULL) )
+    if ( unlikely((d = rcu_lock_domain_by_id(dom)) == NULL) )
     {
         gdprintk(XENLOG_INFO, "Bad domid %d.\n", dom);
         op.status = GNTST_bad_domain;
@@ -741,7 +739,7 @@ gnttab_query_size(
 
     spin_unlock(&d->grant_table->lock);
 
-    put_domain(d);
+    rcu_unlock_domain(d);
 
  query_out:
     if ( unlikely(copy_to_guest(uop, &op, 1)) )
@@ -869,7 +867,7 @@ gnttab_transfer(
         }
 
         /* Find the target domain. */
-        if ( unlikely((e = get_domain_by_id(gop.domid)) == NULL) )
+        if ( unlikely((e = rcu_lock_domain_by_id(gop.domid)) == NULL) )
         {
             gdprintk(XENLOG_INFO, "gnttab_transfer: can't find domain %d\n",
                     gop.domid);
@@ -897,7 +895,7 @@ gnttab_transfer(
                         "or is dying (%lx)\n",
                         e->tot_pages, e->max_pages, gop.ref, e->domain_flags);
             spin_unlock(&e->page_alloc_lock);
-            put_domain(e);
+            rcu_unlock_domain(e);
             page->count_info &= ~(PGC_count_mask|PGC_allocated);
             free_domheap_page(page);
             gop.status = GNTST_general_error;
@@ -925,7 +923,7 @@ gnttab_transfer(
 
         spin_unlock(&e->grant_table->lock);
 
-        put_domain(e);
+        rcu_unlock_domain(e);
 
         gop.status = GNTST_okay;
 
@@ -1092,7 +1090,7 @@ __gnttab_copy(
         sd = current->domain;
         get_knownalive_domain(sd);
     }
-    else if ( (sd = get_domain_by_id(op->source.domid)) == NULL )
+    else if ( (sd = rcu_lock_domain_by_id(op->source.domid)) == NULL )
     {
         PIN_FAIL(error_out, GNTST_bad_domain,
                  "couldn't find %d\n", op->source.domid);
@@ -1103,7 +1101,7 @@ __gnttab_copy(
         dd = current->domain;
         get_knownalive_domain(dd);
     }
-    else if ( (dd = get_domain_by_id(op->dest.domid)) == NULL )
+    else if ( (dd = rcu_lock_domain_by_id(op->dest.domid)) == NULL )
     {
         PIN_FAIL(error_out, GNTST_bad_domain,
                  "couldn't find %d\n", op->dest.domid);
@@ -1173,9 +1171,9 @@ __gnttab_copy(
     if ( have_d_grant )
         __release_grant_for_copy(dd, op->dest.u.ref, 0);
     if ( sd )
-        put_domain(sd);
+        rcu_unlock_domain(sd);
     if ( dd )
-        put_domain(dd);
+        rcu_unlock_domain(dd);
     op->status = rc;
 }
 
@@ -1397,7 +1395,7 @@ gnttab_release_mappings(
                 "flags:(%x) dom:(%hu)\n",
                 handle, ref, map->flags, map->domid);
 
-        rd = get_domain_by_id(map->domid);
+        rd = rcu_lock_domain_by_id(map->domid);
         if ( rd == NULL )
         {
             /* Nothing to clear up... */
@@ -1453,7 +1451,7 @@ gnttab_release_mappings(
 
         spin_unlock(&rd->grant_table->lock);
 
-        put_domain(rd);
+        rcu_unlock_domain(rd);
 
         map->flags = 0;
     }
diff -r a5b5279d2ba3 -r 09a9b6d6c356 xen/common/memory.c
--- a/xen/common/memory.c       Thu Mar 01 10:32:52 2007 +0000
+++ b/xen/common/memory.c       Thu Mar 01 10:44:40 2007 +0000
@@ -244,12 +244,12 @@ static long translate_gpfn_list(
     else if ( !IS_PRIV(current->domain) )
         return -EPERM;
 
-    if ( (d = get_domain_by_id(op.domid)) == NULL )
+    if ( (d = rcu_lock_domain_by_id(op.domid)) == NULL )
         return -ESRCH;
 
     if ( !shadow_mode_translate(d) )
     {
-        put_domain(d);
+        rcu_unlock_domain(d);
         return -EINVAL;
     }
 
@@ -257,14 +257,14 @@ static long translate_gpfn_list(
     {
         if ( hypercall_preempt_check() )
         {
-            put_domain(d);
+            rcu_unlock_domain(d);
             *progress = i;
             return -EAGAIN;
         }
 
         if ( unlikely(__copy_from_guest_offset(&gpfn, op.gpfn_list, i, 1)) )
         {
-            put_domain(d);
+            rcu_unlock_domain(d);
             return -EFAULT;
         }
 
@@ -272,12 +272,12 @@ static long translate_gpfn_list(
 
         if ( unlikely(__copy_to_guest_offset(op.mfn_list, i, &mfn, 1)) )
         {
-            put_domain(d);
+            rcu_unlock_domain(d);
             return -EFAULT;
         }
     }
 
-    put_domain(d);
+    rcu_unlock_domain(d);
     return 0;
 }
 
@@ -545,7 +545,7 @@ long do_memory_op(unsigned long cmd, XEN
         if ( likely(reservation.domid == DOMID_SELF) )
             d = current->domain;
         else if ( !IS_PRIV(current->domain) ||
-                  ((d = get_domain_by_id(reservation.domid)) == NULL) )
+                  ((d = rcu_lock_domain_by_id(reservation.domid)) == NULL) )
             return start_extent;
         args.domain = d;
 
@@ -563,7 +563,7 @@ long do_memory_op(unsigned long cmd, XEN
         }
 
         if ( unlikely(reservation.domid != DOMID_SELF) )
-            put_domain(d);
+            rcu_unlock_domain(d);
 
         rc = args.nr_done;
 
@@ -591,13 +591,13 @@ long do_memory_op(unsigned long cmd, XEN
             d = current->domain;
         else if ( !IS_PRIV(current->domain) )
             return -EPERM;
-        else if ( (d = get_domain_by_id(domid)) == NULL )
+        else if ( (d = rcu_lock_domain_by_id(domid)) == NULL )
             return -ESRCH;
 
         rc = (op == XENMEM_current_reservation) ? d->tot_pages : d->max_pages;
 
         if ( unlikely(domid != DOMID_SELF) )
-            put_domain(d);
+            rcu_unlock_domain(d);
 
         break;
 
diff -r a5b5279d2ba3 -r 09a9b6d6c356 xen/include/acm/acm_hooks.h
--- a/xen/include/acm/acm_hooks.h       Thu Mar 01 10:32:52 2007 +0000
+++ b/xen/include/acm/acm_hooks.h       Thu Mar 01 10:44:40 2007 +0000
@@ -241,18 +241,18 @@ static inline int acm_pre_domctl(struct 
                     __func__);
             return -EACCES;
         }
-        d = get_domain_by_id(op->domain);
+        d = rcu_lock_domain_by_id(op->domain);
         if (d != NULL) {
             *ssid = d->ssid; /* save for post destroy when d is gone */
             if (*ssid == NULL) {
                 printk("%s: Warning. Destroying domain without ssid 
pointer.\n", 
                        __func__);
-                put_domain(d);
+                domain_rcu_lock(d);
                 return -EACCES;
             }
             d->ssid = NULL; /* make sure it's not used any more */
              /* no policy-specific hook */
-            put_domain(d);
+            domain_rcu_lock(d);
             ret = 0;
         }
         break;

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

<Prev in Thread] Current Thread [Next in Thread>
  • [Xen-changelog] [xen-unstable] xen: Use RCU-based domain-locking functions where appropriate., Xen patchbot-unstable <=