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] Grant-table cleanups, reduce break-even point for INVLPG

To: xen-changelog@xxxxxxxxxxxxxxxxxxx
Subject: [Xen-changelog] Grant-table cleanups, reduce break-even point for INVLPG vs. full flush,
From: BitKeeper Bot <riel@xxxxxxxxxxx>
Date: Tue, 19 Apr 2005 12:09:05 +0000
Delivery-date: Tue, 19 Apr 2005 13:03:33 +0000
Envelope-to: www-data@xxxxxxxxxxxxxxxxxxx
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 Development List <xen-devel@xxxxxxxxxxxxxxxxxxx>
Sender: xen-changelog-bounces@xxxxxxxxxxxxxxxxxxx
ChangeSet 1.1325, 2005/04/19 13:09:05+01:00, kaf24@xxxxxxxxxxxxxxxxxxxx

        Grant-table cleanups, reduce break-even point for INVLPG vs. full flush,
        and fix TLB flushing for SMP guests.
        Signed-off-by: Keir Fraser <keir@xxxxxxxxxxxxx>



 grant_table.c |  142 +++++++++++++++++++++++++++++-----------------------------
 1 files changed, 71 insertions(+), 71 deletions(-)


diff -Nru a/xen/common/grant_table.c b/xen/common/grant_table.c
--- a/xen/common/grant_table.c  2005-04-19 09:03:48 -04:00
+++ b/xen/common/grant_table.c  2005-04-19 09:03:48 -04:00
@@ -191,7 +191,8 @@
          * A more accurate check cannot be done with a single comparison.
          */
         if ( (act->pin & 0x80808080U) != 0 )
-            PIN_FAIL(unlock_out, ENOSPC, "Risk of counter overflow %08x\n", 
act->pin);
+            PIN_FAIL(unlock_out, ENOSPC,
+                     "Risk of counter overflow %08x\n", act->pin);
 
         frame = act->frame;
 
@@ -236,12 +237,14 @@
         if ( dev_hst_ro_flags & GNTMAP_device_map )
             act->pin += (dev_hst_ro_flags & GNTMAP_readonly) ? 
                 GNTPIN_devr_inc : GNTPIN_devw_inc;
+
         if ( dev_hst_ro_flags & GNTMAP_host_map )
             act->pin += (dev_hst_ro_flags & GNTMAP_readonly) ?
                 GNTPIN_hstr_inc : GNTPIN_hstw_inc;
     }
 
-    /* At this point:
+    /*
+     * At this point:
      * act->pin updated to reflect mapping.
      * sha->flags updated to indicate to granting domain mapping done.
      * frame contains the mfn.
@@ -251,9 +254,7 @@
 
     if ( (host_virt_addr != 0) && (dev_hst_ro_flags & GNTMAP_host_map) )
     {
-        /* Write update into the pagetable
-         */
-
+        /* Write update into the pagetable. */
         rc = update_grant_va_mapping( host_virt_addr,
                                 (frame << PAGE_SHIFT) | _PAGE_PRESENT  |
                                                         _PAGE_ACCESSED |
@@ -261,18 +262,21 @@
                        ((dev_hst_ro_flags & GNTMAP_readonly) ? 0 : _PAGE_RW),
                        mapping_d, mapping_ed );
 
-        /* IMPORTANT: (rc == 0) => must flush / invalidate entry in TLB.
+        /*
+         * IMPORTANT: (rc == 0) => must flush / invalidate entry in TLB.
          * This is done in the outer gnttab_map_grant_ref.
          */
 
-        if ( 0 > rc )
+        if ( rc < 0 )
         {
-            /* Abort. */
+            /* Failure: undo and abort. */
 
             spin_lock(&granting_d->grant_table->lock);
 
             if ( dev_hst_ro_flags & GNTMAP_readonly )
+            {
                 act->pin -= GNTPIN_hstr_inc;
+            }
             else
             {
                 act->pin -= GNTPIN_hstw_inc;
@@ -282,6 +286,7 @@
                     put_page_type(&frame_table[frame]);
                 }
             }
+
             if ( act->pin == 0 )
             {
                 clear_bit(_GTF_reading, &sha->flags);
@@ -292,6 +297,7 @@
         }
 
     }
+
     *pframe = frame;
     return rc;
 
@@ -300,6 +306,10 @@
     return rc;
 }
 
+/*
+ * Returns 0 if TLB flush / invalidate required by caller.
+ * va will indicate the address to be invalidated.
+ */
 static int
 __gnttab_map_grant_ref(
     gnttab_map_grant_ref_t *uop,
@@ -314,9 +324,6 @@
     unsigned long         frame = 0, host_virt_addr;
     int                   rc;
 
-    /* Returns 0 if TLB flush / invalidate required by caller.
-     * va will indicate the address to be invalidated. */
-
     led = current;
     ld = led->domain;
 
@@ -331,7 +338,7 @@
     }
 
 
