ia64/xen-unstable

changeset 4065:68d9d54ac50f

bitkeeper revision 1.1236.1.73 (4230542aNzdikO2FdRgaB46eNiQNHw)

Maintain count of mappings, and fast exit put_page check if none in use
author cwc22@centipede.cl.cam.ac.uk
date Thu Mar 10 14:05:30 2005 +0000 (2005-03-10)
parents 3dafdc84f1a2
children fbad927100bc
files xen/common/grant_table.c xen/include/xen/grant_table.h
line diff
     1.1 --- a/xen/common/grant_table.c	Thu Mar 10 14:01:19 2005 +0000
     1.2 +++ b/xen/common/grant_table.c	Thu Mar 10 14:05:30 2005 +0000
     1.3 @@ -44,6 +44,7 @@ get_maptrack_handle(
     1.4      if ( unlikely((h = t->maptrack_head) == NR_MAPTRACK_ENTRIES) )
     1.5          return -1;
     1.6      t->maptrack_head = t->maptrack[h].ref_and_flags >> MAPTRACK_REF_SHIFT;
     1.7 +    t->map_count++;
     1.8      return h;
     1.9  }
    1.10  
    1.11 @@ -53,6 +54,7 @@ put_maptrack_handle(
    1.12  {
    1.13      t->maptrack[handle].ref_and_flags = t->maptrack_head << MAPTRACK_REF_SHIFT;
    1.14      t->maptrack_head = handle;
    1.15 +    t->map_count--;
    1.16  }
    1.17  
    1.18  static int
    1.19 @@ -529,7 +531,7 @@ gnttab_unmap_grant_ref(
    1.20      if ( flush == 1 )
    1.21          __flush_tlb_one(va);
    1.22  
    1.23 -    else if ( flush )
    1.24 +    else if ( flush != 0 )
    1.25          local_flush_tlb();
    1.26  
    1.27      return 0;
    1.28 @@ -734,12 +736,19 @@ gnttab_check_unmap(
    1.29      int found = 0;
    1.30  
    1.31      lgt = ld->grant_table;
    1.32 +
    1.33 +    /* Fast exit if we're not mapping anything using grant tables */
    1.34 +    if ( lgt->map_count == 0 )
    1.35 +        return 0;
    1.36 +
    1.37      rgt = rd->grant_table;
    1.38  
    1.39 +#ifdef GRANT_DEBUG
    1.40      if ( ld->id != 0 ) {
    1.41          DPRINTK("Foreign unref rd(%d) ld(%d) frm(%x) flgs(%x).\n",
    1.42                  rd->id, ld->id, frame, readonly);
    1.43      }
    1.44 +#endif
    1.45  
    1.46      for ( handle = 0; handle < NR_MAPTRACK_ENTRIES; handle++ )
    1.47      {
     2.1 --- a/xen/include/xen/grant_table.h	Thu Mar 10 14:01:19 2005 +0000
     2.2 +++ b/xen/include/xen/grant_table.h	Thu Mar 10 14:05:30 2005 +0000
     2.3 @@ -74,6 +74,7 @@ typedef struct {
     2.4      /* Mapping tracking table. */
     2.5      grant_mapping_t      *maptrack;
     2.6      unsigned int          maptrack_head;
     2.7 +    unsigned int          map_count;
     2.8      /* Lock protecting updates to active and shared grant tables. */
     2.9      spinlock_t            lock;
    2.10  } grant_table_t;