Skip to contentSkip to conversation

Don't take the domain lock for p2m operations.

PATCH In review Tim Deegan 4 participants 4 messages Jul 29, 2013

lore
Share & tools
lore

Tim Deegan

author
#0 lore raw

PATCH v2 1/1 Don't take the domain lock for p2m operations.

P2M ops are covered by their own locks, and these uses of the domain lock are relics of shadow-v1 code.

---
v2: also drop a domain_lock() from ARM mm code.

---
 xen/arch/arm/mm.c   |    4 ----
 xen/arch/x86/mm.c   |    9 +++------
 xen/common/memory.c |    4 ----
 3 files changed, 3 insertions(+), 14 deletions(-)
xen/arch/arm/mm.c +0 -4
index d1290cd..f301e65 100644
@@ -875,13 +875,9 @@ static int xenmem_add_to_physmap_one(
         return -ENOSYS;
     }
 
-    domain_lock(d);
-
     /* Map at new location. */
     rc = guest_physmap_add_page(d, gpfn, mfn, 0);
 
-    domain_unlock(d);
-
     return rc;
 }
 
xen/arch/x86/mm.c +3 -6
index c00841c..e7f0e13 100644
@@ -4596,11 +4596,6 @@ static int xenmem_add_to_physmap_once(
         return -EINVAL;
     }
 
-    domain_lock(d);
-
-    if ( page )
-        put_page(page);
-
     /* Remove previously mapped page if it was present. */
     prev_mfn = mfn_x(get_gfn(d, xatp->gpfn, &p2mt));
     if ( mfn_valid(prev_mfn) )
@@ -4631,7 +4626,9 @@ static int xenmem_add_to_physmap_once(
     if ( xatp->space == XENMAPSPACE_gmfn ||
          xatp->space == XENMAPSPACE_gmfn_range )
         put_gfn(d, gfn);
-    domain_unlock(d);
+
+    if ( page )
+        put_page(page);
 
     return rc;
 }
xen/common/memory.c +0 -4
index 06a0d0a..50b740f 100644
@@ -693,8 +693,6 @@ long do_memory_op(unsigned long cmd, XEN_GUEST_HANDLE_PARAM(void) arg)
             return rc;
         }
 
-        domain_lock(d);
-
         page = get_page_from_gfn(d, xrfp.gpfn, NULL, P2M_ALLOC);
         if ( page )
         {
@@ -704,8 +702,6 @@ long do_memory_op(unsigned long cmd, XEN_GUEST_HANDLE_PARAM(void) arg)
         else
             rc = -ENOENT;
 
-        domain_unlock(d);
-
         rcu_unlock_domain(d);
 
         break;
Signature · 1 line
1.7.10.4
Reviewed-by on v2 1/1
#1 lore raw
Quoted 4 lines · Tim Deegan

P2M ops are covered by their own locks, and these uses of the domain lock are relics of shadow-v1 code.

Quoted 78 lines

---
v2: also drop a domain_lock() from ARM mm code.
---

xen/arch/arm/mm.c   |    4 ----
xen/arch/x86/mm.c   |    9 +++------
xen/common/memory.c |    4 ----
3 files changed, 3 insertions(+), 14 deletions(-)
xen/arch/arm/mm.c +0 -4
index d1290cd..f301e65 100644
@@ -875,13 +875,9 @@ static int xenmem_add_to_physmap_one(
        return -ENOSYS;
    }
 
-    domain_lock(d);
-
    /* Map at new location. */
    rc = guest_physmap_add_page(d, gpfn, mfn, 0);
 
-    domain_unlock(d);
-
    return rc;
 }
 
xen/arch/x86/mm.c +3 -6
index c00841c..e7f0e13 100644
@@ -4596,11 +4596,6 @@ static int xenmem_add_to_physmap_once(
        return -EINVAL;
    }
 
-    domain_lock(d);
-
-    if ( page )
-        put_page(page);
-
    /* Remove previously mapped page if it was present. */
    prev_mfn = mfn_x(get_gfn(d, xatp->gpfn, &p2mt));
    if ( mfn_valid(prev_mfn) )
@@ -4631,7 +4626,9 @@ static int xenmem_add_to_physmap_once(
    if ( xatp->space == XENMAPSPACE_gmfn ||
         xatp->space == XENMAPSPACE_gmfn_range )
        put_gfn(d, gfn);
-    domain_unlock(d);
+
+    if ( page )
+        put_page(page);
 
    return rc;
 }
xen/common/memory.c +0 -4
index 06a0d0a..50b740f 100644
@@ -693,8 +693,6 @@ long do_memory_op(unsigned long cmd, XEN_GUEST_HANDLE_PARAM(void) arg)
            return rc;
        }
 
-        domain_lock(d);
-
        page = get_page_from_gfn(d, xrfp.gpfn, NULL, P2M_ALLOC);
        if ( page )
        {
@@ -704,8 +702,6 @@ long do_memory_op(unsigned long cmd, XEN_GUEST_HANDLE_PARAM(void) arg)
        else
            rc = -ENOENT;
 
-        domain_unlock(d);
-
        rcu_unlock_domain(d);
 
        break;
Signature · 1 line
1.7.10.4
Acked-by on v2 1/1
#2 lore raw
In reply to Tim Deegan
Quoted 6 lines · Tim Deegan

P2M ops are covered by their own locks, and these uses of the domain lock are relics of shadow-v1 code.

---
v2: also drop a domain_lock() from ARM mm code.

Quoted 73 lines
---
 xen/arch/arm/mm.c   |    4 ----
 xen/arch/x86/mm.c   |    9 +++------
 xen/common/memory.c |    4 ----
 3 files changed, 3 insertions(+), 14 deletions(-)
xen/arch/arm/mm.c +0 -4
index d1290cd..f301e65 100644
@@ -875,13 +875,9 @@ static int xenmem_add_to_physmap_one(
         return -ENOSYS;
     }
 
-    domain_lock(d);
-
     /* Map at new location. */
     rc = guest_physmap_add_page(d, gpfn, mfn, 0);
 
-    domain_unlock(d);
-
     return rc;
 }
 
xen/arch/x86/mm.c +3 -6
index c00841c..e7f0e13 100644
@@ -4596,11 +4596,6 @@ static int xenmem_add_to_physmap_once(
         return -EINVAL;
     }
 
-    domain_lock(d);
-
-    if ( page )
-        put_page(page);
-
     /* Remove previously mapped page if it was present. */
     prev_mfn = mfn_x(get_gfn(d, xatp->gpfn, &p2mt));
     if ( mfn_valid(prev_mfn) )
@@ -4631,7 +4626,9 @@ static int xenmem_add_to_physmap_once(
     if ( xatp->space == XENMAPSPACE_gmfn ||
          xatp->space == XENMAPSPACE_gmfn_range )
         put_gfn(d, gfn);
-    domain_unlock(d);
+
+    if ( page )
+        put_page(page);
 
     return rc;
 }
xen/common/memory.c +0 -4
index 06a0d0a..50b740f 100644
@@ -693,8 +693,6 @@ long do_memory_op(unsigned long cmd, XEN_GUEST_HANDLE_PARAM(void) arg)
             return rc;
         }
 
-        domain_lock(d);
-
         page = get_page_from_gfn(d, xrfp.gpfn, NULL, P2M_ALLOC);
         if ( page )
         {
@@ -704,8 +702,6 @@ long do_memory_op(unsigned long cmd, XEN_GUEST_HANDLE_PARAM(void) arg)
         else
             rc = -ENOENT;
 
-        domain_unlock(d);
-
         rcu_unlock_domain(d);
 
         break;