Skip to contentSkip to conversation

common/domain_page: Drop domain_mmap_cache infrastructure

PATCH In review Andrew Cooper 2 participants 2 messages Aug 9, 2017 – Aug 10, 2017

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 common/domain_page: Drop domain_mmap_cache infrastructure

This infrastructure is used exclusively by the x86 do_mmu_update() hypercall. Mapping and unmapping domain pages is probably not the slow part of that function, but even with an opencoded caching implementation, Bloat-o-meter reports:

function old new delta
do_mmu_update 6815 6573 -242

The !CONFIG_DOMAIN_PAGE stub code has a mismatch between mapping and unmapping, which is a latent bug.

---
CC: Jan Beulich <[email protected]>
CC: Stefano Stabellini <[email protected]>
CC: Julien Grall <[email protected]>

---
 xen/arch/x86/mm.c             | 22 ++++++++------
 xen/include/xen/domain_page.h | 68 -------------------------------------------
 2 files changed, 13 insertions(+), 77 deletions(-)
xen/arch/x86/mm.c +13 -9
index 97b3b4b..88bf4f6 100644
@@ -3440,13 +3440,13 @@ long do_mmu_update(
     unsigned int foreigndom)
 {
     struct mmu_update req;
-    void *va;
+    void *va = NULL;
     unsigned long gpfn, gmfn, mfn;
     struct page_info *page;
     unsigned int cmd, i = 0, done = 0, pt_dom;
     struct vcpu *curr = current, *v = curr;
     struct domain *d = v->domain, *pt_owner = d, *pg_owner;
-    struct domain_mmap_cache mapcache;
+    mfn_t map_mfn = INVALID_MFN;
     uint32_t xsm_needed = 0;
     uint32_t xsm_checked = 0;
     int rc = put_old_guest_table(curr);
@@ -3503,8 +3503,6 @@ long do_mmu_update(
         goto out;
     }
 
-    domain_mmap_cache_init(&mapcache);
-
     for ( i = 0; i < count; i++ )
     {
         if ( curr->arch.old_guest_table || (i && hypercall_preempt_check()) )
@@ -3573,9 +3571,15 @@ long do_mmu_update(
             }
 
             mfn = page_to_mfn(page);
-            va = map_domain_page_with_cache(mfn, &mapcache);
-            va = (void *)((unsigned long)va +
-                          (unsigned long)(req.ptr & ~PAGE_MASK));
+
+            if ( !mfn_eq(_mfn(mfn), map_mfn) )
+            {
+                if ( va )
+                    unmap_domain_page(va);
+                va = map_domain_page(_mfn(mfn));
+                map_mfn = _mfn(mfn);
+            }
+            va = _p(((unsigned long)va & PAGE_MASK) + (req.ptr & ~PAGE_MASK));
 
             if ( page_lock(page) )
             {
@@ -3653,7 +3657,6 @@ long do_mmu_update(
                 put_page_type(page);
             }
 
-            unmap_domain_page_with_cache(va, &mapcache);
             put_page(page);
         }
         break;
@@ -3734,7 +3737,8 @@ long do_mmu_update(
 
     put_pg_owner(pg_owner);
 
-    domain_mmap_cache_destroy(&mapcache);
+    if ( va )
+        unmap_domain_page(va);
 
     perfc_add(num_page_updates, i);
 
xen/include/xen/domain_page.h +0 -68

80 lines not on this page · raw message

Signature · 7 lines
2.1.4


_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel
Reviewed-by on v1 1/1
#1 lore raw
Quoted 6 lines
Quoted 1 line
Quoted 1 line · On 09.08.17 at 20:21, <[email protected]> wrote:

This infrastructure is used exclusively by the x86 do_mmu_update() hypercall. Mapping and unmapping domain pages is probably not the slow part of that function, but even with an opencoded caching implementation, Bloat-o-meter reports:

Quoted 7 lines

function old new delta
do_mmu_update 6815 6573 -242

The !CONFIG_DOMAIN_PAGE stub code has a mismatch between mapping and unmapping, which is a latent bug.

_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel