Skip to contentSkip to conversation

Xen 3.0 Status update

PATCH New Ian Pratt 2 participants 2 messages Jul 28, 2005 – Jul 29, 2005

lore
Share & tools
lore

Ian Pratt

author
#0 lore raw
Quoted 6 lines
Quoted 6 lines
Quoted 4 lines

I have a patch that introduces zones into xen, and a hypercall to request dmaable memory, which i've made xen_contig_memory() use.

The hypercall should probably pass in the 'order' of the

Quoted 8 lines

address limit

Quoted 2 lines

required for the allocation. There are a few stupid devices that require memory below 2GB etc (e.g. aacraid)

This is with the MEMOP_decrease_reservation hypercall, which is already using up all of its allotted arguments. Its been a while, but it didn't look like it was going to be real easy to raise the limit of 6 arguments on x86_32.

extent_order only needs to be a byte parameter, so it would be reasonable to have the next byte of the word be the addr_limit_order. (We might want a separate alignment order in future too).

Quoted 10 lines
Quoted 5 lines
Quoted 3 lines

Unfortunately, there still seems to be some places where kmallocs are done for dma buffers. (i tried putting all linux memory into ZONE_NORMAL and caught a couple of these places)

Can you give examples? What size are the allocations? Do

you know what

Quoted 1 line

the official position is i.e. is using kmalloc with

ZONE_DMA deprecated?

I have no idea about official positions of the linux kernel.

I guess its probably allowed for sub page allocations.

Hopefully the s/w iommu can take care of these at map time.

Ian

#1 lore raw

PATCH 1/1 give xen dma zones

Attached patch adds a DMA zone to xen, also modifies xen_contig_memory() to ask for DMA pages.

sRp

Quoted 36 lines · Ian Pratt
Quoted 5 lines
Quoted 5 lines
Quoted 3 lines

I have a patch that introduces zones into xen, and a hypercall to request dmaable memory, which i've made xen_contig_memory() use.

The hypercall should probably pass in the 'order' of the

Quoted 8 lines

address limit

Quoted 2 lines

required for the allocation. There are a few stupid devices that require memory below 2GB etc (e.g. aacraid)

This is with the MEMOP_decrease_reservation hypercall, which is already using up all of its allotted arguments. Its been a while, but it didn't look like it was going to be real easy to raise the limit of 6 arguments on x86_32.

extent_order only needs to be a byte parameter, so it would be reasonable to have the next byte of the word be the addr_limit_order. (We might want a separate alignment order in future too).

Quoted 10 lines
Quoted 5 lines
Quoted 3 lines

Unfortunately, there still seems to be some places where kmallocs are done for dma buffers. (i tried putting all linux memory into ZONE_NORMAL and caught a couple of these places)

Can you give examples? What size are the allocations? Do

you know what

Quoted 1 line

the official position is i.e. is using kmalloc with

ZONE_DMA deprecated?

I have no idea about official positions of the linux kernel.

I guess its probably allowed for sub page allocations.

Hopefully the s/w iommu can take care of these at map time.

Ian

