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

[Xen-changelog] I/O rings may now be dynamically sized: instead of declaring size



ChangeSet 1.1425, 2005/04/01 17:31:40+01:00, kaf24@xxxxxxxxxxxxxxxxxxxx

        I/O rings may now be dynamically sized: instead of declaring size
        at struct definition time, declare it in FRONT/BACK_RING_INIT().
        Signed-off-by: Keir Fraser <keir@xxxxxxxxxxxxx>



 freebsd-5.3-xen-sparse/i386-xen/i386-xen/ctrl_if.c             |    8 -
 freebsd-5.3-xen-sparse/i386-xen/xen/blkfront/xb_blkfront.c     |   18 ++--
 linux-2.6.11-xen-sparse/arch/xen/kernel/ctrl_if.c              |    8 -
 linux-2.6.11-xen-sparse/drivers/xen/blkback/interface.c        |    2 
 linux-2.6.11-xen-sparse/drivers/xen/blkfront/blkfront.c        |   22 ++---
 linux-2.6.11-xen-sparse/drivers/xen/blktap/blktap_controlmsg.c |    4 
 linux-2.6.11-xen-sparse/drivers/xen/blktap/blktap_userdev.c    |    7 -
 linux-2.6.11-xen-sparse/drivers/xen/usbback/interface.c        |    2 
 linux-2.6.11-xen-sparse/drivers/xen/usbfront/usbfront.c        |    2 
 tools/blktap/blktaplib.c                                       |    6 -
 tools/xcs/ctrl_interface.c                                     |    4 
 xen/include/public/io/blkif.h                                  |    2 
 xen/include/public/io/domain_controller.h                      |   12 ++
 xen/include/public/io/ring.h                                   |   43 
+++++-----
 xen/include/public/io/usbif.h                                  |   38 ++++----
 15 files changed, 95 insertions(+), 83 deletions(-)


diff -Nru a/freebsd-5.3-xen-sparse/i386-xen/i386-xen/ctrl_if.c 
b/freebsd-5.3-xen-sparse/i386-xen/i386-xen/ctrl_if.c
--- a/freebsd-5.3-xen-sparse/i386-xen/i386-xen/ctrl_if.c        2005-04-01 
12:03:37 -05:00
+++ b/freebsd-5.3-xen-sparse/i386-xen/i386-xen/ctrl_if.c        2005-04-01 
12:03:37 -05:00
@@ -470,8 +470,8 @@
     
 
     /* Sync up with shared indexes. */
-    FRONT_RING_ATTACH(&ctrl_if_tx_ring, &ctrl_if->tx_ring);
-    BACK_RING_ATTACH(&ctrl_if_rx_ring, &ctrl_if->rx_ring);
+    FRONT_RING_ATTACH(&ctrl_if_tx_ring, &ctrl_if->tx_ring, CONTROL_RING_MEM);
+    BACK_RING_ATTACH(&ctrl_if_rx_ring, &ctrl_if->rx_ring, CONTROL_RING_MEM);
 
     ctrl_if_evtchn = xen_start_info->domain_controller_evtchn;
     ctrl_if_irq    = bind_evtchn_to_irq(ctrl_if_evtchn);
@@ -498,8 +498,8 @@
     for ( i = 0; i < 256; i++ )
         ctrl_if_rxmsg_handler[i] = ctrl_if_rxmsg_default_handler;
     
-    FRONT_RING_ATTACH(&ctrl_if_tx_ring, &ctrl_if->tx_ring);
-    BACK_RING_ATTACH(&ctrl_if_rx_ring, &ctrl_if->rx_ring);
+    FRONT_RING_ATTACH(&ctrl_if_tx_ring, &ctrl_if->tx_ring, CONTROL_RING_MEM);
+    BACK_RING_ATTACH(&ctrl_if_rx_ring, &ctrl_if->rx_ring, CONTROL_RING_MEM);
 
     mtx_init(&ctrl_if_lock, "ctrlif", NULL, MTX_SPIN | MTX_NOWITNESS);
     
diff -Nru a/freebsd-5.3-xen-sparse/i386-xen/xen/blkfront/xb_blkfront.c 
b/freebsd-5.3-xen-sparse/i386-xen/xen/blkfront/xb_blkfront.c
--- a/freebsd-5.3-xen-sparse/i386-xen/xen/blkfront/xb_blkfront.c        
2005-04-01 12:03:36 -05:00
+++ b/freebsd-5.3-xen-sparse/i386-xen/xen/blkfront/xb_blkfront.c        
2005-04-01 12:03:36 -05:00
@@ -102,8 +102,10 @@
 
 static blkif_front_ring_t   blk_ring;
 
