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

[Xen-changelog] [xen-unstable] rcu_lock(current->domain) does not need to disable preemption.



# HG changeset patch
# User Keir Fraser <keir@xxxxxxx>
# Date 1290083187 0
# Node ID 92bc47c81fdcb06c0b0db2399a7d58b15a533c5d
# Parent  0b88ccf6332d6b8285843cf403b13a6623840de3
rcu_lock(current->domain) does not need to disable preemption.

If the guest sleeps in hypervisor context, it should not be destroyed
until execution reaches a safe point (i.e., guest context). This is
not implemented yet. :-) But the next patch will rely on it, to allow
an HVM guest to execute hypercalls that indirectly invoke __hvm_copy()
within an rcu_lock_current_domain() region.

Signed-off-by: Keir Fraser <keir@xxxxxxx>
---
 xen/arch/x86/mm.c       |    2 +-
 xen/arch/x86/physdev.c  |   12 ++++--------
 xen/common/domain.c     |    9 ++++++---
 xen/include/xen/sched.h |    8 +++++---
 4 files changed, 16 insertions(+), 15 deletions(-)

diff -r 0b88ccf6332d -r 92bc47c81fdc xen/arch/x86/mm.c
--- a/xen/arch/x86/mm.c Thu Nov 18 11:45:33 2010 +0000
+++ b/xen/arch/x86/mm.c Thu Nov 18 12:26:27 2010 +0000
@@ -2759,7 +2759,7 @@ static struct domain *get_pg_owner(domid
 
     if ( likely(domid == DOMID_SELF) )
     {
-        pg_owner = rcu_lock_domain(curr);
+        pg_owner = rcu_lock_current_domain();
         goto out;
     }
 
diff -r 0b88ccf6332d -r 92bc47c81fdc xen/arch/x86/physdev.c
--- a/xen/arch/x86/physdev.c    Thu Nov 18 11:45:33 2010 +0000
+++ b/xen/arch/x86/physdev.c    Thu Nov 18 12:26:27 2010 +0000
@@ -37,10 +37,8 @@ static int physdev_map_pirq(struct physd
     if ( !map )
         return -EINVAL;
 
-    if ( map->domid == DOMID_SELF )
-        d = rcu_lock_domain(current->domain);
-    else
-        d = rcu_lock_domain_by_id(map->domid);
+    d = (map->domid == DOMID_SELF) ? rcu_lock_current_domain()
+        : rcu_lock_domain_by_id(map->domid);
 
     if ( d == NULL )
         return -ESRCH;
@@ -165,10 +163,8 @@ static int physdev_unmap_pirq(struct phy
     struct domain *d;
     int ret;
 
-    if ( unmap->domid == DOMID_SELF )
-        d = rcu_lock_domain(current->domain);
-    else
-        d = rcu_lock_domain_by_id(unmap->domid);
+    d = (unmap->domid == DOMID_SELF) ? rcu_lock_current_domain()
+        : rcu_lock_domain_by_id(unmap->domid);
 
     if ( d == NULL )
         return -ESRCH;
diff -r 0b88ccf6332d -r 92bc47c81fdc xen/common/domain.c
--- a/xen/common/domain.c       Thu Nov 18 11:45:33 2010 +0000
+++ b/xen/common/domain.c       Thu Nov 18 12:26:27 2010 +0000
@@ -398,7 +398,7 @@ struct domain *get_domain_by_id(domid_t 
 
 struct domain *rcu_lock_domain_by_id(domid_t dom)
 {
-    struct domain *d;
+    struct domain *d = NULL;
 
     rcu_read_lock(&domlist_read_lock);
 
@@ -407,12 +407,15 @@ struct domain *rcu_lock_domain_by_id(dom
           d = rcu_dereference(d->next_in_hashbucket) )
     {
         if ( d->domain_id == dom )
-            return d;
+        {
+            rcu_lock_domain(d);
+            break;
+        }
     }
 
     rcu_read_unlock(&domlist_read_lock);
 
-    return NULL;
+    return d;
 }
 
 int rcu_lock_target_domain_by_id(domid_t dom, struct domain **d)
diff -r 0b88ccf6332d -r 92bc47c81fdc xen/include/xen/sched.h
--- a/xen/include/xen/sched.h   Thu Nov 18 11:45:33 2010 +0000
+++ b/xen/include/xen/sched.h   Thu Nov 18 12:26:27 2010 +0000
@@ -439,18 +439,20 @@ int rcu_lock_target_domain_by_id(domid_t
 /* Finish a RCU critical region started by rcu_lock_domain_by_id(). */
 static inline void rcu_unlock_domain(struct domain *d)
 {
-    rcu_read_unlock(&domlist_read_lock);
+    if ( d != current->domain )
+        rcu_read_unlock(&domlist_read_lock);
 }
 
 static inline struct domain *rcu_lock_domain(struct domain *d)
 {
-    rcu_read_lock(d);
+    if ( d != current->domain )
+        rcu_read_lock(d);
     return d;
 }
 
 static inline struct domain *rcu_lock_current_domain(void)
 {
-    return rcu_lock_domain(current->domain);
+    return /*rcu_lock_domain*/(current->domain);
 }
 
 struct domain *get_domain_by_id(domid_t dom);

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