Signature · 2 lines
Scott Parish
Signed-off-by: [email protected]
linux-2.6-xen-sparse/arch/xen/i386/mm/hypervisor.c +1 -1
diff -rN -u -p old-xen-64-dma-pure/linux-2.6-xen-sparse/arch/xen/i386/mm/hypervisor.c new-xen-64-dma-pure/linux-2.6-xen-sparse/arch/xen/i386/mm/hypervisor.c
@@ -296,7 +296,7 @@ void xen_contig_memory(unsigned long vst
 
     /* 2. Get a new contiguous memory extent. */
     BUG_ON(HYPERVISOR_dom_mem_op(
-        MEMOP_increase_reservation, &mfn, 1, order) != 1);
+	       MEMOP_increase_reservation, &mfn, 1, order | (32<<8)) != 1);
 
     /* 3. Map the new extent in place of old pages. */
     for (i = 0; i < (1<<order); i++) {
xen/arch/x86/domain_build.c +1 -1
diff -rN -u -p old-xen-64-dma-pure/xen/arch/x86/domain_build.c new-xen-64-dma-pure/xen/arch/x86/domain_build.c
@@ -63,7 +63,7 @@ static struct pfn_info *alloc_largest(st
     unsigned int order = get_order(max * PAGE_SIZE);
     if ( (max & (max-1)) != 0 )
         order--;
-    while ( (page = alloc_domheap_pages(d, order)) == NULL )
+    while ( (page = alloc_domheap_pages(d, order, 0)) == NULL )
         if ( order-- == 0 )
             break;
     return page;
xen/arch/x86/x86_32/mm.c +1 -1
diff -rN -u -p old-xen-64-dma-pure/xen/arch/x86/x86_32/mm.c new-xen-64-dma-pure/xen/arch/x86/x86_32/mm.c
@@ -102,7 +102,7 @@ void __init paging_init(void)
         mpt_size = 4*1024*1024;
     for ( i = 0; i < (mpt_size >> L2_PAGETABLE_SHIFT); i++ )
     {
-        if ( (pg = alloc_domheap_pages(NULL, PAGETABLE_ORDER)) == NULL )
+        if ( (pg = alloc_domheap_pages(NULL, PAGETABLE_ORDER, 0) == NULL )
             panic("Not enough memory to bootstrap Xen.\n");
         idle_pg_table_l2[l2_linear_offset(RDWR_MPT_VIRT_START) + i] =
             l2e_from_page(pg, PAGE_HYPERVISOR | _PAGE_PSE);
xen/arch/x86/x86_64/mm.c +1 -1
diff -rN -u -p old-xen-64-dma-pure/xen/arch/x86/x86_64/mm.c new-xen-64-dma-pure/xen/arch/x86/x86_64/mm.c
@@ -100,7 +100,7 @@ void __init paging_init(void)
      */
     for ( i = 0; i < max_page; i += ((1UL << L2_PAGETABLE_SHIFT) / 8) )
     {
-        pg = alloc_domheap_pages(NULL, PAGETABLE_ORDER);
+        pg = alloc_domheap_pages(NULL, PAGETABLE_ORDER, 0);
         if ( pg == NULL )
             panic("Not enough memory for m2p table\n");
         map_pages_to_xen(
xen/common/dom_mem_ops.c +11 -3
diff -rN -u -p old-xen-64-dma-pure/xen/common/dom_mem_ops.c new-xen-64-dma-pure/xen/common/dom_mem_ops.c
@@ -37,7 +37,8 @@ alloc_dom_mem(struct domain *d, 
               unsigned long *extent_list, 
               unsigned long  start_extent,
               unsigned int   nr_extents,
-              unsigned int   extent_order)
+              unsigned int   extent_order,
+    		  unsigned int   flags)
 {
     struct pfn_info *page;
     unsigned long    i;
@@ -56,7 +57,8 @@ alloc_dom_mem(struct domain *d, 
     {
         PREEMPT_CHECK(MEMOP_increase_reservation);
 
-        if ( unlikely((page = alloc_domheap_pages(d, extent_order)) == NULL) )
+        if ( unlikely((page = alloc_domheap_pages(d, extent_order,
+                                                  flags)) == NULL) )
         {
             DPRINTK("Could not allocate a frame\n");
             return i;
@@ -131,11 +133,16 @@ do_dom_mem_op(unsigned long  op, 
 {
     struct domain *d;
     unsigned long  rc, start_extent;
+    unsigned int   address_bits_order;
 
     /* Extract @start_extent from @op. */
     start_extent  = op >> START_EXTENT_SHIFT;
     op           &= (1 << START_EXTENT_SHIFT) - 1;
 
+    /* seperate extent_order and address_bits_order */
+    address_bits_order = (extent_order >> 1) & 0xff;
+    extent_order &= 0xff;
+
     if ( unlikely(start_extent > nr_extents) )
         return -EINVAL;
 
@@ -150,7 +157,8 @@ do_dom_mem_op(unsigned long  op, 
     {
     case MEMOP_increase_reservation:
         rc = alloc_dom_mem(
-            d, extent_list, start_extent, nr_extents, extent_order);
+            d, extent_list, start_extent, nr_extents, extent_order,
+            (address_bits_order <= 32) ? ALLOC_DOM_DMA : 0);
         break;
     case MEMOP_decrease_reservation:
         rc = free_dom_mem(
xen/common/page_alloc.c +31 -13

102 lines not on this page · raw message

xen/include/xen/mm.h +5 -2
diff -rN -u -p old-xen-64-dma-pure/xen/include/xen/mm.h new-xen-64-dma-pure/xen/include/xen/mm.h
@@ -33,12 +33,15 @@ void free_xenheap_pages(void *v, unsigne
 
 /* Domain suballocator. These functions are *not* interrupt-safe.*/
 void init_domheap_pages(physaddr_t ps, physaddr_t pe);
-struct pfn_info *alloc_domheap_pages(struct domain *d, unsigned int order);
+struct pfn_info *alloc_domheap_pages(
+    struct domain *d, unsigned int order, unsigned int flags);
 void free_domheap_pages(struct pfn_info *pg, unsigned int order);
 unsigned long avail_domheap_pages(void);
-#define alloc_domheap_page(d) (alloc_domheap_pages(d,0))
+#define alloc_domheap_page(d) (alloc_domheap_pages(d,0,0))
 #define free_domheap_page(p)  (free_domheap_pages(p,0))
 
+#define ALLOC_DOM_DMA 1
+
 /* Automatic page scrubbing for dead domains. */
 extern struct list_head page_scrub_list;
 #define page_scrub_schedule_work()              \

_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xensource.com/xen-devel