+#define BLK_RING_SIZE __RING_SIZE((blkif_sring_t *)0, PAGE_SIZE)
+
 static unsigned long rec_ring_free;            
-blkif_request_t rec_ring[RING_SIZE(&blk_ring)];        /* shadow recovery ring 
*/
+blkif_request_t rec_ring[BLK_RING_SIZE];
 
 /* XXX move to xb_vbd.c when VBD update support is added */
 #define MAX_VBDS 64
@@ -133,7 +135,7 @@
 {
     unsigned long free = rec_ring_free;
 
-    KASSERT(free <= RING_SIZE(&blk_ring), ("free %lu > RING_SIZE", free));
+    KASSERT(free <= BLK_RING_SIZE, ("free %lu > RING_SIZE", free));
 
     rec_ring_free = rec_ring[free].id;
 
@@ -638,7 +640,7 @@
     if (blk_ring.sring) free(blk_ring.sring, M_DEVBUF);
     blk_ring.sring = (blkif_sring_t *)malloc(PAGE_SIZE, M_DEVBUF, M_WAITOK);
     SHARED_RING_INIT(blk_ring.sring);
-    FRONT_RING_INIT(&blk_ring, blk_ring.sring);
+    FRONT_RING_INIT(&blk_ring, blk_ring.sring, PAGE_SIZE);
     blkif_state  = BLKIF_STATE_DISCONNECTED;
     blkif_send_interface_connect();
 }
@@ -662,7 +664,7 @@
      * This will need to be fixed once we have barriers */
 
     /* Stage 1 : Find active and move to safety. */
