[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Xen-changelog] switch back to Xen memory allocator code



ChangeSet 1.1311.1.32, 2005/03/23 15:27:37-07:00, djm@djmnc4000.(none)

        switch back to Xen memory allocator code



 arch/ia64/Makefile                      |   19 +-
 arch/ia64/domain.c                      |   26 +-
 arch/ia64/irq.c                         |    9 -
 arch/ia64/mm_init.c                     |  217 ------------------------
 arch/ia64/patch/linux-2.6.7/mm_contig.c |  208 +++++++++++++++++------
 arch/ia64/patch/linux-2.6.7/page.h      |   26 ++
 arch/ia64/patch/linux-2.6.7/pgalloc.h   |   54 ++++++
 arch/ia64/patch/linux-2.6.7/setup.c     |   87 +++++++--
 arch/ia64/patch/linux-2.6.7/swiotlb.c   |   37 ++++
 arch/ia64/smp.c                         |   11 -
 arch/ia64/tools/mkbuildtree             |   12 -
 arch/ia64/vhpt.c                        |    9 -
 arch/ia64/xenmisc.c                     |   21 --
 arch/ia64/xensetup.c                    |  280 +++++++++++---------------------
 common/Makefile                         |    4 
 include/asm-ia64/config.h               |   22 --
 include/asm-ia64/domain_page.h          |   14 +
 include/asm-ia64/flushtlb.h             |   13 +
 include/asm-ia64/mm.h                   |   63 ++++---
 19 files changed, 563 insertions(+), 569 deletions(-)


diff -Nru a/xen/arch/ia64/Makefile b/xen/arch/ia64/Makefile
--- a/xen/arch/ia64/Makefile    2005-03-25 19:04:47 -05:00
+++ b/xen/arch/ia64/Makefile    2005-03-25 19:04:47 -05:00
@@ -6,7 +6,7 @@
        xenmisc.o pdb-stub.o acpi.o hypercall.o \
        machvec.o dom0_ops.o domain.o \
        idle0_task.o pal.o hpsim.o efi.o efi_stub.o ivt.o mm_contig.o \
-       mm_bootmem.o sal.o cmdline.o mm_init.o tlb.o page_alloc.o slab.o \
+       sal.o cmdline.o mm_init.o tlb.o \
        extable.o linuxextable.o \
        regionreg.o entry.o unaligned.o privop.o vcpu.o \
        irq_ia64.o irq_lsapic.o hpsim_irq.o vhpt.o xenasm.o dom_fw.o
@@ -32,9 +32,22 @@
        $(OBJCOPY) -R .note -R .comment -S $(TARGET)-syms $(TARGET)
 #      $(BASEDIR)/tools/elf-reloc $(MONITOR_BASE) $(LOAD_BASE) $(TARGET)
 
-asm-offsets.s: asm-offsets.c
+asm-offsets.s: asm-offsets.c $(BASEDIR)/include/asm-ia64/.offsets.h.stamp
        $(CC) $(CFLAGS) -S -o $@ $<
 
+$(BASEDIR)/include/asm-ia64/.offsets.h.stamp:
+# Need such symbol link to make linux headers available
+       [ -e $(BASEDIR)/include/linux ] \
+        || ln -s $(BASEDIR)/include/xen $(BASEDIR)/include/linux
+       [ -e $(BASEDIR)/include/asm-ia64/xen ] \
+        || ln -s $(BASEDIR)/include/asm-ia64/linux 
$(BASEDIR)/include/asm-ia64/xen
+# Solve circular reference on asm-offsets.h
+       [ -f $(BASEDIR)/include/asm-ia64/asm-offsets.h ] \
+        || echo "#define IA64_TASK_SIZE 0" > 
$(BASEDIR)/include/asm-ia64/asm-offsets.h
+#Bad hack. Force asm-offsets.h out-of-date
+        sleep 1
+        touch $@
+
 # I'm sure a Makefile wizard would know a better way to do this
 xen.lds.s: xen.lds.S
        $(CC) -E $(CPPFLAGS) -P -DXEN -D__ASSEMBLY__ \
@@ -44,7 +57,7 @@
        $(MAKE) -C lib && cp lib/ia64lib.o .
 
 clean:
-       rm -f *.o *~ core  xen.lds.s
+       rm -f *.o *~ core  xen.lds.s 
$(BASEDIR)/include/asm-ia64/.offsets.h.stamp
        $(MAKE) -C lib clean
 
 # setup.o contains bits of compile.h so it must be blown away
diff -Nru a/xen/arch/ia64/domain.c b/xen/arch/ia64/domain.c
--- a/xen/arch/ia64/domain.c    2005-03-25 19:04:47 -05:00
+++ b/xen/arch/ia64/domain.c    2005-03-25 19:04:47 -05:00
@@ -39,8 +39,6 @@
 //FIXME: alignment should be 256MB, lest Linux use a 256MB page size
 unsigned long dom0_align = 64*1024*1024;
 
-extern kmem_cache_t *domain_struct_cachep;
-
 // initialized by arch/ia64/setup.c:find_initrd()
 unsigned long initrd_start = 0, initrd_end = 0;
 
@@ -136,22 +134,24 @@
 
 struct domain *arch_alloc_domain_struct(void)
 {
-       return xmem_cache_alloc(domain_struct_cachep);
+       return xmalloc(struct domain);
 }
 
 void arch_free_domain_struct(struct domain *d)
 {
-       xmem_cache_free(domain_struct_cachep,d);
+       xfree(d);
 }
 
 struct exec_domain *arch_alloc_exec_domain_struct(void)
 {
-       return alloc_task_struct();
+       /* Per-vp stack is used here. So we need keep exec_domain
+        * same page as per-vp stack */
+       return alloc_xenheap_pages(KERNEL_STACK_SIZE_ORDER);
 }
 
 void arch_free_exec_domain_struct(struct exec_domain *ed)
 {
-       free_task_struct(ed);
+       free_xenheap_pages(ed, KERNEL_STACK_SIZE_ORDER);
 }
 
 void arch_do_createdomain(struct exec_domain *ed)
@@ -307,7 +307,7 @@
                if (d == dom0) p = map_new_domain0_page(mpaddr);
                else
 #endif
-                       p = alloc_page(GFP_KERNEL);
+                       p = alloc_domheap_page(d);
                if (unlikely(!p)) {
 printf("map_new_domain_page: Can't alloc!!!! Aaaargh!\n");
                        return(p);
@@ -509,7 +509,13 @@
        dom0_size = 128*1024*1024; //FIXME: Should be configurable
        }
        printf("alloc_dom0: starting (initializing %d 
MB...)\n",dom0_size/(1024*1024));
-       dom0_start = 
__alloc_bootmem(dom0_size,dom0_align,__pa(MAX_DMA_ADDRESS));
+ 
+     /* FIXME: The first trunk (say 256M) should always be assigned to
+      * Dom0, since Dom0's physical == machine address for DMA purpose.
+      * Some old version linux, like 2.4, assumes physical memory existing
+      * in 2nd 64M space.
+      */
+     dom0_start = alloc_boot_pages(dom0_size,dom0_align);
        if (!dom0_start) {
        printf("construct_dom0: can't allocate contiguous memory size=%p\n",
                dom0_size);
@@ -611,7 +617,7 @@
 
        // prepare domain0 pagetable (maps METAphysical to physical)
        // following is roughly mm_init() in linux/kernel/fork.c
-       d->arch.mm = kmem_cache_alloc(mm_cachep, SLAB_KERNEL);
+       d->arch.mm = xmalloc(struct mm_struct);
        if (unlikely(!d->arch.mm)) {
                printk("Can't allocate mm_struct for domain0\n");
                return -ENOMEM;
@@ -721,7 +727,7 @@
        printk("parsedomainelfimage returns %d\n",rc);
        if ( rc != 0 ) return rc;
 
-       d->arch.mm = kmem_cache_alloc(mm_cachep, SLAB_KERNEL);
+       d->arch.mm = xmalloc(struct mm_struct);
        if (unlikely(!d->arch.mm)) {
                printk("Can't allocate mm_struct for domain %d\n",d->id);
                return -ENOMEM;
diff -Nru a/xen/arch/ia64/irq.c b/xen/arch/ia64/irq.c
--- a/xen/arch/ia64/irq.c       2005-03-25 19:04:47 -05:00
+++ b/xen/arch/ia64/irq.c       2005-03-25 19:04:47 -05:00
@@ -649,8 +649,7 @@
        if (!handler)
                return -EINVAL;
 
-       action = (struct irqaction *)
-                       kmalloc(sizeof(struct irqaction), GFP_ATOMIC);
+       action = xmalloc(struct irqaction);
        if (!action)
                return -ENOMEM;
 
@@ -667,7 +666,7 @@
 
        retval = setup_irq(irq, action);
        if (retval)
-               kfree(action);
+               xfree(action);
        return retval;
 }
 
@@ -730,7 +729,7 @@
 
                        /* Wait to make sure it's not being used on another CPU 
*/
                        synchronize_irq(irq);
-                       kfree(action);
+                       xfree(action);
                        return;
                }
                printk(KERN_ERR "Trying to free free IRQ%d\n",irq);
@@ -1389,7 +1388,7 @@
             goto out;
         }
 
