multi-page blkfront/blkback patch
PATCH 1/1 multi-page blkfront/blkback patch
Hi,
Here is the refreshed version of the multi-page ring patch for blkfront and blkback. I currently don't have time to refresh the blktap part of the patch. The patch should apply cleanly to the following changeset in the linux 2.6.18 tree:
changeset: 752:0b859c9516ba tag: qparent parent: 751:6591b4869889 parent: 748:5012c470f875 user: Keir Fraser <[email protected]> date: Wed Nov 26 11:13:49 2008 +0000 summary: Merge with ia64 tree.
The patch adds support for 1,2 and 4 pages ring for block devices. The number of page is configured when compiling blkfront. The xenstore setup protocol is backward compatible in the sense that a patched blkback will support both patched and unpatched blkfront, and a patched blkfront will use the existing protocol when setting up a 1 page ring so that it works with existing dom0. A guest will fail at boot time if it tries to setup a multi-page ring with an unpatched dom0.
The ring setup protocol is a bit crude and it would be much nicer if the number of ring pages could be configured more dynamically and if blkfront could adapt to block backend that don't support multi-page ring (specially if you want to be able to migrate from a patched to an unpatched dom0). If someone is interested in implementing this feature, feel free to have a go at it.
The refreshed version of the patch hasn't been tested extensively but it seems to work well. I don't have access to a setup that allows me to test if migration works but save/restore seems to work. I also don't have access to a filer to reproduce the performance number but the patch did give a significant boost in throughput (from 60 to 100MB/sec) when we last tested it. I am sorry i currently don't have much time to spend on this but hopefully this will be helpful.
cheers,
geoffrey
# HG changeset patch
# User Geoffrey Lefebvre <[email protected]> # Date 1227835911 28800
# Node ID 87d43eab70d872ae30c9ff985c1b5ff5e986e843 # Parent f9d9b9ff4bbc35b78df31567375534173a032450 imported patch big_ring_linux_unstable.patch
drivers/xen/Kconfig +28 -0
@@ -184,6 +184,34 @@ dedicated device-driver domain, or your master control domain (domain 0), then you almost certainly want to say Y here. +choice + depends on XEN_BLKDEV_FRONTEND!=n + prompt "Number of pages used for the block device ring" + default 1_PAGE + help + Select the number of memory pages used to construct the + request/response ring between DomU and Dom0. A bigger ring can + provide higher throughput when used with a high performance backend + such as a iSCSI filer. If you are using single IDE/SATA drives for + the backend then increasing the number of pages will not increase + throughput. Using more than 1 page with a Dom0 that does not support + multi-page ring will fail at boot time. + + config 1_PAGE + bool "1 page" + config 2_PAGE + bool "2 pages" + config 4_PAGE + bool "4 pages" +endchoice + +config XEN_BLKDEV_NUM_RING_PAGES + int + default 1 if 1_PAGE + default 2 if 2_PAGE + default 4 if 4_PAGE + + config XEN_NETDEV_FRONTEND tristate "Network-device frontend driver" depends on NET
drivers/xen/blkback/blkback.c +1 -1
@@ -53,7 +53,7 @@* This will increase the chances of being able to write whole tracks. * 64 should be enough to keep us competitive with Linux. */ -static int blkif_reqs =64 ; +static int blkif_reqs =128 ;module_param_named (reqs, blkif_reqs, int,0 );MODULE_PARM_DESC (reqs,"Number of blkback requests to allocate" );
drivers/xen/blkback/common.h +6 -3
@@ -47,6 +47,8 @@ #define DPRINTK(_f, _a...) \ pr_debug("(file=%s, line=%d) " _f, \ __FILE__ , __LINE__ , ## _a ) +#define IPRINTK(fmt, args...) \ + printk(KERN_INFO "%s: " fmt, __FUNCTION__, ##args)struct vbd {blkif_vdev_t handle;/* what the domain refers to this vbd as */
@@ -92,14 +94,15 @@wait_queue_head_t waiting_to_free; -grant_handle_t shmem_handle; -grant_ref_t shmem_ref; +unsigned int num_ring_pages; +grant_handle_t shmem_handle[BLKIF_MAX_NUM_RING_PAGES ]; +grant_ref_t shmem_ref[BLKIF_MAX_NUM_RING_PAGES ]; } blkif_t;blkif_t *blkif_alloc (domid_t domid);void blkif_disconnect (blkif_t *blkif);void blkif_free (blkif_t *blkif); -int blkif_map (blkif_t *blkif,unsigned long shared_page,unsigned int evtchn); +int blkif_map (blkif_t *blkif,unsigned long *shared_pages,unsigned int evtchn);#define blkif_get (_b) (atomic_inc(&(_b)->refcnt))#define blkif_put (_b) \
drivers/xen/blkback/interface.c +74 -31
179 lines not on this page · raw message
drivers/xen/blkback/xenbus.c +65 -10
98 lines not on this page · raw message
drivers/xen/blkfront/blkfront.c +72 -21
140 lines not on this page · raw message
drivers/xen/blkfront/block.h +11 -2
@@ -57,6 +57,7 @@#include <asm/uaccess.h> #define DPRINTK(_f, _a...) pr_debug(_f, ## _a) +#define IPRINTK(_f, _a...) printk(KERN_INFO _f, ## _a)#if 0 #define DPRINTK_IOCTL(_f, _a...) printk(KERN_ALERT _f, ## _a)
@@ -86,7 +87,15 @@unsigned long frame[BLKIF_MAX_SEGMENTS_PER_REQUEST ]; }; -#define BLK_RING_SIZE __RING_SIZE((blkif_sring_t *)0, PAGE_SIZE) +#ifndef CONFIG_XEN_BLKDEV_NUM_RING_PAGES +#error "CONFIG_XEN_BLKDEV_NUM_RING_PAGES undefined!" +#endif +#if CONFIG_XEN_BLKDEV_NUM_RING_PAGES >BLKIF_MAX_NUM_RING_PAGES +#error "CONFIG_XEN_BLKDEV_NUM_RING_PAGES too large" +#endif +#define BLK_NUM_RING_PAGES CONFIG_XEN_BLKDEV_NUM_RING_PAGES +#define BLK_RING_AREA_SIZE (BLK_NUM_RING_PAGES * PAGE_SIZE) +#define BLK_RING_SIZE __RING_SIZE((blkif_sring_t *)0, BLK_RING_AREA_SIZE)/* * We have one of these per vbd, whether ide, scsi or 'other'. They
@@ -101,7 +110,7 @@int vdevice;blkif_vdev_t handle;int connected; -int ring_ref; +int ring_ref[BLK_NUM_RING_PAGES ];blkif_front_ring_t ring;unsigned int irq;struct xlbd_major_info *mi;
include/xen/interface/io/blkif.h +5 -0
@@ -124,6 +124,11 @@ DEFINE_RING_TYPES(blkif, struct blkif_request, struct blkif_response); +/* +* Maximum number of pages used for a blkif ring. +*/ +#define BLKIF_MAX_NUM_RING_PAGES 4 +#define VDISK_CDROM 0x1#define VDISK_REMOVABLE 0x2#define VDISK_READONLY 0x4
_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xensource.com/xen-devel
Some comments on infrastructural things, not the actual functionality:
drivers/xen/Kconfig line 205
Quoted 6 lines
drivers/xen/Kconfig +6
-0+ config 1_PAGE + bool "1 page" + config 2_PAGE + bool "2 pages" + config 4_PAGE + bool "4 pages"
These names are too generic. At least XEN_ (and perhaps also BLKFRONT or some such) should also appear in them.
drivers/xen/blkback/blkback.c line 56
Quoted 2 lines
drivers/xen/blkback/blkback.c +1
-1-static int blkif_reqs =64 ; +static int blkif_reqs =128 ;
Is this really related to the functionality introduced here?
drivers/xen/blkfront/blkfront.c line 167
Quoted 3 lines
drivers/xen/blkfront/blkfront.c +3
-0+BUG_ON (BLK_NUM_RING_PAGES !=1 && +BLK_NUM_RING_PAGES !=2 && +BLK_NUM_RING_PAGES !=4 );
This should be BUILD_BUG_ON().
drivers/xen/blkfront/block.h line 92
Quoted 3 lines
drivers/xen/blkfront/block.h +3
-0+#ifndef CONFIG_XEN_BLKDEV_NUM_RING_PAGES +#error "CONFIG_XEN_BLKDEV_NUM_RING_PAGES undefined!" +#endif
This won't work when building unmodified_drivers - I'm not sure what value to default to here, though. But for compatibility it should probably be 1, and the unmodified drivers' Kbuild could override it if desired.
Jan
Quoted 7 lines · Jan Beulich
drivers/xen/blkfront/block.h line 92
Quoted 3 lines
drivers/xen/blkfront/block.h +3
-0+#ifndef CONFIG_XEN_BLKDEV_NUM_RING_PAGES +#error "CONFIG_XEN_BLKDEV_NUM_RING_PAGES undefined!" +#endif This won't work when building
unmodified_drivers- I'm not sure what value to default to here, though. But for compatibility it should probably be 1, and the unmodified drivers'Kbuildcould override it if desired.
It should be a module parameter anyway. I don't think there's anything particularly hard about choosing ring size at run time rather than build time.
-- Keir
Thank you very much Geoffrey for sharing blkfront/blkback changes.
Regards,
Sam
________________________________
From: Geoffrey Lefebvre <[email protected]>
To: Samvel Yuri <[email protected]>
Cc: Dutch Meyer <[email protected]>; Samuel Thibault <[email protected]>; xen-devel <[email protected]>; Andrew Warfield <[email protected]>
Sent: Thursday, November 27, 2008 6:17:58 PM
Subject: [PATCH] multi-page blkfront/blkback patch
Hi,
Here is the refreshed version of the multi-page ring patch for blkfront and blkback. I currently don't have time to refresh the blktap part of the patch. The patch should apply cleanly to the following changeset in the linux 2.6.18 tree:
changeset: 752:0b859c9516ba tag: qparent parent: 751:6591b4869889 parent: 748:5012c470f875 user: Keir Fraser <[email protected]> date: Wed Nov 26 11:13:49 2008 +0000 summary: Merge with ia64 tree.
The patch adds support for 1,2 and 4 pages ring for block devices. The number of page is configured when compiling blkfront. The xenstore setup protocol is backward compatible in the sense that a patched blkback will support both patched and unpatched blkfront, and a patched blkfront will use the existing protocol when setting up a 1 page ring so that it works with existing dom0. A guest will fail at boot time if it tries to setup a multi-page ring with an unpatched dom0.
The ring setup protocol is a bit crude and it would be much nicer if the number of ring pages could be configured more dynamically and if blkfront could adapt to block backend that don't support multi-page ring (specially if you want to be able to migrate from a patched to an unpatched dom0). If someone is interested in implementing this feature, feel free to have a go at it.
The refreshed version of the patch hasn't been tested extensively but it seems to work well. I don't have access to a setup that allows me to test if migration works but save/restore seems to work. I also don't have access to a filer to reproduce the performance number but the patch did give a significant boost in throughput (from 60 to 100MB/sec) when we last tested it. I am sorry i currently don't have much time to spend on this but hopefully this will be helpful.
cheers,
geoffrey
_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xensource.com/xen-devel