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] Add find_domain_rcu_lock() and domain_rcu

To: xen-changelog@xxxxxxxxxxxxxxxxxxx
Subject: [Xen-changelog] [xen-unstable] Add find_domain_rcu_lock() and domain_rcu_unlock().
From: Xen patchbot-unstable <patchbot-unstable@xxxxxxxxxxxxxxxxxxx>
Date: Wed, 21 Feb 2007 18:00:18 -0800
Delivery-date: Wed, 21 Feb 2007 17:59:44 -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 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

<Prev in Thread] Current Thread [Next in Thread>
  • [Xen-changelog] [xen-unstable] Add find_domain_rcu_lock() and domain_rcu_unlock()., Xen patchbot-unstable <=