ia64/xen-unstable

changeset 117:659cfa9656db

bitkeeper revision 1.22.1.4 (3e3fcb0abWl_8ZV_bqeQT5nG7bJXAw)

get_unmapped_area.c, mm.h, memory.c, domain.c, dom0_ops.c:
Reduced size of 'struct pfn_info'. Domain frame list is now threaded through a list_head.
author kaf24@labyrinth.cl.cam.ac.uk
date Tue Feb 04 14:15:38 2003 +0000 (2003-02-04)
parents c2ff58fce197
children 73643659824d
files xen-2.4.16/common/dom0_ops.c xen-2.4.16/common/domain.c xen-2.4.16/common/memory.c xen-2.4.16/include/xeno/mm.h xenolinux-2.4.16-sparse/arch/xeno/mm/get_unmapped_area.c
line diff
     1.1 --- a/xen-2.4.16/common/dom0_ops.c	Tue Feb 04 13:35:50 2003 +0000
     1.2 +++ b/xen-2.4.16/common/dom0_ops.c	Tue Feb 04 14:15:38 2003 +0000
     1.3 @@ -35,21 +35,24 @@ static void build_page_list(struct task_
     1.4      unsigned long * list;
     1.5      unsigned long curr;
     1.6      unsigned long page;
     1.7 +    struct list_head *list_ent;
     1.8  
     1.9      list = (unsigned long *)map_domain_mem(p->pg_head << PAGE_SHIFT);
    1.10 -    curr = p->pg_head;
    1.11 -    *list++ = p->pg_head;
    1.12 -    page = (frame_table + p->pg_head)->next;
    1.13 -    while(page != p->pg_head){
    1.14 -        if(!((unsigned long)list & (PAGE_SIZE-1))){
    1.15 -            curr = (frame_table + curr)->next;
    1.16 -            unmap_domain_mem((unsigned long)(list-1) & PAGE_MASK);
    1.17 +    curr = page = p->pg_head;
    1.18 +    do {
    1.19 +        *list++ = page;
    1.20 +        list_ent = frame_table[page].list.next;
    1.21 +        page = list_entry(list_ent, struct pfn_info, list) - frame_table;
    1.22 +        if( !((unsigned long)list & (PAGE_SIZE-1)) )
    1.23 +        {
    1.24 +            list_ent = frame_table[curr].list.next;
    1.25 +            curr = list_entry(list_ent, struct pfn_info, list) - frame_table;
    1.26 +            unmap_domain_mem(list-1);
    1.27              list = (unsigned long *)map_domain_mem(curr << PAGE_SHIFT);
    1.28          }
    1.29 -        *list++ = page;
    1.30 -        page = (frame_table + page)->next;
    1.31      }
    1.32 -    unmap_domain_mem((unsigned long)(list-1) & PAGE_MASK);
    1.33 +    while ( page != p->pg_head );
    1.34 +    unmap_domain_mem(list);
    1.35  }
    1.36      
    1.37  long do_dom0_op(dom0_op_t *u_dom0_op)
    1.38 @@ -147,12 +150,14 @@ long do_dom0_op(dom0_op_t *u_dom0_op)
    1.39          int i;
    1.40          unsigned long pfn = op.u.getmemlist.start_pfn;
    1.41          unsigned long *buffer = op.u.getmemlist.buffer;
    1.42 +        struct list_head *list_ent;
    1.43  
    1.44          for ( i = 0; i < op.u.getmemlist.num_pfns; i++ )
    1.45          {
    1.46              /* XXX We trust DOM0 to give us a safe buffer. XXX */
    1.47              *buffer++ = pfn;
    1.48 -            pfn = (frame_table + pfn)->next;
    1.49 +            list_ent = frame_table[pfn].list.next;
    1.50 +            pfn = list_entry(list_ent, struct pfn_info, list) - frame_table;
    1.51          }
    1.52      }
    1.53      break;
     2.1 --- a/xen-2.4.16/common/domain.c	Tue Feb 04 13:35:50 2003 +0000
     2.2 +++ b/xen-2.4.16/common/domain.c	Tue Feb 04 14:15:38 2003 +0000
     2.3 @@ -356,26 +356,24 @@ unsigned int alloc_new_dom_mem(struct ta
     2.4      temp = free_list.next;
     2.5  
     2.6      /* allocate first page */
     2.7 -    pf = list_entry(temp, struct pfn_info, list);
     2.8 +    pf = pf_head = list_entry(temp, struct pfn_info, list);
     2.9      pf->flags |= p->domain;
    2.10      temp = temp->next;
    2.11      list_del(&pf->list);
    2.12 -    pf->next = pf->prev = p->pg_head = (pf - frame_table);
    2.13 +    INIT_LIST_HEAD(&pf->list);
    2.14 +    p->pg_head = pf - frame_table;
    2.15      pf->type_count = pf->tot_count = 0;
    2.16      free_pfns--;
    2.17 -    pf_head = pf;
    2.18  
    2.19      /* allocate the rest */
    2.20 -    for(alloc_pfns = req_pages - 1; alloc_pfns; alloc_pfns--){
    2.21 +    for ( alloc_pfns = req_pages - 1; alloc_pfns; alloc_pfns-- )
    2.22 +    {
    2.23          pf = list_entry(temp, struct pfn_info, list);
    2.24          pf->flags |= p->domain;
    2.25          temp = temp->next;
    2.26          list_del(&pf->list);
    2.27  
    2.28 -        pf->next = p->pg_head;
    2.29 -        pf->prev = pf_head->prev;
    2.30 -        (frame_table + pf_head->prev)->next = (pf - frame_table);
    2.31 -        pf_head->prev = (pf - frame_table);
    2.32 +        list_add_tail(&pf->list, &pf_head->list);
    2.33          pf->type_count = pf->tot_count = 0;
    2.34  
    2.35          free_pfns--;
    2.36 @@ -406,6 +404,7 @@ unsigned int alloc_new_dom_mem(struct ta
    2.37  
    2.38  int final_setup_guestos(struct task_struct * p, dom_meminfo_t * meminfo)
    2.39  {
    2.40 +    struct list_head *list_ent;
    2.41      l2_pgentry_t * l2tab;
    2.42      l1_pgentry_t * l1tab;
    2.43      start_info_t * virt_startinfo_addr;
    2.44 @@ -428,10 +427,12 @@ int final_setup_guestos(struct task_stru
    2.45          do_process_page_updates_bh(pgt_updates, 1);
    2.46          pgt_updates++;
    2.47          if(!((unsigned long)pgt_updates & (PAGE_SIZE-1))){
    2.48 -            unmap_domain_mem((void *)((unsigned long)(pgt_updates-1) & PAGE_MASK));
    2.49 -            curr_update_phys = (frame_table + (curr_update_phys >> PAGE_SHIFT))->next 
    2.50 -                << PAGE_SHIFT;
    2.51 -            pgt_updates = (page_update_request_t *)map_domain_mem(curr_update_phys);
    2.52 +            unmap_domain_mem(pgt_updates-1);
    2.53 +            list_ent = frame_table[curr_update_phys >> PAGE_SHIFT].list.next;
    2.54 +            curr_update_phys = list_entry(list_ent, struct pfn_info, list) -
    2.55 +                frame_table;
    2.56 +            curr_update_phys <<= PAGE_SHIFT;
    2.57 +            pgt_updates = map_domain_mem(curr_update_phys);
    2.58          }
    2.59      }
    2.60      unmap_domain_mem((void *)((unsigned long)(pgt_updates-1) & PAGE_MASK));
    2.61 @@ -549,7 +550,9 @@ int final_setup_guestos(struct task_stru
    2.62  static unsigned long alloc_page_from_domain(unsigned long * cur_addr, 
    2.63      unsigned long * index)
    2.64  {
    2.65 -    *cur_addr = (frame_table + (*cur_addr >> PAGE_SHIFT))->prev << PAGE_SHIFT;
    2.66 +    struct list_head *ent = frame_table[*cur_addr >> PAGE_SHIFT].list.prev;
    2.67 +    *cur_addr = list_entry(ent, struct pfn_info, list) - frame_table;
    2.68 +    *cur_addr <<= PAGE_SHIFT;
    2.69      (*index)--;    
    2.70      return *cur_addr;
    2.71  }
    2.72 @@ -559,6 +562,7 @@ static unsigned long alloc_page_from_dom
    2.73   */
    2.74  int setup_guestos(struct task_struct *p, dom0_newdomain_t *params)
    2.75  {
    2.76 +    struct list_head *list_ent;
    2.77      char *src, *dst;
    2.78      int i, dom = p->domain;
    2.79      unsigned long phys_l1tab, phys_l2tab;
    2.80 @@ -653,7 +657,10 @@ int setup_guestos(struct task_struct *p,
    2.81              machine_to_phys_mapping[cur_address >> PAGE_SHIFT] = count;
    2.82          }
    2.83  
    2.84 -        cur_address = ((frame_table + (cur_address >> PAGE_SHIFT))->next) << PAGE_SHIFT;
    2.85 +        list_ent = frame_table[cur_address >> PAGE_SHIFT].list.next;
    2.86 +        cur_address = list_entry(list_ent, struct pfn_info, list) -
    2.87 +            frame_table;
    2.88 +        cur_address <<= PAGE_SHIFT;
    2.89      }
    2.90      unmap_domain_mem(l1start);
    2.91  
    2.92 @@ -661,7 +668,10 @@ int setup_guestos(struct task_struct *p,
    2.93      cur_address = p->pg_head << PAGE_SHIFT;
    2.94      for ( count = 0; count < alloc_index; count++ ) 
    2.95      {
    2.96 -        cur_address = ((frame_table + (cur_address >> PAGE_SHIFT))->next) << PAGE_SHIFT;
    2.97 +        list_ent = frame_table[cur_address >> PAGE_SHIFT].list.next;
    2.98 +        cur_address = list_entry(list_ent, struct pfn_info, list) -
    2.99 +            frame_table;
   2.100 +        cur_address <<= PAGE_SHIFT;
   2.101      }
   2.102  
   2.103      l2tab = l2start + l2_table_offset(virt_load_address + 
   2.104 @@ -682,7 +692,10 @@ int setup_guestos(struct task_struct *p,
   2.105          page->flags = dom | PGT_l1_page_table;
   2.106          page->tot_count++;
   2.107          
   2.108 -        cur_address = ((frame_table + (cur_address >> PAGE_SHIFT))->next) << PAGE_SHIFT;
   2.109 +        list_ent = frame_table[cur_address >> PAGE_SHIFT].list.next;
   2.110 +        cur_address = list_entry(list_ent, struct pfn_info, list) -
   2.111 +            frame_table;
   2.112 +        cur_address <<= PAGE_SHIFT;
   2.113      }
   2.114      page->flags = dom | PGT_l2_page_table;
   2.115      unmap_domain_mem(l1start);
     3.1 --- a/xen-2.4.16/common/memory.c	Tue Feb 04 13:35:50 2003 +0000
     3.2 +++ b/xen-2.4.16/common/memory.c	Tue Feb 04 14:15:38 2003 +0000
     3.3 @@ -175,7 +175,7 @@
     3.4  #include <asm/uaccess.h>
     3.5  #include <asm/domain_page.h>
     3.6  
     3.7 -#if 1
     3.8 +#if 0
     3.9  #define MEM_LOG(_f, _a...) printk("DOM%d: (file=memory.c, line=%d) " _f "\n", current->domain, __LINE__, ## _a )
    3.10  #else
    3.11  #define MEM_LOG(_f, _a...) ((void)0)
     4.1 --- a/xen-2.4.16/include/xeno/mm.h	Tue Feb 04 13:35:50 2003 +0000
     4.2 +++ b/xen-2.4.16/include/xeno/mm.h	Tue Feb 04 14:15:38 2003 +0000
     4.3 @@ -56,8 +56,6 @@ void __free_pages(unsigned long p, int o
     4.4   */
     4.5  typedef struct pfn_info {
     4.6      struct list_head list;      /* ->mapping has some page lists. */
     4.7 -    unsigned long next;         /* used for threading pages belonging */
     4.8 -    unsigned long prev;         /* to same domain */
     4.9      unsigned long flags;        /* atomic flags. */
    4.10      unsigned long tot_count;    /* Total domain usage count. */
    4.11      unsigned long type_count;   /* pagetable/dir, or domain-writeable refs. */
     5.1 --- a/xenolinux-2.4.16-sparse/arch/xeno/mm/get_unmapped_area.c	Tue Feb 04 13:35:50 2003 +0000
     5.2 +++ b/xenolinux-2.4.16-sparse/arch/xeno/mm/get_unmapped_area.c	Tue Feb 04 14:15:38 2003 +0000
     5.3 @@ -56,11 +56,6 @@ unsigned long arch_get_unmapped_area(str
     5.4  		if (TASK_SIZE - len < addr)
     5.5  			return -ENOMEM;
     5.6          
     5.7 -		if(current->pid > 100){
     5.8 -		printk(KERN_ALERT "bd240 debug: gua: vm addr found %lx\n", addr);
     5.9 -			printk(KERN_ALERT "bd240 debug: gua: first condition %d, %lx, %lx\n",vma, addr + len, vma->vm_start);
    5.10 -			printk(KERN_ALERT "bd240 debug: gua: second condition %d\n", direct_mapped(addr));
    5.11 -		}
    5.12  		if ((!vma || addr + len <= vma->vm_start) && !direct_mapped(addr))
    5.13  			return addr;
    5.14  		
    5.15 @@ -77,10 +72,7 @@ struct list_head *find_direct(struct lis
    5.16      for ( curr = direct_list->next; curr != direct_list; curr = curr->next )
    5.17      {
    5.18          node = list_entry(curr, direct_mmap_node_t, list);
    5.19 -        if( node->vm_start >= addr ){
    5.20 -			printk(KERN_ALERT "bd240 debug: find_direct: hit %lx\n", node->vm_start); 
    5.21 -			break;
    5.22 -		}
    5.23 +        if ( node->vm_start >= addr ) break;
    5.24      }
    5.25  
    5.26      return curr;