-    if ( ((host_virt_addr != 0) || (dev_hst_ro_flags & GNTMAP_host_map) ) &&
+    if ( ((host_virt_addr != 0) || (dev_hst_ro_flags & GNTMAP_host_map)) &&
          unlikely(!__addr_ok(host_virt_addr)))
     {
         DPRINTK("Bad virtual address (%x) or flags (%x).\n",
@@ -341,8 +348,8 @@
     }
 
     if ( unlikely(ref >= NR_GRANT_ENTRIES) ||
-         unlikely((dev_hst_ro_flags & (GNTMAP_device_map|GNTMAP_host_map)) ==
-0) )
+         unlikely((dev_hst_ro_flags &
+                   (GNTMAP_device_map|GNTMAP_host_map)) == 0) )
     {
         DPRINTK("Bad ref (%d) or flags (%x).\n", ref, dev_hst_ro_flags);
         (void)__put_user(GNTST_bad_gntref, &uop->handle);
@@ -359,15 +366,16 @@
         return GNTST_bad_domain;
     }
 
-    /* get a maptrack handle */
+    /* Get a maptrack handle. */
     if ( unlikely((handle = get_maptrack_handle(ld->grant_table)) == -1) )
     {
         int              i;
         grant_mapping_t *new_mt;
         grant_table_t   *lgt      = ld->grant_table;
 
-        /* grow the maptrack table */
-        if ( (new_mt = (void *)alloc_xenheap_pages(lgt->maptrack_order + 1)) 
== NULL )
+        /* Grow the maptrack table. */
+        new_mt = (void *)alloc_xenheap_pages(lgt->maptrack_order + 1);
+        if ( new_mt == NULL )
         {
             put_domain(rd);
             DPRINTK("No more map handles available\n");
@@ -397,9 +405,9 @@
                                                   dev_hst_ro_flags,
                                                   host_virt_addr, &frame)))
     {
-        /* Only make the maptrack live _after_ writing the pte,
-         * in case we overwrite the same frame number, causing a
-         *  maptrack walk to find it
+        /*
+         * Only make the maptrack live _after_ writing the pte, in case we 
+         * overwrite the same frame number, causing a maptrack walk to find it
          */
         ld->grant_table->maptrack[handle].domid = dom;
 
@@ -429,21 +437,16 @@
     gnttab_map_grant_ref_t *uop, unsigned int count)
 {
     int i, flush = 0;
-    unsigned long va[8];
+    unsigned long va;
 
     for ( i = 0; i < count; i++ )
-        if ( __gnttab_map_grant_ref(&uop[i],
-             &va[ (flush < 8 ? flush : 0) ]   ) == 0)
+        if ( __gnttab_map_grant_ref(&uop[i], &va) == 0 )
             flush++;
 
-    if ( flush != 0 )
-    {
-        if ( flush <= 8 )
-            for ( i = 0; i < flush; i++ )
-                flush_tlb_one_mask(current->domain->cpuset, va[i]);
-        else 
-            local_flush_tlb();
-    }
+    if ( flush == 1 )
+        flush_tlb_one_mask(current->domain->cpuset, va);
+    else if ( flush != 0 ) 
+        flush_tlb_mask(current->domain->cpuset);
 
     return 0;
 }
@@ -499,6 +502,7 @@
         (void)__put_user(GNTST_bad_domain, &uop->status);
         return GNTST_bad_domain;
     }
+
 #if GRANT_DEBUG_VERBOSE
     DPRINTK("Unmapping grant ref (%hu) for domain (%hu) with handle (%hu)\n",
             ref, dom, handle);
@@ -510,15 +514,17 @@
     spin_lock(&rd->grant_table->lock);
 
     if ( frame == 0 )
+    {
         frame = act->frame;
+    }
     else if ( frame == GNTUNMAP_DEV_FROM_VIRT )
     {
         if ( !( flags & GNTMAP_device_map ) )
             PIN_FAIL(unmap_out, GNTST_bad_dev_addr,
-                     "Bad frame number: frame not mapped for device 
access.\n");
+                     "Bad frame number: frame not mapped for dev access.\n");
         frame = act->frame;
 
-        /* frame will be unmapped for device access below if virt addr ok */
+        /* Frame will be unmapped for device access below if virt addr okay. */
     }
     else
     {
@@ -532,7 +538,7 @@
         map->ref_and_flags &= ~GNTMAP_device_map;
         (void)__put_user(0, &uop->dev_bus_addr);
 
-        /* frame is now unmapped for device access */
+        /* Frame is now unmapped for device access. */
     }
 
     if ( (virt != 0) &&
@@ -543,7 +549,7 @@
         unsigned long   _ol1e;
 
         pl1e = &linear_pg_table[l1_linear_offset(virt)];
-                                                                               
             
+
         if ( unlikely(__get_user(_ol1e, (unsigned long *)pl1e) != 0) )
         {
             DPRINTK("Could not find PTE entry for address %x\n", virt);
@@ -551,8 +557,9 @@
             goto unmap_out;
         }
 
-        /* check that the virtual address supplied is actually
-         * mapped to act->frame.
+        /*
+         * Check that the virtual address supplied is actually mapped to 
+         * act->frame.
          */
         if ( unlikely((_ol1e >> PAGE_SHIFT) != frame ))
         {
@@ -562,8 +569,7 @@
             goto unmap_out;
         }
 
-        /* Delete pagetable entry
-         */
+        /* Delete pagetable entry. */
         if ( unlikely(__put_user(0, (unsigned long *)pl1e)))
         {

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

<Prev in Thread] Current Thread [Next in Thread>
  • [Xen-changelog] Grant-table cleanups, reduce break-even point for INVLPG vs. full flush,, BitKeeper Bot <=