ia64/xen-unstable

changeset 13414:2406531dae95

[MINIOS] Fix grant-entry freelist maintenance.
Signed-off-by: Jacob Gorm Hansen <jacobg@diku.dk>
author kfraser@localhost.localdomain
date Fri Jan 12 15:16:05 2007 +0000 (2007-01-12)
parents 1fc8fb8ea425
children 65a835dee3bc
files extras/mini-os/gnttab.c
line diff
     1.1 --- a/extras/mini-os/gnttab.c	Fri Jan 12 15:15:25 2007 +0000
     1.2 +++ b/extras/mini-os/gnttab.c	Fri Jan 12 15:16:05 2007 +0000
     1.3 @@ -23,39 +23,32 @@
     1.4  
     1.5  #define NR_GRANT_FRAMES 4
     1.6  #define NR_GRANT_ENTRIES (NR_GRANT_FRAMES * PAGE_SIZE / sizeof(grant_entry_t))
     1.7 -#define GNTTAB_LIST_END (NR_GRANT_ENTRIES + 1)
     1.8  
     1.9  static grant_entry_t *gnttab_table;
    1.10  static grant_ref_t gnttab_list[NR_GRANT_ENTRIES];
    1.11 -static grant_ref_t gnttab_free_head;
    1.12 +
    1.13 +static void
    1.14 +put_free_entry(grant_ref_t ref)
    1.15 +{
    1.16 +    gnttab_list[ref] = gnttab_list[0];
    1.17 +    gnttab_list[0]  = ref;
    1.18 +
    1.19 +}
    1.20  
    1.21  static grant_ref_t
    1.22 -get_free_entries(int count)
    1.23 +get_free_entry(void)
    1.24  {
    1.25 -    grant_ref_t ref;
    1.26 -    grant_ref_t head;
    1.27 -
    1.28 -    ref = head = gnttab_free_head;
    1.29 -    while (count-- > 1)
    1.30 -	head = gnttab_list[head];
    1.31 -    gnttab_free_head = gnttab_list[head];
    1.32 -    gnttab_list[head] = GNTTAB_LIST_END;
    1.33 +    unsigned int ref = gnttab_list[0];
    1.34 +    gnttab_list[0] = gnttab_list[ref];
    1.35      return ref;
    1.36  }
    1.37  
    1.38 -static void
    1.39 -put_free_entry(grant_ref_t gref)
    1.40 -{
    1.41 -    gnttab_list[gref] = gnttab_free_head;
    1.42 -    gnttab_free_head = gref;
    1.43 -}
    1.44 -
    1.45  grant_ref_t
    1.46  gnttab_grant_access(domid_t domid, unsigned long frame, int readonly)
    1.47  {
    1.48      grant_ref_t ref;
    1.49  
    1.50 -    ref = get_free_entries(1);
    1.51 +    ref = get_free_entry();
    1.52      gnttab_table[ref].frame = frame;
    1.53      gnttab_table[ref].domid = domid;
    1.54      wmb();
    1.55 @@ -70,7 +63,7 @@ gnttab_grant_transfer(domid_t domid, uns
    1.56  {
    1.57      grant_ref_t ref;
    1.58  
    1.59 -    ref = get_free_entries(1);
    1.60 +    ref = get_free_entry();
    1.61      gnttab_table[ref].frame = pfn;
    1.62      gnttab_table[ref].domid = domid;
    1.63      wmb();
    1.64 @@ -157,8 +150,7 @@ init_gnttab(void)
    1.65      int i;
    1.66  
    1.67      for (i = NR_RESERVED_ENTRIES; i < NR_GRANT_ENTRIES; i++)
    1.68 -	gnttab_list[i] = i + 1;
    1.69 -    gnttab_free_head = NR_RESERVED_ENTRIES;
    1.70 +        put_free_entry(i);
    1.71  
    1.72      setup.dom = DOMID_SELF;
    1.73      setup.nr_frames = NR_GRANT_FRAMES;