-    for ( i = 0; i < RING_SIZE(&blk_ring); i++ ) {
+    for ( i = 0; i < BLK_RING_SIZE; i++ ) {
         if ( rec_ring[i].id >= KERNBASE ) {
            req = RING_GET_REQUEST(&blk_ring, 
                                    blk_ring.req_prod_pvt);
@@ -682,11 +684,11 @@
     }
 
     /* Stage 3 : Set up free list. */
-    for ( ; i < RING_SIZE(&blk_ring); i++ ){
+    for ( ; i < BLK_RING_SIZE; i++ ){
         rec_ring[i].id = i+1;
     }
     rec_ring_free = blk_ring.req_prod_pvt;
-    rec_ring[RING_SIZE(&blk_ring)-1].id = 0x0fffffff;
+    rec_ring[BLK_RING_SIZE-1].id = 0x0fffffff;
 
     /* blk_ring.req_prod will be set when we flush_requests().*/
     wmb();
@@ -874,10 +876,10 @@
     printk("[XEN] Initialising virtual block device driver\n");
 
     rec_ring_free = 0;
-    for (i = 0; i < RING_SIZE(&blk_ring); i++) {
+    for (i = 0; i < BLK_RING_SIZE; i++) {
        rec_ring[i].id = i+1;
     }
-    rec_ring[RING_SIZE(&blk_ring)-1].id = 0x0fffffff;
+    rec_ring[BLK_RING_SIZE-1].id = 0x0fffffff;
 
     (void)ctrl_if_register_receiver(CMSG_BLKIF_FE, blkif_ctrlif_rx, 0);
 
diff -Nru a/linux-2.6.11-xen-sparse/arch/xen/kernel/ctrl_if.c 
b/linux-2.6.11-xen-sparse/arch/xen/kernel/ctrl_if.c
--- a/linux-2.6.11-xen-sparse/arch/xen/kernel/ctrl_if.c 2005-04-01 12:03:37 
-05:00
+++ b/linux-2.6.11-xen-sparse/arch/xen/kernel/ctrl_if.c 2005-04-01 12:03:37 
-05:00
@@ -503,8 +503,8 @@
     }
 
     /* Sync up with shared indexes. */
-    FRONT_RING_ATTACH(&ctrl_if_tx_ring, &ctrl_if->tx_ring);
-    BACK_RING_ATTACH(&ctrl_if_rx_ring, &ctrl_if->rx_ring);
+    FRONT_RING_ATTACH(&ctrl_if_tx_ring, &ctrl_if->tx_ring, CONTROL_RING_MEM);
+    BACK_RING_ATTACH(&ctrl_if_rx_ring, &ctrl_if->rx_ring, CONTROL_RING_MEM);
 
     ctrl_if_evtchn = xen_start_info.domain_controller_evtchn;
     ctrl_if_irq    = bind_evtchn_to_irq(ctrl_if_evtchn);
@@ -523,8 +523,8 @@
     for ( i = 0; i < 256; i++ )
         ctrl_if_rxmsg_handler[i] = ctrl_if_rxmsg_default_handler;
 
-    FRONT_RING_ATTACH(&ctrl_if_tx_ring, &ctrl_if->tx_ring);
-    BACK_RING_ATTACH(&ctrl_if_rx_ring, &ctrl_if->rx_ring);
+    FRONT_RING_ATTACH(&ctrl_if_tx_ring, &ctrl_if->tx_ring, CONTROL_RING_MEM);
+    BACK_RING_ATTACH(&ctrl_if_rx_ring, &ctrl_if->rx_ring, CONTROL_RING_MEM);
     
     spin_lock_init(&ctrl_if_lock);
 
diff -Nru a/linux-2.6.11-xen-sparse/drivers/xen/blkback/interface.c 
b/linux-2.6.11-xen-sparse/drivers/xen/blkback/interface.c
--- a/linux-2.6.11-xen-sparse/drivers/xen/blkback/interface.c   2005-04-01 
12:03:36 -05:00
+++ b/linux-2.6.11-xen-sparse/drivers/xen/blkback/interface.c   2005-04-01 
12:03:36 -05:00
@@ -198,7 +198,7 @@
     }
     sring = (blkif_sring_t *)vma->addr;
     SHARED_RING_INIT(sring);
-    BACK_RING_INIT(&blkif->blk_ring, sring);
+    BACK_RING_INIT(&blkif->blk_ring, sring, PAGE_SIZE);
     
     blkif->evtchn        = evtchn;
     blkif->irq           = bind_evtchn_to_irq(evtchn);
diff -Nru a/linux-2.6.11-xen-sparse/drivers/xen/blkfront/blkfront.c 
b/linux-2.6.11-xen-sparse/drivers/xen/blkfront/blkfront.c
--- a/linux-2.6.11-xen-sparse/drivers/xen/blkfront/blkfront.c   2005-04-01 
12:03:36 -05:00
+++ b/linux-2.6.11-xen-sparse/drivers/xen/blkfront/blkfront.c   2005-04-01 
12:03:36 -05:00
@@ -74,8 +74,10 @@
 
 static blkif_front_ring_t blk_ring;
 
+#define BLK_RING_SIZE __RING_SIZE((blkif_sring_t *)0, PAGE_SIZE)
+
 unsigned long rec_ring_free;
-blkif_request_t rec_ring[RING_SIZE(&blk_ring)];
+blkif_request_t rec_ring[BLK_RING_SIZE];
 
 static int recovery = 0;           /* "Recovery in progress" flag.  Protected
                                     * by the blkif_io_lock */
@@ -90,8 +92,7 @@
 {
     unsigned long free = rec_ring_free;
 
-    if ( free > RING_SIZE(&blk_ring) )
-        BUG();
+    BUG_ON(free > BLK_RING_SIZE);
 
     rec_ring_free = rec_ring[free].id;
 
@@ -522,8 +523,7 @@
 {
     /* We kick pending request queues if the ring is reasonably empty. */
     if ( (nr_pending != 0) && 
-         (RING_PENDING_REQUESTS(&blk_ring) < 
-          (RING_SIZE(&blk_ring) >> 1)) )
+         (RING_PENDING_REQUESTS(&blk_ring) < (BLK_RING_SIZE >> 1)) )
     {
         /* Attempt to drain the queue, but bail if the ring becomes full. */
         while ( (nr_pending != 0) && !RING_FULL(&blk_ring) )
@@ -1138,7 +1138,7 @@
     
     sring = (blkif_sring_t *)__get_free_page(GFP_KERNEL);
     SHARED_RING_INIT(sring);
-    FRONT_RING_INIT(&blk_ring, sring);
+    FRONT_RING_INIT(&blk_ring, sring, PAGE_SIZE);
     blkif_state  = BLKIF_STATE_DISCONNECTED;
     blkif_send_interface_connect();
 }
@@ -1158,7 +1158,7 @@
      * This will need to be fixed once we have barriers */
 
     /* Stage 1 : Find active and move to safety. */
-    for ( i = 0; i < RING_SIZE(&blk_ring); i++ )
+    for ( i = 0; i < BLK_RING_SIZE; i++ )
     {
         if ( rec_ring[i].id >= PAGE_OFFSET )
         {
@@ -1179,10 +1179,10 @@
     }
 
     /* Stage 3 : Set up free list. */
-    for ( ; i < RING_SIZE(&blk_ring); i++ )
+    for ( ; i < BLK_RING_SIZE; i++ )
         rec_ring[i].id = i+1;
     rec_ring_free = blk_ring.req_prod_pvt;
-    rec_ring[RING_SIZE(&blk_ring)-1].id = 0x0fffffff;
+    rec_ring[BLK_RING_SIZE-1].id = 0x0fffffff;
 
     /* blk_ring->req_prod will be set when we flush_requests().*/
     wmb();
@@ -1369,9 +1369,9 @@
     printk(KERN_INFO "xen_blk: Initialising virtual block device driver\n");
 
     rec_ring_free = 0;
-    for ( i = 0; i < RING_SIZE(&blk_ring); i++ )
+    for ( i = 0; i < BLK_RING_SIZE; i++ )
         rec_ring[i].id = i+1;
-    rec_ring[RING_SIZE(&blk_ring)-1].id = 0x0fffffff;
+    rec_ring[BLK_RING_SIZE-1].id = 0x0fffffff;
 
     (void)ctrl_if_register_receiver(CMSG_BLKIF_FE, blkif_ctrlif_rx,
                                     CALLBACK_IN_BLOCKING_CONTEXT);
diff -Nru a/linux-2.6.11-xen-sparse/drivers/xen/blktap/blktap_controlmsg.c 
b/linux-2.6.11-xen-sparse/drivers/xen/blktap/blktap_controlmsg.c
--- a/linux-2.6.11-xen-sparse/drivers/xen/blktap/blktap_controlmsg.c    
2005-04-01 12:03:36 -05:00
+++ b/linux-2.6.11-xen-sparse/drivers/xen/blktap/blktap_controlmsg.c    
2005-04-01 12:03:36 -05:00
@@ -229,7 +229,7 @@
 
     sring = (blkif_sring_t *)vma->addr;
     SHARED_RING_INIT(sring);
-    BACK_RING_INIT(&blkif->blk_ring, sring);
+    BACK_RING_INIT(&blkif->blk_ring, sring, PAGE_SIZE);
     
     blkif->evtchn        = evtchn;
     blkif->irq           = bind_evtchn_to_irq(evtchn);
@@ -302,7 +302,7 @@
     
     sring = (blkif_sring_t *)__get_free_page(GFP_KERNEL);
     SHARED_RING_INIT(sring);
-    FRONT_RING_INIT(&blktap_be_ring, sring);
+    FRONT_RING_INIT(&blktap_be_ring, sring, PAGE_SIZE);
     blktap_be_state  = BLKIF_STATE_DISCONNECTED;
     DPRINTK("Blkif-Passthrough-BE is now DISCONNECTED.\n");
     blkif_ptbe_send_interface_connect();
diff -Nru a/linux-2.6.11-xen-sparse/drivers/xen/blktap/blktap_userdev.c 
b/linux-2.6.11-xen-sparse/drivers/xen/blktap/blktap_userdev.c
--- a/linux-2.6.11-xen-sparse/drivers/xen/blktap/blktap_userdev.c       
2005-04-01 12:03:37 -05:00
+++ b/linux-2.6.11-xen-sparse/drivers/xen/blktap/blktap_userdev.c       
2005-04-01 12:03:37 -05:00
@@ -87,8 +87,7 @@
     SetPageReserved(virt_to_page(csring));
     
     SHARED_RING_INIT(csring);
-    FRONT_RING_INIT(&blktap_uctrl_ring, csring);
-
+    FRONT_RING_INIT(&blktap_uctrl_ring, csring, PAGE_SIZE);
 
     /* Allocate the fe ring. */
     sring = (blkif_sring_t *)get_zeroed_page(GFP_KERNEL);
@@ -98,7 +97,7 @@
     SetPageReserved(virt_to_page(sring));
     
     SHARED_RING_INIT(sring);
-    FRONT_RING_INIT(&blktap_ufe_ring, sring);
+    FRONT_RING_INIT(&blktap_ufe_ring, sring, PAGE_SIZE);
 

_______________________________________________
Xen-changelog mailing list
Xen-changelog@xxxxxxxxxxxxxxxxxxx
http://lists.xensource.com/xen-changelog


 


Rackspace

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