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

[Xen-devel] [patch] new version of find_domain_by_id() without reference count [1/6]



Following Keir suggestion, this is set of patches to add a new version
of find_domain_by_id() which does not increment the domain reference
counter. This reduces the overhead and can be used by any function which
does not need to keep a domain reference beyond its current invocation,
as the rcu mechanism prevents the domain from being removed under our
feet. Of course, this can only be applied after the RCU patch posted
earlier.

Beyond adding the function the patch also replaces most invocations to
find_domain_by_id() with the new function find_domain_by_id_noref().
Only a few places needed to continue using the old function as the
reference was kept beyond the function invocation.
  
I only did minor tests on x86-32. Xen and dom0 boots fine and I can
create and destroy domains. But, no more exaustive tests were done. I
carefully checked if I removed all put_domain() associated with each
modified invocation of find_domain_by_id but mistakes are always
possible. It would be good to put this to some more exhaustive tests
before pushing it to the main tree. Waiting for post 3.0.4 release is
strongly suggested.

I also decomposed the patch in multiple parts so that the mantainers of
each architecture can review changes in their subtree, test  and apply
them at their convenience.

This patch:
1/6: add new function find_domain_by_id_noref()

=======================================
Signed-off-by: Jose Renato Santos <jsantos@xxxxxxxxxx>

# HG changeset patch
# User root@xxxxxxxxxxxxxxxxxxx
# Node ID 2301c76e27c401a04f29745024091a374d49f424
# Parent  9650364c37ddab7a9e9b395237719188fb45a6e2
Add find_domain_by_id_noref()

diff -r 9650364c37dd -r 2301c76e27c4 xen/common/domain.c
--- a/xen/common/domain.c       Wed Dec  6 09:13:06 2006 -0800
+++ b/xen/common/domain.c       Fri Dec  8 18:09:25 2006 -0800
@@ -230,6 +230,23 @@ struct domain *find_domain_by_id(domid_t
 }
 
 
+struct domain *find_domain_by_id_noref(domid_t dom)
+{
+    struct domain *d;
+
+    rcu_read_lock();
+    d = rcu_dereference(domain_hash[DOMAIN_HASH(dom)]);
+    while ( d != NULL )
+    {
+        if ( d->domain_id == dom )
+            break;
+        d = rcu_dereference(d->next_in_hashbucket);
+    }
+    rcu_read_unlock();
+
+    return d;
+}
+
 void domain_kill(struct domain *d)
 {
     domain_pause(d);
diff -r 9650364c37dd -r 2301c76e27c4 xen/include/xen/sched.h
--- a/xen/include/xen/sched.h   Wed Dec  6 09:13:06 2006 -0800
+++ b/xen/include/xen/sched.h   Fri Dec  8 18:09:25 2006 -0800
@@ -259,6 +259,7 @@ int set_info_guest(struct domain *d, xen
 int set_info_guest(struct domain *d, xen_domctl_vcpucontext_t *);
 
 struct domain *find_domain_by_id(domid_t dom);
+struct domain *find_domain_by_id_noref(domid_t dom);
 void domain_destroy(struct domain *d);
 void domain_kill(struct domain *d);
 void domain_shutdown(struct domain *d, u8 reason);

Attachment: find_domain_by_id_noref_1.patch
Description: find_domain_by_id_noref_1.patch

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

 


Rackspace

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