]> xenbits.xensource.com Git - xen.git/commitdiff
bitkeeper revision 1.1236.1.73 (4230542aNzdikO2FdRgaB46eNiQNHw)
authorcwc22@centipede.cl.cam.ac.uk <cwc22@centipede.cl.cam.ac.uk>
Thu, 10 Mar 2005 14:05:30 +0000 (14:05 +0000)
committercwc22@centipede.cl.cam.ac.uk <cwc22@centipede.cl.cam.ac.uk>
Thu, 10 Mar 2005 14:05:30 +0000 (14:05 +0000)
Maintain count of mappings, and fast exit put_page check if none in use

xen/common/grant_table.c
xen/include/xen/grant_table.h

index 5ef5124960f971c820fa50aa75ac0cf864a798b6..b8302b64830202f7abae5a944ec7702a61531c6f 100644 (file)
@@ -44,6 +44,7 @@ get_maptrack_handle(
     if ( unlikely((h = t->maptrack_head) == NR_MAPTRACK_ENTRIES) )
         return -1;
     t->maptrack_head = t->maptrack[h].ref_and_flags >> MAPTRACK_REF_SHIFT;
+    t->map_count++;
     return h;
 }
 
@@ -53,6 +54,7 @@ put_maptrack_handle(
 {
     t->maptrack[handle].ref_and_flags = t->maptrack_head << MAPTRACK_REF_SHIFT;
     t->maptrack_head = handle;
+    t->map_count--;
 }
 
 static int
@@ -529,7 +531,7 @@ gnttab_unmap_grant_ref(
     if ( flush == 1 )
         __flush_tlb_one(va);
 
-    else if ( flush )
+    else if ( flush != 0 )
         local_flush_tlb();
 
     return 0;
@@ -734,12 +736,19 @@ gnttab_check_unmap(
     int found = 0;
 
     lgt = ld->grant_table;
+
+    /* Fast exit if we're not mapping anything using grant tables */
+    if ( lgt->map_count == 0 )
+        return 0;
+
     rgt = rd->grant_table;
 
+#ifdef GRANT_DEBUG
     if ( ld->id != 0 ) {
         DPRINTK("Foreign unref rd(%d) ld(%d) frm(%x) flgs(%x).\n",
                 rd->id, ld->id, frame, readonly);
     }
+#endif
 
     for ( handle = 0; handle < NR_MAPTRACK_ENTRIES; handle++ )
     {
index c161667cdf9f39e141f16c441c12a7f3016cec3c..9520fbca45443d2ac90528ea4b8862356b58e05a 100644 (file)
@@ -74,6 +74,7 @@ typedef struct {
     /* Mapping tracking table. */
     grant_mapping_t      *maptrack;
     unsigned int          maptrack_head;
+    unsigned int          map_count;
     /* Lock protecting updates to active and shared grant tables. */
     spinlock_t            lock;
 } grant_table_t;