-        action = xmalloc(sizeof(irq_guest_action_t));
+        action = xmalloc(irq_guest_action_t);
         if ( (desc->action = (struct irqaction *)action) == NULL )
         {
             DPRINTK("Cannot bind IRQ %d to guest. Out of memory.\n", irq);
diff -Nru a/xen/arch/ia64/mm_init.c b/xen/arch/ia64/mm_init.c
--- a/xen/arch/ia64/mm_init.c   2005-03-25 19:04:47 -05:00
+++ b/xen/arch/ia64/mm_init.c   2005-03-25 19:04:47 -05:00
@@ -163,24 +163,6 @@
 #endif /* XEN */
 
 void
-check_pgt_cache (void)
-{
-       int low, high;
-
-       low = pgt_cache_water[0];
-       high = pgt_cache_water[1];
-
-       if (pgtable_cache_size > (u64) high) {
-               do {
-                       if (pgd_quicklist)
-                               free_page((unsigned long)pgd_alloc_one_fast(0));
-                       if (pmd_quicklist)
-                               free_page((unsigned long)pmd_alloc_one_fast(0, 
0));
-               } while (pgtable_cache_size > (u64) low);
-       }
-}
-
-void
 update_mmu_cache (struct vm_area_struct *vma, unsigned long vaddr, pte_t pte)
 {
        unsigned long addr;
@@ -261,132 +243,9 @@
 #endif
 }
 
-void
-free_initmem (void)
-{
-       unsigned long addr, eaddr;
-
-       addr = (unsigned long) ia64_imva(__init_begin);
-       eaddr = (unsigned long) ia64_imva(__init_end);
-       while (addr < eaddr) {
-               ClearPageReserved(virt_to_page(addr));
-               set_page_count(virt_to_page(addr), 1);
-               free_page(addr);
-               ++totalram_pages;
-               addr += PAGE_SIZE;
-       }
-       printk(KERN_INFO "Freeing unused kernel memory: %ldkB freed\n",
-              (__init_end - __init_begin) >> 10);
-}
-
-void
-free_initrd_mem (unsigned long start, unsigned long end)
-{
-       struct page *page;
-       /*
-        * EFI uses 4KB pages while the kernel can use 4KB  or bigger.
-        * Thus EFI and the kernel may have different page sizes. It is
-        * therefore possible to have the initrd share the same page as
-        * the end of the kernel (given current setup).
-        *
-        * To avoid freeing/using the wrong page (kernel sized) we:
-        *      - align up the beginning of initrd
-        *      - align down the end of initrd
-        *
-        *  |             |
-        *  |=============| a000
-        *  |             |
-        *  |             |
-        *  |             | 9000
-        *  |/////////////|
-        *  |/////////////|
-        *  |=============| 8000
-        *  |///INITRD////|
-        *  |/////////////|
-        *  |/////////////| 7000
-        *  |             |
-        *  |KKKKKKKKKKKKK|
-        *  |=============| 6000
-        *  |KKKKKKKKKKKKK|
-        *  |KKKKKKKKKKKKK|
-        *  K=kernel using 8KB pages
-        *


-------------------------------------------------------
SF email is sponsored by - The IT Product Guide
Read honest & candid reviews on hundreds of IT Products from real users.
Discover which products truly live up to the hype. Start reading now.
http://ads.osdn.com/?ad_id=6595&alloc_id=14396&op=click
_______________________________________________
Xen-changelog mailing list
Xen-changelog@xxxxxxxxxxxxxxxxxxxxx
https://lists.sourceforge.net/lists/listinfo/xen-changelog


 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.