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

[Xen-changelog] [xen-unstable] Add find_domain_rcu_lock() and domain_rcu_unlock().



# HG changeset patch
# User kfraser@xxxxxxxxxxxxxxxxxxxxx
# Date 1172075614 0
# Node ID af3281c66e7310cd0abe1a3f30de905d92ca6858
# Parent  97826d77bd4debec34716c9492aeffefa91b3932
Add find_domain_rcu_lock() and domain_rcu_unlock().

Signed-off-by: Jose Renato Santos <jsantos@xxxxxxxxxx>
Signed-off-by: Keir Fraser <keir@xxxxxxxxxxxxx>
---
 xen/common/domain.c     |   30 ++++++++++++++++++++++++++----
 xen/include/xen/sched.h |   15 +++++++++++++++
 2 files changed, 41 insertions(+), 4 deletions(-)

diff -r 97826d77bd4d -r af3281c66e73 xen/common/domain.c
--- a/xen/common/domain.c       Wed Feb 21 16:13:49 2007 +0000
+++ b/xen/common/domain.c       Wed Feb 21 16:33:34 2007 +0000
@@ -217,8 +217,10 @@ struct domain *get_domain_by_id(domid_t 
     struct domain *d;
 
     rcu_read_lock(&domlist_read_lock);
-    d = rcu_dereference(domain_hash[DOMAIN_HASH(dom)]);
-    while ( d != NULL )
+
+    for ( d = rcu_dereference(domain_hash[DOMAIN_HASH(dom)]);
+          d != NULL;
+          d = rcu_dereference(d->next_in_hashbucket) )
     {
         if ( d->domain_id == dom )
         {
@@ -226,11 +228,31 @@ struct domain *get_domain_by_id(domid_t 
                 d = NULL;
             break;
         }
-        d = rcu_dereference(d->next_in_hashbucket);
-    }
+    }
+
     rcu_read_unlock(&domlist_read_lock);
 
     return d;
+}
+
+
+struct domain *find_domain_rcu_lock(domid_t dom)
+{
+    struct domain *d;
+
+    rcu_read_lock(&domlist_read_lock);
+
+    for ( d = rcu_dereference(domain_hash[DOMAIN_HASH(dom)]);
+          d != NULL;
+          d = rcu_dereference(d->next_in_hashbucket) )
+    {
+        if ( d->domain_id == dom )
+            return d;
+    }
+
+    rcu_read_unlock(&domlist_read_lock);
+
+    return NULL;
 }
 
 
diff -r 97826d77bd4d -r af3281c66e73 xen/include/xen/sched.h
--- a/xen/include/xen/sched.h   Wed Feb 21 16:13:49 2007 +0000
+++ b/xen/include/xen/sched.h   Wed Feb 21 16:33:34 2007 +0000
@@ -268,6 +268,21 @@ int construct_dom0(
     unsigned long image_start, unsigned long image_len, 
     unsigned long initrd_start, unsigned long initrd_len,
     char *cmdline);
+
+/*
+ * find_domain_rcu_lock() is more efficient than get_domain_by_id().
+ * This is the preferred function if the returned domain reference
+ * is short lived,  but it cannot be used if the domain reference needs 
+ * to be kept beyond the current scope (e.g., across a softirq).
+ * The returned domain reference must be discarded using domain_rcu_unlock().
+ */
+struct domain *find_domain_rcu_lock(domid_t dom);
+
+/* Finish a RCU critical region started by find_domain_rcu_lock(). */
+static inline void domain_rcu_unlock(struct domain *d)
+{
+    rcu_read_unlock(&domlist_read_lock);
+}
 
 struct domain *get_domain_by_id(domid_t dom);
 void domain_destroy(struct domain *d);

_______________________________________________
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®.