ia64/xen-unstable

changeset 106:0ce34da1b61d

bitkeeper revision 1.15.3.1 (3e3797e9gMcow8ShTTrYuWSeSSe-BA)

protect free_list with a spin lock.
author akw27@boulderdash.cl.cam.ac.uk
date Wed Jan 29 08:59:21 2003 +0000 (2003-01-29)
parents 540e4f4c8e38
children 91f5e18965d9
files xen-2.4.16/common/domain.c xen-2.4.16/common/memory.c xen-2.4.16/include/xeno/mm.h
line diff
     1.1 --- a/xen-2.4.16/common/domain.c	Mon Jan 27 12:05:24 2003 +0000
     1.2 +++ b/xen-2.4.16/common/domain.c	Wed Jan 29 08:59:21 2003 +0000
     1.3 @@ -334,10 +334,13 @@ static unsigned int alloc_new_dom_mem(st
     1.4      struct pfn_info *pf, *pf_head;
     1.5      unsigned int alloc_pfns;
     1.6      unsigned int req_pages;
     1.7 +    unsigned long flags;
     1.8  
     1.9      /* how many pages do we need to alloc? */
    1.10      req_pages = kbytes >> (PAGE_SHIFT - 10);
    1.11  
    1.12 +    spin_lock_irqsave(&free_list_lock, flags);
    1.13 +    
    1.14      /* is there enough mem to serve the request? */   
    1.15      if(req_pages > free_pfns)
    1.16          return -1;
    1.17 @@ -369,6 +372,8 @@ static unsigned int alloc_new_dom_mem(st
    1.18  
    1.19          free_pfns--;
    1.20      }
    1.21 +   
    1.22 +    spin_unlock_irqrestore(&free_list_lock, flags);
    1.23      
    1.24      p->tot_pages = req_pages;
    1.25  
     2.1 --- a/xen-2.4.16/common/memory.c	Mon Jan 27 12:05:24 2003 +0000
     2.2 +++ b/xen-2.4.16/common/memory.c	Wed Jan 29 08:59:21 2003 +0000
     2.3 @@ -206,6 +206,7 @@ unsigned long frame_table_size;
     2.4  unsigned long max_page;
     2.5  
     2.6  struct list_head free_list;
     2.7 +spinlock_t free_list_lock = SPIN_LOCK_UNLOCKED;
     2.8  unsigned int free_pfns;
     2.9  
    2.10  static int tlb_flush[NR_CPUS];
    2.11 @@ -219,6 +220,7 @@ void __init init_frametable(unsigned lon
    2.12  {
    2.13      struct pfn_info *pf;
    2.14      unsigned long page_index;
    2.15 +    unsigned long flags;
    2.16  
    2.17      memset(tlb_flush, 0, sizeof(tlb_flush));
    2.18  
    2.19 @@ -232,6 +234,7 @@ void __init init_frametable(unsigned lon
    2.20      memset(frame_table, 0, frame_table_size);
    2.21  
    2.22      /* Put all domain-allocatable memory on a free list. */
    2.23 +    spin_lock_irqsave(&free_list_lock, flags);
    2.24      INIT_LIST_HEAD(&free_list);
    2.25      for( page_index = (MAX_MONITOR_ADDRESS + frame_table_size) >> PAGE_SHIFT; 
    2.26           page_index < nr_pages; 
    2.27 @@ -240,6 +243,7 @@ void __init init_frametable(unsigned lon
    2.28          pf = list_entry(&frame_table[page_index].list, struct pfn_info, list);
    2.29          list_add_tail(&pf->list, &free_list);
    2.30      }
    2.31 +    spin_unlock_irqrestore(&free_list_lock, flags);
    2.32  }
    2.33  
    2.34  
     3.1 --- a/xen-2.4.16/include/xeno/mm.h	Mon Jan 27 12:05:24 2003 +0000
     3.2 +++ b/xen-2.4.16/include/xeno/mm.h	Wed Jan 29 08:59:21 2003 +0000
     3.3 @@ -7,6 +7,7 @@
     3.4  #include <asm/desc.h>
     3.5  #include <xeno/list.h>
     3.6  #include <hypervisor-ifs/hypervisor-if.h>
     3.7 +#include <xeno/spinlock.h>
     3.8  
     3.9  /* XXX KAF: These may die eventually, but so many refs in slab.c :((( */
    3.10  
    3.11 @@ -110,6 +111,7 @@ typedef struct pfn_info {
    3.12  extern frame_table_t * frame_table;
    3.13  extern unsigned long frame_table_size;
    3.14  extern struct list_head free_list;
    3.15 +extern spinlock_t free_list_lock;
    3.16  extern unsigned int free_pfns;
    3.17  extern unsigned long max_page;
    3.18  void init_frametable(unsigned long nr_pages);