Skip to contentSkip to conversation

Paravirtualised drivers for fully virtualised domains

PATCH Steven Smith 7 participants 22 messages Jul 18, 2006 – Aug 16, 2006

lore
Share & tools
lore
#0 lore raw

(The list appears to have eaten my previous attempt to send this. Apologies if you receive multiple copies.)

The attached patches allow you to use paravirtualised network and block interfaces from fully virtualised domains, based on Intel's patches from a few months ago. These are significantly faster than the equivalent ioemu devices, sometimes by more than an order of magnitude.

These drivers are explicitly not considered by XenSource to be an alternative to improving the performance of the ioemu devices. Rather, work on both will continue in parallel.

To build, apply the three patches to a clean checkout of xen-unstable and then build Xen, dom0, and the tools in the usual way. To build the drivers themselves, you first need to build a native kernel for the guest, and then go

cd xen-unstable.hg/unmodified-drivers/linux-2.6
./mkbuildtree
make -C /usr/src/linux-2.6.16 M=$PWD modules

where /usr/src/linux-2.6.16 is the path to the area where you built the guest kernel. This should be a native kernel, and not a xenolinux one. You should end up with four modules. xen-evtchn.ko should be loaded first, followed by xenbus.ko, and then whichever of xen-vnif.ko and xen-vbd.ko you need. None of the modules need any arguments.

The xm configuration syntax is exactly the same as it would be for paravirtualised devices in a paravirtualised domain. For a network interface, you take your line

vif= [ 'type=ioemu,mac=00:16:3E:C1:CA:78' ]

(or whatever) and replace it with

vif= [ 'type=ioemu,mac=00:16:3E:C1:CA:78', 'bridge=xenbr0' ]

where bridge=xenbr0 should be some suitable netif configuration string, as it would be in the PV-on-PV case. Disk is likewise fairly simple:

disk = [ 'file:/path/to/image,ioemu:hda,w' ]

becomes

disk = [ 'file:/path/to/image,ioemu:hda,w', 'file:/path/to/some/other/image,hde,w' ]

There is a slight complication in that the paravirtualised block device can't share an IDE controller with an ioemu device, so if you have an ioemu hda, the paravirtualised device must be hde or later. This is to avoid confusing the Linux IDE driver.

Note that having a PV device doesn't imply having a corresponding ioemu device, and vice versa. Configuring a single backing store to appear as both an IDE device and a paravirtualised block device is likely to cause problems; don't do it.

The patches consist of a number of big parts:

-- A version of netback and netfront which can copy packets into
domains rather than doing page flipping. It's much easier to make this work well with qemu, since the P2M table doesn't need to change, and it can be faster for some workloads.

The copying interface has been confirmed to work in paravirtualised domains, but is currently disabled there.

-- Reworking the device model and hypervisor support so that iorequest
completion notifications no longer go to the HVM guest's event channel mask. This avoids a whole slew of really quite nasty race conditions

-- Adding a new device to the qemu PCI bus which is used for
bootstrapping the devices and getting an IRQ.

-- Support for hypercalls from HVM domains

-- Various shims and fixes to the frontends so that they work without
the rest of the xenolinux infrastructure.

The patches still have a few rough edges, and they're not as easy to understand as I'd like, but I think they should be mostly comprehensible and reasonably stable. The plan is to add them to xen-unstable over the next few weeks, probably before 3.0.3, so any testing which anyone can do would be helpful.

The Xen and tools changes are also available as a series of smaller patches at http://www.cl.cam.ac.uk/~sos22/pv-on-hvm/hvm_xen . The composition of these gives hvm_xen_unstable.diff.

Steven.

# HG changeset patch
# User [email protected]
# Date 1153175686 -3600
# Node ID 7053592c928b488b0c653fb25ce6f73bc6deeb05 # Parent 4726fd416506a34da96888bac0e7c9772c5037e8 Copying netback.

linux-2.6-xen-sparse/drivers/xen/netback/common.h +2 -0
diff -r 4726fd416506 -r 7053592c928b linux-2.6-xen-sparse/drivers/xen/netback/common.h
@@ -59,6 +59,8 @@ typedef struct netif_st {
 	/* Unique identifier for this interface. */
 	domid_t          domid;
 	unsigned int     handle;
+	unsigned int     rx_flags;
+	unsigned int     copy_delivery_offset;
 
 	u8               fe_dev_addr[6];
 
linux-2.6-xen-sparse/drivers/xen/netback/netback.c +217 -78

375 lines not on this page · raw message

linux-2.6-xen-sparse/drivers/xen/netback/xenbus.c +36 -0
diff -r 4726fd416506 -r 7053592c928b linux-2.6-xen-sparse/drivers/xen/netback/xenbus.c
@@ -110,6 +110,18 @@ static int netback_probe(struct xenbus_d
 		}
 #endif
 
+		err = xenbus_printf(xbt, dev->nodename, "feature-rx-copy", "%d", 1);
+		if (err) {
+			message = "writing feature-copying";
+			goto abort_transaction;
+		}
+
+		err = xenbus_printf(xbt, dev->nodename, "feature-rx-flags", "%d", 1);
+		if (err) {
+			message = "writing feature-rx-flags";
+			goto abort_transaction;
+		}
+
 		err = xenbus_transaction_end(xbt, 0);
 	} while (err == -EAGAIN);
 
@@ -363,6 +375,30 @@ static int connect_rings(struct backend_
 	if (err) {
 		xenbus_dev_fatal(dev, err,
 				 "reading %s/ring-ref and event-channel",
+				 dev->otherend);
+		return err;
+	}
+
+	err = xenbus_scanf(XBT_NIL, dev->otherend,
+			   "use-rx-flags", "%u",
+			   &be->netif->rx_flags);
+	if (err == -ENOENT) {
+		be->netif->rx_flags = 0;
+	} else if (err < 0) {
+		xenbus_dev_fatal(dev, err,
+				 "reading %s/use-rx-flags",
+				 dev->otherend);
+		return err;
+	}
+
+	err = xenbus_scanf(XBT_NIL, dev->otherend,
+			   "copy-delivery-offset", "%u",
+			   &be->netif->copy_delivery_offset);
+	if (err == -ENOENT) {
+		be->netif->copy_delivery_offset = 0;
+	} else if (err < 0) {
+		xenbus_dev_fatal(dev, err,
+				 "reading %s/copy_delivery_offset",
 				 dev->otherend);
 		return err;
 	}
linux-2.6-xen-sparse/include/asm-i386/mach-xen/asm/hypervisor.h +10 -0
diff -r 4726fd416506 -r 7053592c928b linux-2.6-xen-sparse/include/asm-i386/mach-xen/asm/hypervisor.h
@@ -200,6 +200,16 @@ MULTI_update_va_mapping(
 }
 
 static inline void
+MULTI_grant_table_op(multicall_entry_t *mcl, unsigned int cmd,
+		     void *uop, unsigned int count)
+{
+    mcl->op = __HYPERVISOR_grant_table_op;
+    mcl->args[0] = cmd;
+    mcl->args[1] = (unsigned long)uop;
+    mcl->args[2] = count;
+}
+
+static inline void
 MULTI_update_va_mapping_otherdomain(
     multicall_entry_t *mcl, unsigned long va,
     pte_t new_val, unsigned long flags, domid_t domid)
xen/include/public/io/netif.h +4 -0
diff -r 4726fd416506 -r 7053592c928b xen/include/public/io/netif.h
@@ -109,8 +109,12 @@ struct netif_tx_response {
 };
 typedef struct netif_tx_response netif_tx_response_t;
 
+#define _NETIF_RXRF_copy_packet (0)
+#define  NETIF_RXRF_copy_packet (1U<<_NETIF_RXRF_copy_packet)
+
 struct netif_rx_request {
     uint16_t    id;        /* Echoed in response message.        */
+    uint16_t    flags;     /* NETRXRF_* */
     grant_ref_t gref;      /* Reference to incoming granted frame */
 };
 typedef struct netif_rx_request netif_rx_request_t;

# HG changeset patch
# User [email protected]
# Date 1153175939 -3600
# Node ID aa3087ee5769d60d5ab1e368cc062233d364ec8b # Parent 7053592c928b488b0c653fb25ce6f73bc6deeb05 Frontend parts of PV-on-HVM patches.

linux-2.6-xen-sparse/drivers/xen/blkfront/blkfront.c +1 -0
diff -r 7053592c928b -r aa3087ee5769 linux-2.6-xen-sparse/drivers/xen/blkfront/blkfront.c
@@ -46,6 +46,7 @@
 #include <xen/interface/grant_table.h>
 #include <xen/gnttab.h>
 #include <asm/hypervisor.h>
+#include <asm/maddr.h>
 
 #define BLKIF_STATE_DISCONNECTED 0
 #define BLKIF_STATE_CONNECTED    1
linux-2.6-xen-sparse/drivers/xen/core/gnttab.c +45 -9

84 lines not on this page · raw message

linux-2.6-xen-sparse/drivers/xen/core/xen_proc.c +2 -0
diff -r 7053592c928b -r aa3087ee5769 linux-2.6-xen-sparse/drivers/xen/core/xen_proc.c
@@ -1,4 +1,5 @@
 
+#include <linux/module.h>
 #include <linux/config.h>
 #include <linux/proc_fs.h>
 #include <xen/xen_proc.h>
@@ -12,6 +13,7 @@ struct proc_dir_entry *create_xen_proc_e
 			panic("Couldn't create /proc/xen");
 	return create_proc_entry(name, mode, xen_base);
 }
+EXPORT_SYMBOL(create_xen_proc_entry);
 
 void remove_xen_proc_entry(const char *name)
 {
linux-2.6-xen-sparse/drivers/xen/netfront/netfront.c +215 -82

455 lines not on this page · raw message

linux-2.6-xen-sparse/drivers/xen/xenbus/xenbus_comms.c +6 -4
diff -r 7053592c928b -r aa3087ee5769 linux-2.6-xen-sparse/drivers/xen/xenbus/xenbus_comms.c
@@ -39,6 +39,8 @@
 #include <xen/xenbus.h>
 #include "xenbus_comms.h"
 
+void *shared_xenstore_buf;
+
 static int xenbus_irq;
 
 extern void xenbus_probe(void *);
@@ -49,7 +51,7 @@ DECLARE_WAIT_QUEUE_HEAD(xb_waitq);
 
 static inline struct xenstore_domain_interface *xenstore_domain_interface(void)
 {
-	return mfn_to_virt(xen_start_info->store_mfn);
+	return shared_xenstore_buf;
 }
 
 static irqreturn_t wake_waiting(int irq, void *unused, struct pt_regs *regs)
@@ -129,7 +131,7 @@ int xb_write(const void *data, unsigned 
 		intf->req_prod += avail;
 
 		/* This implies mb() before other side sees interrupt. */
-		notify_remote_via_evtchn(xen_start_info->store_evtchn);
+		notify_remote_via_evtchn(xen_store_evtchn);
 	}
 
 	return 0;
@@ -180,7 +182,7 @@ int xb_read(void *data, unsigned len)
 		pr_debug("Finished read of %i bytes (%i to go)\n", avail, len);
 
 		/* Implies mb(): they will see new header. */
-		notify_remote_via_evtchn(xen_start_info->store_evtchn);
+		notify_remote_via_evtchn(xen_store_evtchn);
 	}
 
 	return 0;
@@ -195,7 +197,7 @@ int xb_init_comms(void)
 		unbind_from_irqhandler(xenbus_irq, &xb_waitq);
 
 	err = bind_evtchn_to_irqhandler(
-		xen_start_info->store_evtchn, wake_waiting,
+		xen_store_evtchn, wake_waiting,
 		0, "xenbus", &xb_waitq);
 	if (err <= 0) {
 		printk(KERN_ERR "XENBUS request irq failed %i\n", err);
linux-2.6-xen-sparse/drivers/xen/xenbus/xenbus_comms.h +2 -0
diff -r 7053592c928b -r aa3087ee5769 linux-2.6-xen-sparse/drivers/xen/xenbus/xenbus_comms.h
@@ -39,5 +39,7 @@ int xb_read(void *data, unsigned len);
 int xb_read(void *data, unsigned len);
 int xs_input_avail(void);
 extern wait_queue_head_t xb_waitq;
+extern void *shared_xenstore_buf;
+extern int xen_store_evtchn;
 
 #endif /* _XENBUS_COMMS_H */
linux-2.6-xen-sparse/drivers/xen/xenbus/xenbus_dev.c +5 -2
diff -r 7053592c928b -r aa3087ee5769 linux-2.6-xen-sparse/drivers/xen/xenbus/xenbus_dev.c
@@ -48,6 +48,7 @@
 #include <xen/xenbus.h>
 #include <xen/xen_proc.h>
 #include <asm/hypervisor.h>
+#include <asm/io.h>
 
 struct xenbus_dev_transaction {
 	struct list_head list;
@@ -181,7 +182,7 @@ static int xenbus_dev_open(struct inode 
 {
 	struct xenbus_dev_data *u;
 
-	if (xen_start_info->store_evtchn == 0)
+	if (xen_store_evtchn == 0)
 		return -ENOENT;
 
 	nonseekable_open(inode, filp);
@@ -232,7 +233,7 @@ static struct file_operations xenbus_dev
 	.poll = xenbus_dev_poll,
 };
 
-static int __init
+int __init
 xenbus_dev_init(void)
 {
 	xenbus_dev_intf = create_xen_proc_entry("xenbus", 0400);
@@ -242,4 +243,6 @@ xenbus_dev_init(void)
 	return 0;
 }
 
+#ifndef MODULE
 __initcall(xenbus_dev_init);
+#endif
linux-2.6-xen-sparse/drivers/xen/xenbus/xenbus_probe.c +33 -10

114 lines not on this page · raw message

linux-2.6-xen-sparse/include/asm-i386/mach-xen/asm/hypercall.h +94 -0

112 lines not on this page · raw message

linux-2.6-xen-sparse/include/asm-i386/mach-xen/asm/page.h +1 -123

148 lines not on this page · raw message

linux-2.6-xen-sparse/include/asm-i386/mach-xen/asm/pgtable-2level.h +0 -1
diff -r 7053592c928b -r aa3087ee5769 linux-2.6-xen-sparse/include/asm-i386/mach-xen/asm/pgtable-2level.h
@@ -45,7 +45,6 @@
 
 #define pte_none(x)		(!(x).pte_low)
 #define pfn_pte(pfn, prot)	__pte(((pfn) << PAGE_SHIFT) | pgprot_val(prot))
-#define pfn_pte_ma(pfn, prot)	__pte_ma(((pfn) << PAGE_SHIFT) | pgprot_val(prot))
 #define pfn_pmd(pfn, prot)	__pmd(((pfn) << PAGE_SHIFT) | pgprot_val(prot))
 
 /*
linux-2.6-xen-sparse/include/asm-i386/mach-xen/asm/pgtable-3level.h +0 -12
diff -r 7053592c928b -r aa3087ee5769 linux-2.6-xen-sparse/include/asm-i386/mach-xen/asm/pgtable-3level.h
@@ -151,18 +151,6 @@ static inline int pte_none(pte_t pte)
 
 extern unsigned long long __supported_pte_mask;
 
-static inline pte_t pfn_pte_ma(unsigned long page_nr, pgprot_t pgprot)
-{
-	pte_t pte;
-
-	pte.pte_high = (page_nr >> (32 - PAGE_SHIFT)) | \
-					(pgprot_val(pgprot) >> 32);
-	pte.pte_high &= (__supported_pte_mask >> 32);
-	pte.pte_low = ((page_nr << PAGE_SHIFT) | pgprot_val(pgprot)) & \
-							__supported_pte_mask;
-	return pte;
-}
-
 static inline pte_t pfn_pte(unsigned long page_nr, pgprot_t pgprot)
 {
 	return pfn_pte_ma(pfn_to_mfn(page_nr), pgprot);
linux-2.6-xen-sparse/include/xen/xenbus.h +1 -0
diff -r 7053592c928b -r aa3087ee5769 linux-2.6-xen-sparse/include/xen/xenbus.h
@@ -295,5 +295,6 @@ void xenbus_dev_fatal(struct xenbus_devi
 void xenbus_dev_fatal(struct xenbus_device *dev, int err, const char *fmt,
 		      ...);
 
+int __init xenbus_dev_init(void);
 
 #endif /* _XEN_XENBUS_H */
linux-2.6-xen-sparse/include/asm-i386/mach-xen/asm/maddr.h new file +153 -0

153 lines not on this page · raw message

linux-2.6-xen-sparse/include/xen/hvm.h new file +17 -0
diff -r 7053592c928b -r aa3087ee5769 linux-2.6-xen-sparse/include/xen/hvm.h
@@ -0,0 +1,17 @@
+/* Simple wrappers around HVM functions */
+#ifndef XEN_HVM_H__
+#define XEN_HVM_H__
+
+#include <xen/interface/hvm/params.h>
+#include <asm/hypercall.h>
+
+static inline unsigned long hvm_get_parameter(int idx)
+{
+	struct xen_hvm_param xhv;
+
+	xhv.domid = DOMID_SELF;
+	xhv.index = idx;
+	return HYPERVISOR_hvm_op(HVMOP_get_param, &xhv);
+}
+
+#endif /* XEN_HVM_H__ */
unmodified_drivers/linux-2.6/Makefile new file +22 -0
diff -r 7053592c928b -r aa3087ee5769 unmodified_drivers/linux-2.6/Makefile
@@ -0,0 +1,22 @@
+include $(M)/overrides.mk
+
+obj-$(CONFIG_XEN_EVTCHN_PCI)	+= evtchn-pci/
+obj-$(CONFIG_XEN_BLKDEV_FRONTEND)	+= blkfront/
+obj-$(CONFIG_XEN_NETDEV_FRONTEND)	+= netfront/
+obj-m	+= xenbus/
+
+
+debug:
+	chmod +x compile.sh
+	chmod +x mkbuildtree
+	echo $(XEN_DRIVERS_ROOT)
+	echo $(EXTRA_CFLAGS)
+	./compile.sh
+
+clean:
+	find . -name "*.o" |xargs rm -f
+	find . -name "*.ko" |xargs rm -f
+	find . -name "*.mod.c" |xargs rm -f
+	find . -name ".*.cmd" |xargs rm -f
+	rm .tmp_versions -rf
+    
unmodified_drivers/linux-2.6/README new file +7 -0
diff -r 7053592c928b -r aa3087ee5769 unmodified_drivers/linux-2.6/README
@@ -0,0 +1,7 @@
+To build, run ./mkbuildtree and then
+
+make -C /path/to/kernel/source M=$PWD modules
+
+You get four modules, xen-evtchn-pci.ko, xenbus.ko, xen-vbd.ko, and
+xen-vnif.ko.  Load xen-evtchn-pci first, then xenbus, and then
+whichever of xen-vbd and xen-vnif you happen to need.
unmodified_drivers/linux-2.6/blkfront/Kbuild new file +6 -0
diff -r 7053592c928b -r aa3087ee5769 unmodified_drivers/linux-2.6/blkfront/Kbuild
@@ -0,0 +1,6 @@
+include $(M)/overrides.mk
+
+obj-m += xen-vbd.o
+
+xen-vbd-objs := blkfront.o vbd.o
+
unmodified_drivers/linux-2.6/evtchn-pci/Kbuild new file +8 -0
diff -r 7053592c928b -r aa3087ee5769 unmodified_drivers/linux-2.6/evtchn-pci/Kbuild
@@ -0,0 +1,8 @@
+include $(M)/overrides.mk
+
+obj-m := xen-evtchn-pci.o
+
+EXTRA_CFLAGS += -I$(M)/evtchn-pci
+
+xen-evtchn-pci-objs := evtchn.o evtchn-pci.o gnttab.o xen_proc.o xen_support.o\
+	features.o
unmodified_drivers/linux-2.6/evtchn-pci/debuginfo.h new file +56 -0

56 lines not on this page · raw message

unmodified_drivers/linux-2.6/evtchn-pci/evtchn-pci.c new file +299 -0

299 lines not on this page · raw message

unmodified_drivers/linux-2.6/evtchn-pci/evtchn-pci.h new file +58 -0

58 lines not on this page · raw message

unmodified_drivers/linux-2.6/evtchn-pci/evtchn.c new file +200 -0

200 lines not on this page · raw message

unmodified_drivers/linux-2.6/evtchn-pci/xen_support.c new file +53 -0

53 lines not on this page · raw message

unmodified_drivers/linux-2.6/mkbuildtree new file +35 -0
diff -r 7053592c928b -r aa3087ee5769 unmodified_drivers/linux-2.6/mkbuildtree
@@ -0,0 +1,35 @@
+#! /bin/sh
+
+C=$PWD
+
+XEN=$C/../../xen
+XL=$C/../../linux-2.6-xen-sparse
+
+for d in $(find ${XL}/drivers/xen/ -type d -maxdepth 1 | sed -e 1d); do
+    if ! echo $d | egrep -q back; then
+        lndir $d $(basename $d) > /dev/null 2>&1
+    fi
+done
+
+ln -sf ${XL}/drivers/xen/net_driver_util.c netfront
+
+ln -sf ${XL}/drivers/xen/core/gnttab.c evtchn-pci
+ln -sf ${XL}/drivers/xen/core/features.c evtchn-pci
+ln -sf ${XL}/drivers/xen/core/xen_proc.c evtchn-pci
+
+mkdir -p include
+mkdir -p include/xen
+mkdir -p include/public
+mkdir -p include/asm
+
+lndir -silent ${XL}/include/xen include/xen
+ln -sf ${XEN}/include/public include/xen/interface
+
+# Need to be quite careful here: we don't want the files we link in to
+# risk overriding the native Linux ones (in particular, system.h must
+# be native and not xenolinux).
+ln -sf ${XL}/include/asm-i386/mach-xen/asm/hypervisor.h include/asm
+ln -sf ${XL}/include/asm-i386/mach-xen/asm/hypercall.h include/asm
+ln -sf ${XL}/include/asm-i386/mach-xen/asm/synch_bitops.h include/asm
+ln -sf ${XL}/include/asm-i386/mach-xen/asm/maddr.h include/asm
+
unmodified_drivers/linux-2.6/netfront/Kbuild new file +4 -0
diff -r 7053592c928b -r aa3087ee5769 unmodified_drivers/linux-2.6/netfront/Kbuild
@@ -0,0 +1,4 @@
+include $(M)/overrides.mk
+
+obj-m  = xen-vnif.o
+xen-vnif-objs	:= netfront.o
unmodified_drivers/linux-2.6/overrides.mk new file +16 -0
diff -r 7053592c928b -r aa3087ee5769 unmodified_drivers/linux-2.6/overrides.mk
@@ -0,0 +1,16 @@
+# Hack: we need to use the config which was used to build the kernel,
+# except that that won't have the right headers etc., so duplicate
+# some of the mach-xen infrastructure in here.
+#
+# (i.e. we need the native config for things like -mregparm, but
+# a Xen kernel to find the right headers)
+CONFIG_X86_XEN=y
+CONFIG_XEN_EVTCHN_PCI = m
+CONFIG_XEN_BLKDEV_FRONTEND	= m
+CONFIG_XEN_NETDEV_FRONTEND	= m
+EXTRA_CFLAGS += -DCONFIG_VMX -DCONFIG_VMX_GUEST -DCONFIG_X86_XEN
+EXTRA_CFLAGS += -DCONFIG_XEN_SHADOW_MODE -DCONFIG_XEN_SHADOW_TRANSLATE
+EXTRA_CFLAGS += -DCONFIG_XEN_BLKDEV_GRANT -DXEN_EVTCHN_MASK_OPS
+EXTRA_CFLAGS += -DCONFIG_XEN_NETDEV_GRANT_RX -DCONFIG_XEN_NETDEV_GRANT_TX
+EXTRA_CFLAGS += -D__XEN_INTERFACE_VERSION__=0x00030202
+EXTRA_CFLAGS += -I$(M)/include
unmodified_drivers/linux-2.6/xenbus/Kbuild new file +9 -0
diff -r 7053592c928b -r aa3087ee5769 unmodified_drivers/linux-2.6/xenbus/Kbuild
@@ -0,0 +1,9 @@
+include $(M)/overrides.mk
+
+obj-m	+= xenbus.o
+xenbus-objs =
+xenbus-objs += xenbus_comms.o
+xenbus-objs += xenbus_xs.o
+xenbus-objs += xenbus_probe.o 
+xenbus-objs += xenbus_dev.o 
+xenbus-objs += xenbus_client.o 
linux-2.6-xen-sparse/drivers/xen/privcmd/privcmd.c +1 -0
diff -r ecb8ff1fcf1f linux-2.6-xen-sparse/drivers/xen/privcmd/privcmd.c
@@ -270,6 +270,7 @@ static int __init privcmd_init(void)
 	set_bit(__HYPERVISOR_sched_op_compat,  hypercall_permission_map);
 	set_bit(__HYPERVISOR_event_channel_op_compat,
 		hypercall_permission_map);
+	set_bit(__HYPERVISOR_hvm_op,           hypercall_permission_map);
 
 	privcmd_intf = create_xen_proc_entry("privcmd", 0400);
 	if (privcmd_intf != NULL)
tools/firmware/hvmloader/hvmloader.c +5 -5
diff -r ecb8ff1fcf1f tools/firmware/hvmloader/hvmloader.c
@@ -31,7 +31,7 @@
 #define	ROMBIOS_PHYSICAL_ADDRESS	0x000F0000
 
 /* invoke SVM's paged realmode support */
-#define SVM_VMMCALL_RESET_TO_REALMODE	0x00000001
+#define SVM_VMMCALL_RESET_TO_REALMODE	0x80000001
 
 /*
  * C runtime start off
@@ -133,15 +133,15 @@ cirrus_check(void)
 	return inb(0x3C5) == 0x12;
 }
 
-int 
-vmmcall(int edi, int esi, int edx, int ecx, int ebx)
+int
+vmmcall(int function, int edi, int esi, int edx, int ecx, int ebx)
 {
         int eax;
 
         __asm__ __volatile__(
 		".byte 0x0F,0x01,0xD9"
                 : "=a" (eax)
-		: "a"(0x58454E00), /* XEN\0 key */
+		: "a"(function),
 		  "b"(ebx), "c"(ecx), "d"(edx), "D"(edi), "S"(esi)
 	);
         return eax;
@@ -200,7 +200,7 @@ main(void)
 	if (check_amd()) {
 		/* AMD implies this is SVM */
                 puts("SVM go ...\n");
-                vmmcall(SVM_VMMCALL_RESET_TO_REALMODE, 0, 0, 0, 0);
+                vmmcall(SVM_VMMCALL_RESET_TO_REALMODE, 0, 0, 0, 0, 0);
 	} else {
 		puts("Loading VMXAssist ...\n");
 		memcpy((void *)VMXASSIST_PHYSICAL_ADDRESS,
tools/ioemu/Makefile.target +1 -0
diff -r ecb8ff1fcf1f tools/ioemu/Makefile.target
@@ -336,6 +336,7 @@ VL_OBJS+= fdc.o mc146818rtc.o serial.o p
 VL_OBJS+= fdc.o mc146818rtc.o serial.o pc.o
 VL_OBJS+= cirrus_vga.o mixeng.o parallel.o
 VL_OBJS+= piix4acpi.o
+VL_OBJS+= xen_evtchn.o
 DEFINES += -DHAS_AUDIO
 endif
 ifeq ($(TARGET_BASE_ARCH), ppc)
tools/ioemu/hw/pc.c +3 -0
diff -r ecb8ff1fcf1f tools/ioemu/hw/pc.c
@@ -819,6 +819,9 @@ static void pc_init1(uint64_t ram_size, 
     }
 #endif /* !CONFIG_DM */
 
+    if (pci_enabled)
+	pci_xen_evtchn_init(pci_bus);
+
     for(i = 0; i < MAX_SERIAL_PORTS; i++) {
         if (serial_hds[i]) {
             serial_init(&pic_set_irq_new, isa_pic,
tools/ioemu/target-i386-dm/helper2.c +19 -21
diff -r ecb8ff1fcf1f tools/ioemu/target-i386-dm/helper2.c
@@ -82,6 +82,10 @@ int xce_handle = -1;
 /* which vcpu we are serving */
 int send_vcpu = 0;
 
+//the evtchn port for polling the notification,
+#define NR_CPUS 32
+evtchn_port_t ioreq_local_port[NR_CPUS];
+
 CPUX86State *cpu_x86_init(void)
 {
     CPUX86State *env;
@@ -105,15 +109,14 @@ CPUX86State *cpu_x86_init(void)
             return NULL;
         }
 
-        /* FIXME: how about if we overflow the page here? */
         for (i = 0; i < vcpus; i++) {
-            rc = xc_evtchn_bind_interdomain(
-                xce_handle, domid, shared_page->vcpu_iodata[i].vp_eport);
+	    rc = xc_evtchn_bind_interdomain(xce_handle, DOMID_XEN,
+			     shared_page->vcpu_iodata[i].vp_xen_port);
             if (rc == -1) {
                 fprintf(logfile, "bind interdomain ioctl error %d\n", errno);
                 return NULL;
             }
-            shared_page->vcpu_iodata[i].dm_eport = rc;
+	    ioreq_local_port[i] = rc;
         }
     }
 
@@ -184,10 +187,9 @@ void sp_info()
 
     for (i = 0; i < vcpus; i++) {
         req = &(shared_page->vcpu_iodata[i].vp_ioreq);
-        term_printf("vcpu %d: event port %d\n", i,
-                    shared_page->vcpu_iodata[i].vp_eport);
+        term_printf("vcpu %d: event port %d\n", i, ioreq_local_port[i]);
         term_printf("  req state: %x, pvalid: %x, addr: %"PRIx64", "
-                    "data: %"PRIx64", count: %"PRIx64", size: %"PRIx64"\n",
+                    "data: %"PRIx64",  count: %"PRIx64", size: %"PRIx64"\n",
                     req->state, req->pdata_valid, req->addr,
                     req->u.data, req->count, req->size);
         term_printf("  IO totally occurred on this vcpu: %"PRIx64"\n",
@@ -201,17 +203,12 @@ static ioreq_t *__cpu_get_ioreq(int vcpu
     ioreq_t *req;
 
     req = &(shared_page->vcpu_iodata[vcpu].vp_ioreq);
-
     if (req->state == STATE_IOREQ_READY) {
-        req->state = STATE_IOREQ_INPROCESS;
-        return req;
-    }
-
-    fprintf(logfile, "False I/O request ... in-service already: "
-            "%x, pvalid: %x, port: %"PRIx64", "
-            "data: %"PRIx64", count: %"PRIx64", size: %"PRIx64"\n",
-            req->state, req->pdata_valid, req->addr,
-            req->u.data, req->count, req->size);
+	req->state = STATE_IOREQ_INPROCESS;
+	rmb();
+	return req;
+    }
+
     return NULL;
 }
 
@@ -226,7 +223,7 @@ static ioreq_t *cpu_get_ioreq(void)
     port = xc_evtchn_pending(xce_handle);
     if (port != -1) {
         for ( i = 0; i < vcpus; i++ )
-            if ( shared_page->vcpu_iodata[i].dm_eport == port )
+            if ( ioreq_local_port[i] == port )
                 break;
 
         if ( i == vcpus ) {
@@ -447,8 +444,10 @@ void cpu_handle_ioreq(void *opaque)
         }
 
         /* No state change if state = STATE_IORESP_HOOK */
-        if (req->state == STATE_IOREQ_INPROCESS)
+        if (req->state == STATE_IOREQ_INPROCESS) {
+	    mb();
             req->state = STATE_IORESP_READY;
+	}
         env->send_event = 1;
     }
 }
@@ -479,8 +478,7 @@ int main_loop(void)
 
         if (env->send_event) {
             env->send_event = 0;
-            xc_evtchn_notify(xce_handle,
-                             shared_page->vcpu_iodata[send_vcpu].dm_eport);
+            (void)xc_evtchn_notify(xce_handle, ioreq_local_port[send_vcpu]);
         }
     }
     destroy_hvm_domain();
tools/libxc/xc_hvm_build.c +32 -14

83 lines not on this page · raw message

xen/arch/x86/dom0_ops.c +1 -1
diff -r ecb8ff1fcf1f xen/arch/x86/dom0_ops.c
@@ -429,7 +429,7 @@ long arch_do_dom0_op(struct dom0_op *op,
         ret = 0;
 
         hypercall_page = map_domain_page(mfn);
-        hypercall_page_initialise(hypercall_page);
+        hypercall_page_initialise(d, hypercall_page);
         unmap_domain_page(hypercall_page);
 
         put_page_and_type(mfn_to_page(mfn));
xen/arch/x86/domain.c +1 -1
diff -r ecb8ff1fcf1f xen/arch/x86/domain.c
@@ -819,7 +819,7 @@ unsigned long hypercall_create_continuat
 #if defined(__i386__)
         regs->eax  = op;
 
-        if ( supervisor_mode_kernel )
+        if ( supervisor_mode_kernel || hvm_guest(current) )
             regs->eip &= ~31; /* re-execute entire hypercall entry stub */
         else
             regs->eip -= 2;   /* re-execute 'int 0x82' */
xen/arch/x86/domain_build.c +1 -1
diff -r ecb8ff1fcf1f xen/arch/x86/domain_build.c
@@ -704,7 +704,7 @@ int construct_dom0(struct domain *d,
             return -1;
         }
 
-        hypercall_page_initialise((void *)hypercall_page);
+        hypercall_page_initialise(d, (void *)hypercall_page);
     }
 
     /* Copy the initial ramdisk. */
xen/arch/x86/hvm/hvm.c +172 -80

305 lines not on this page · raw message

xen/arch/x86/hvm/intercept.c +1 -1
diff -r ecb8ff1fcf1f xen/arch/x86/hvm/intercept.c

Lines of this file are not shown. View the raw message.

xen/arch/x86/hvm/io.c +12 -79

91 lines not on this page · raw message

xen/arch/x86/hvm/platform.c +147 -25

172 lines not on this page · raw message

xen/arch/x86/hvm/svm/svm.c +57 -26

83 lines not on this page · raw message

xen/arch/x86/hvm/svm/vmcb.c +4 -15
diff -r ecb8ff1fcf1f xen/arch/x86/hvm/svm/vmcb.c

Lines of this file are not shown. View the raw message.

xen/arch/x86/hvm/vlapic.c +4 -3
diff -r ecb8ff1fcf1f xen/arch/x86/hvm/vlapic.c

Lines of this file are not shown. View the raw message.

xen/arch/x86/hvm/vmx/io.c +18 -4
diff -r ecb8ff1fcf1f xen/arch/x86/hvm/vmx/io.c

Lines of this file are not shown. View the raw message.

xen/arch/x86/hvm/vmx/vmcs.c +0 -12
diff -r ecb8ff1fcf1f xen/arch/x86/hvm/vmx/vmcs.c

Lines of this file are not shown. View the raw message.

xen/arch/x86/hvm/vmx/vmx.c +32 -8
diff -r ecb8ff1fcf1f xen/arch/x86/hvm/vmx/vmx.c

Lines of this file are not shown. View the raw message.

xen/arch/x86/mm.c +6 -1
diff -r ecb8ff1fcf1f xen/arch/x86/mm.c

Lines of this file are not shown. View the raw message.

xen/arch/x86/x86_32/entry.S +2 -0
diff -r ecb8ff1fcf1f xen/arch/x86/x86_32/entry.S

Lines of this file are not shown. View the raw message.

xen/arch/x86/x86_32/traps.c +5 -3
diff -r ecb8ff1fcf1f xen/arch/x86/x86_32/traps.c

Lines of this file are not shown. View the raw message.

xen/common/event_channel.c +181 -5

186 lines not on this page · raw message

xen/common/memory.c +3 -0
diff -r ecb8ff1fcf1f xen/common/memory.c

Lines of this file are not shown. View the raw message.

xen/include/asm-x86/domain.h +1 -1
diff -r ecb8ff1fcf1f xen/include/asm-x86/domain.h

Lines of this file are not shown. View the raw message.

xen/include/asm-x86/guest_access.h +19 -1
diff -r ecb8ff1fcf1f xen/include/asm-x86/guest_access.h

Lines of this file are not shown. View the raw message.

xen/include/asm-x86/hvm/domain.h +4 -4
diff -r ecb8ff1fcf1f xen/include/asm-x86/hvm/domain.h

Lines of this file are not shown. View the raw message.

xen/include/asm-x86/hvm/hvm.h +16 -3
diff -r ecb8ff1fcf1f xen/include/asm-x86/hvm/hvm.h

Lines of this file are not shown. View the raw message.

xen/include/asm-x86/hvm/io.h +2 -2
diff -r ecb8ff1fcf1f xen/include/asm-x86/hvm/io.h

Lines of this file are not shown. View the raw message.

xen/include/asm-x86/hvm/support.h +5 -5
diff -r ecb8ff1fcf1f xen/include/asm-x86/hvm/support.h

Lines of this file are not shown. View the raw message.

xen/include/asm-x86/hvm/svm/vmmcall.h +4 -4
diff -r ecb8ff1fcf1f xen/include/asm-x86/hvm/svm/vmmcall.h

Lines of this file are not shown. View the raw message.

xen/include/asm-x86/hvm/vcpu.h +2 -0
diff -r ecb8ff1fcf1f xen/include/asm-x86/hvm/vcpu.h

Lines of this file are not shown. View the raw message.

xen/include/asm-x86/shadow.h +26 -0
diff -r ecb8ff1fcf1f xen/include/asm-x86/shadow.h

Lines of this file are not shown. View the raw message.

xen/include/public/hvm/ioreq.h +2 -5
diff -r ecb8ff1fcf1f xen/include/public/hvm/ioreq.h

Lines of this file are not shown. View the raw message.

xen/include/public/xen.h +1 -0
diff -r ecb8ff1fcf1f xen/include/public/xen.h

Lines of this file are not shown. View the raw message.

xen/include/xen/event.h +6 -0
diff -r ecb8ff1fcf1f xen/include/xen/event.h

Lines of this file are not shown. View the raw message.

xen/include/xen/hypercall.h +5 -0
diff -r ecb8ff1fcf1f xen/include/xen/hypercall.h

Lines of this file are not shown. View the raw message.

xen/include/xen/sched.h +2 -0
diff -r ecb8ff1fcf1f xen/include/xen/sched.h

Lines of this file are not shown. View the raw message.

tools/ioemu/hw/xen_evtchn.c new file +160 -0

160 lines not on this page · raw message

xen/include/asm-x86/hvm/guest_access.h new file +7 -0
diff -r ecb8ff1fcf1f xen/include/asm-x86/hvm/guest_access.h

Lines of this file are not shown. View the raw message.

xen/include/public/hvm/params.h new file +22 -0
diff -r ecb8ff1fcf1f xen/include/public/hvm/params.h

Lines of this file are not shown. View the raw message.

The rest of this diff is not shown. View the raw message.

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

Part of the diff is not shown here. View the raw message.

#1 lore raw

Steven,

This is very interesting. Thanks for posting it. It appears to closely parallel work that we've been doing here and have mentioned at times on this list. I believe that Steve Ofsthun posted some suggested patches in this area a little while back. I'm looking forward to seeing how your patches resolve the issues and feedback that was given to Steve.

I'm also interested to see how you resolve the 32/64 bit issues. I know that there's some sensitivity here as one of the pieces of feedback about our recent XI shadow posting was the current lack of 32bit support. A 64 bit hypervisor on an hvm capable machine should be capable of concurrent support of both 32 and 64 bit guest domains.

Thanks for posting this. We're looking forward to seeing your final submissions.

Thanks !
-b

Quoted 107 lines · Steven Smith

(The list appears to have eaten my previous attempt to send this. Apologies if you receive multiple copies.)

The attached patches allow you to use paravirtualised network and block interfaces from fully virtualised domains, based on Intel's patches from a few months ago. These are significantly faster than the equivalent ioemu devices, sometimes by more than an order of magnitude.

These drivers are explicitly not considered by XenSource to be an alternative to improving the performance of the ioemu devices. Rather, work on both will continue in parallel.

To build, apply the three patches to a clean checkout of xen-unstable and then build Xen, dom0, and the tools in the usual way. To build the drivers themselves, you first need to build a native kernel for the guest, and then go

cd xen-unstable.hg/unmodified-drivers/linux-2.6
./mkbuildtree
make -C /usr/src/linux-2.6.16 M=$PWD modules

where /usr/src/linux-2.6.16 is the path to the area where you built the guest kernel. This should be a native kernel, and not a xenolinux one. You should end up with four modules. xen-evtchn.ko should be loaded first, followed by xenbus.ko, and then whichever of xen-vnif.ko and xen-vbd.ko you need. None of the modules need any arguments.

The xm configuration syntax is exactly the same as it would be for paravirtualised devices in a paravirtualised domain. For a network interface, you take your line

vif= [ 'type=ioemu,mac=00:16:3E:C1:CA:78' ]

(or whatever) and replace it with

vif= [ 'type=ioemu,mac=00:16:3E:C1:CA:78', 'bridge=xenbr0' ]

where bridge=xenbr0 should be some suitable netif configuration string, as it would be in the PV-on-PV case. Disk is likewise fairly simple:

disk = [ 'file:/path/to/image,ioemu:hda,w' ]

becomes

disk = [ 'file:/path/to/image,ioemu:hda,w',
'file:/path/to/some/other/image,hde,w' ]

There is a slight complication in that the paravirtualised block device can't share an IDE controller with an ioemu device, so if you have an ioemu hda, the paravirtualised device must be hde or later. This is to avoid confusing the Linux IDE driver.

Note that having a PV device doesn't imply having a corresponding ioemu device, and vice versa. Configuring a single backing store to appear as both an IDE device and a paravirtualised block device is likely to cause problems; don't do it.

The patches consist of a number of big parts:

-- A version of netback and netfront which can copy packets into
domains rather than doing page flipping. It's much easier to make this work well with qemu, since the P2M table doesn't need to change, and it can be faster for some workloads.

The copying interface has been confirmed to work in paravirtualised domains, but is currently disabled there.

-- Reworking the device model and hypervisor support so that iorequest
completion notifications no longer go to the HVM guest's event channel mask. This avoids a whole slew of really quite nasty race conditions

-- Adding a new device to the qemu PCI bus which is used for
bootstrapping the devices and getting an IRQ.

-- Support for hypercalls from HVM domains

-- Various shims and fixes to the frontends so that they work without
the rest of the xenolinux infrastructure.

The patches still have a few rough edges, and they're not as easy to understand as I'd like, but I think they should be mostly comprehensible and reasonably stable. The plan is to add them to xen-unstable over the next few weeks, probably before 3.0.3, so any testing which anyone can do would be helpful.

The Xen and tools changes are also available as a series of smaller patches at http://www.cl.cam.ac.uk/~sos22/pv-on-hvm/hvm_xen . The composition of these gives hvm_xen_unstable.diff.

Steven.

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.3 (GNU/Linux)

iD8DBQFEvNk5O4S8/gLNrjcRAviLAJ0eS/1FZY+5ArbCrAaExsMrNAl9AQCgqyIp cRz5az+HktMS60u0qy+3dJA=
=19b4
-----END PGP SIGNATURE-----

Quoted 8 lines

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

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

#2 lore raw
In reply to Steven Smith
Quoted 5 lines · Steven Smith

The attached patches allow you to use paravirtualised network and block interfaces from fully virtualised domains, based on Intel's patches from a few months ago. These are significantly faster than the equivalent ioemu devices, sometimes by more than an order of magnitude.

Excellent work Steven!

I've been working on a similar set of patches and your effort seems quite comprehensive. I do have a few questions:

Can you comment on the testing matrix you used? In particular, does this patch address both 32-bit and 64-bit hypervisors? Can 32-bit guests make 64-bit hypercalls?

Have you built the guest environment on anything other than a 2.6.16 version of Linux? We ran into extra work supporting older linux versions.

You did some work to make xenbus a loadable module in the guest domains. Can this be used to make xenbus loadable in Domain 0?

Quoted 3 lines

These drivers are explicitly not considered by XenSource to be an alternative to improving the performance of the ioemu devices. Rather, work on both will continue in parallel.

I agree. Both activities are worth developing.

Quoted 9 lines

There is a slight complication in that the paravirtualised block device can't share an IDE controller with an ioemu device, so if you have an ioemu hda, the paravirtualised device must be hde or later. This is to avoid confusing the Linux IDE driver.

Note that having a PV device doesn't imply having a corresponding ioemu device, and vice versa. Configuring a single backing store to appear as both an IDE device and a paravirtualised block device is likely to cause problems; don't do it.

Several problems exist here:

Domain 0 buffer cache coherency issues can cause catastrophic file system corruption. This is due to the backend accessing the backing device directly, and QEMU accessing the device through buffered reads and writes. We are working on a patch to convert QEMU to use O_DIRECT whenever possible. This solves the cache coherency issue.

Actually presenting two copies of the same device to linux can cause its own problems. Mounting using LABEL= will complain about duplicate labels. However, using the device names directly seems to work. With this approach it is possible to decide in the guest whether to mount a device as an emulated disk or a PV disk.

Quoted 6 lines

The patches consist of a number of big parts:

-- A version of netback and netfront which can copy packets into
domains rather than doing page flipping. It's much easier to make this work well with qemu, since the P2M table doesn't need to change, and it can be faster for some workloads.

Recent patches to change QEMU to dynamically map memory may make this easier. We still avoid it to prevent large guest pages from being broken up (under the XI shadow code).

Quoted 7 lines

The copying interface has been confirmed to work in paravirtualised domains, but is currently disabled there.

-- Reworking the device model and hypervisor support so that iorequest
completion notifications no longer go to the HVM guest's event channel mask. This avoids a whole slew of really quite nasty race conditions

This is great news. We were filtering iorequest bits out during guest event notification delivery. Your method is much cleaner.

Quoted 2 lines

-- Adding a new device to the qemu PCI bus which is used for
bootstrapping the devices and getting an IRQ.

Have you thought about supporting more than one IRQ. We are experimenting with an IRQ per device class (BUS, NIC, VBD).

Quoted 10 lines

-- Support for hypercalls from HVM domains

-- Various shims and fixes to the frontends so that they work without
the rest of the xenolinux infrastructure.

The patches still have a few rough edges, and they're not as easy to understand as I'd like, but I think they should be mostly comprehensible and reasonably stable. The plan is to add them to xen-unstable over the next few weeks, probably before 3.0.3, so any testing which anyone can do would be helpful.

This is a very good start!

Steve

Signature · 1 line
Steve Ofsthun - Virtual Iron Software, Inc.
#3 lore raw
Quoted 5 lines
Quoted 3 lines

These drivers are explicitly not considered by XenSource to be an alternative to improving the performance of the ioemu devices. Rather, work on both will continue in parallel.

I agree. Both activities are worth developing.

There's lots of stuff still to be done to make the ioemu devices work better, even if some users wish to use PV drivers directly some will still want the simplicity of working "out of the box".

Quoted 5 lines

Actually presenting two copies of the same device to linux can cause its own problems. Mounting using LABEL= will complain about duplicate labels. However, using the device names directly seems to work. With this approach it is possible to decide in the guest whether to mount a device as an emulated disk or a PV disk.

We should *really* have interlocks in dom0 to prevent a guest from accessing both simultaneously :-)

Initially, we could just allow the user only to configure as either model, not both (using a check in Xend, as we do for checking mounted partitions, etc). To support what you propose we'd probably have to add a little control plane stuff, but I think it'd be worth it to avoid too many people damaging stuff!

To mangle a quote I once saw online: duplicate device access can be used to hunt both foot and game, but only one will feed your family.

Cheers,
Mark

#4 lore raw
In reply to Steve Ofsthun
Quoted 7 lines
Quoted 5 lines

The attached patches allow you to use paravirtualised network and block interfaces from fully virtualised domains, based on Intel's patches from a few months ago. These are significantly faster than the equivalent ioemu devices, sometimes by more than an order of magnitude.

I've been working on a similar set of patches and your effort seems quite comprehensive.

Yeah, we (XenSource and Virtual Iron) really need to do a better job of coordinating who's working on what. :)

Quoted 5 lines

I do have a few questions:

Can you comment on the testing matrix you used? In particular, does this patch address both 32-bit and 64-bit hypervisors? Can 32-bit guests make 64-bit hypercalls?

This set of patches only deals with the 32 bit case. Further, the PAE case depends on Tim Deegan's new shadow mode posted last week.

Sorry, I should have said that in the initial post.

Quoted 2 lines

Have you built the guest environment on anything other than a 2.6.16 version of Linux? We ran into extra work supporting older linux versions.

#ifdef soup will get you back to about 2.6.12-ish without too many problems. These patches don't include that, since it would complicate merging.

Quoted 2 lines

You did some work to make xenbus a loadable module in the guest domains. Can this be used to make xenbus loadable in Domain 0?

I can't see any immediate reason why not, but it's not clear to me why that would be useful.

Quoted 9 lines
Quoted 9 lines

There is a slight complication in that the paravirtualised block device can't share an IDE controller with an ioemu device, so if you have an ioemu hda, the paravirtualised device must be hde or later. This is to avoid confusing the Linux IDE driver.

Note that having a PV device doesn't imply having a corresponding ioemu device, and vice versa. Configuring a single backing store to appear as both an IDE device and a paravirtualised block device is likely to cause problems; don't do it.

Quoted 5 lines

Domain 0 buffer cache coherency issues can cause catastrophic file system corruption. This is due to the backend accessing the backing device directly, and QEMU accessing the device through buffered reads and writes. We are working on a patch to convert QEMU to use O_DIRECT whenever possible. This solves the cache coherency issue.

I wasn't aware of these issues. I was much more worried about domU trying to cache the devices twice, and those caches getting out of sync. It's pretty much the usual problem of configuring a device into two domains and then having them trip over each other. Do you have a plan for dealing with this?

Quoted 5 lines

Actually presenting two copies of the same device to linux can cause its own problems. Mounting using LABEL= will complain about duplicate labels. However, using the device names directly seems to work. With this approach it is possible to decide in the guest whether to mount a device as an emulated disk or a PV disk.

My plan here was to just not support VMs which mix paravirtualised and ioemulated devices, requiring the user to load the PV drivers from an initrd. Of course, you have to load the initrd somehow, but the bootloader should only be reading the disk, which makes the coherency issues much easier. As a last resort, rombios could learn about the PV devices, but I'd rather avoid that if possible.

Your way would be preferable, though, if it works.

Quoted 8 lines
Quoted 6 lines

The patches consist of a number of big parts:

-- A version of netback and netfront which can copy packets into
domains rather than doing page flipping. It's much easier to make this work well with qemu, since the P2M table doesn't need to change, and it can be faster for some workloads.

Recent patches to change QEMU to dynamically map memory may make this easier.

Yes, agreed. It should be possible to add this in later in a backwards-compatible fashion.

Quoted 6 lines
Quoted 4 lines

-- Reworking the device model and hypervisor support so that iorequest
completion notifications no longer go to the HVM guest's event channel mask. This avoids a whole slew of really quite nasty race conditions

This is great news. We were filtering iorequest bits out during guest event notification delivery. Your method is much cleaner.

Thank you.

Quoted 4 lines
Quoted 2 lines

-- Adding a new device to the qemu PCI bus which is used for
bootstrapping the devices and getting an IRQ.

Have you thought about supporting more than one IRQ. We are experimenting with an IRQ per device class (BUS, NIC, VBD).

I considered it, but it wasn't obvious that there would be much benefit. You can potentially scan a smaller part of the pending event channel mask, but that's fairly quick already.

Steven.

Quoted 11 lines
Quoted 10 lines

-- Support for hypercalls from HVM domains

-- Various shims and fixes to the frontends so that they work without
the rest of the xenolinux infrastructure.

The patches still have a few rough edges, and they're not as easy to understand as I'd like, but I think they should be mostly comprehensible and reasonably stable. The plan is to add them to xen-unstable over the next few weeks, probably before 3.0.3, so any testing which anyone can do would be helpful.

Quoted 5 lines

This is a very good start!

Steve

Signature · 1 line
Steve Ofsthun - Virtual Iron Software, Inc.

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

#5 lore raw
Quoted 6 lines · Steven Smith
Quoted 2 lines

Have you built the guest environment on anything other than a 2.6.16 version of Linux? We ran into extra work supporting older linux versions.

#ifdef soup will get you back to about 2.6.12-ish without too many problems. These patches don't include that, since it would complicate merging.

I was thinking about SLES9 (2.6.5), RHEL4 (2.6.9), RHEL3 (2.4.21).

Quoted 5 lines
Quoted 2 lines

You did some work to make xenbus a loadable module in the guest domains. Can this be used to make xenbus loadable in Domain 0?

I can't see any immediate reason why not, but it's not clear to me why that would be useful.

It just makes it easier to insert alternate bus implementations.

Quoted 11 lines
Quoted 5 lines

Domain 0 buffer cache coherency issues can cause catastrophic file system corruption. This is due to the backend accessing the backing device directly, and QEMU accessing the device through buffered reads and writes. We are working on a patch to convert QEMU to use O_DIRECT whenever possible. This solves the cache coherency issue.

I wasn't aware of these issues. I was much more worried about domU trying to cache the devices twice, and those caches getting out of sync. It's pretty much the usual problem of configuring a device into two domains and then having them trip over each other. Do you have a plan for dealing with this?

We eliminate any buffer cache use in domain 0 for backing store objects. This prevents double caching and reduces domain 0 's memory footprint. We don't restrict multiple domain access to the same "raw" backing object. Real hardware allows this (at least for SCSI/FC). This may be necessary for shared storage clustering.

Quoted 6 lines
Quoted 5 lines

Actually presenting two copies of the same device to linux can cause its own problems. Mounting using LABEL= will complain about duplicate labels. However, using the device names directly seems to work. With this approach it is possible to decide in the guest whether to mount a device as an emulated disk or a PV disk.

Quoted 8 lines

My plan here was to just not support VMs which mix paravirtualised and ioemulated devices, requiring the user to load the PV drivers from an initrd. Of course, you have to load the initrd somehow, but the bootloader should only be reading the disk, which makes the coherency issues much easier. As a last resort, rombios could learn about the PV devices, but I'd rather avoid that if possible.

Your way would be preferable, though, if it works.

We currently only allow this for the boot device (mainly to avoid the rombios work you mention). In addition, we make the qemu device only visible to the rombios (and not the guest O/S) by controlling the IDE probe logic in qemu.

Quoted 9 lines
Quoted 5 lines
Quoted 2 lines

-- Adding a new device to the qemu PCI bus which is used for
bootstrapping the devices and getting an IRQ.

Have you thought about supporting more than one IRQ. We are experimenting with an IRQ per device class (BUS, NIC, VBD).

I considered it, but it wasn't obvious that there would be much benefit. You can potentially scan a smaller part of the pending event channel mask, but that's fairly quick already.

The main benefit we see is for legacy Linux variants that limit 1 CPU per IRQ. Allowing additional IRQs increases the possible interrupt processing concurrency. In addition, one interrupt class can't starve another (on SMP guests).

Steve

Signature · 1 line
Steve Ofsthun - Virtual Iron Software, Inc.
#6 lore raw
Quoted 11 lines · Steve Ofsthun
Quoted 7 lines · Steven Smith
Quoted 3 lines

Have you built the guest environment on anything other than a 2.6.16 version of Linux? We ran into extra work supporting older linux versions.

#ifdef soup will get you back to about 2.6.12-ish without too many problems. These patches don't include that, since it would complicate merging.

I was thinking about SLES9 (2.6.5), RHEL4 (2.6.9), RHEL3 (2.4.21).

SLES9 SP3 kernels available here:
http://forge.novell.com/modules/xfcontent/downloads.php/xenpreview/SUSE%20Linux%20Enterprise%20Server/9%20SP3/

I have a sles9 guest up and running on a sles10 host machine.

cheers,

Gerd

Signature · 2 lines
Gerd Hoffmann <[email protected]>
http://www.suse.de/~kraxel/julika-dora.jpeg
#7 lore raw
In reply to Steven Smith

I've just put an updated version of these patches up at
http://www.cl.cam.ac.uk/~sos22/pv-on-hvm/rev2 . There's also an equivalent single big patch at
http://www.cl.cam.ac.uk/~sos22/pv-on-hvm/rev2.combined . Thank you to everyone who gave feedback on the previous version.

The main changes since last time are:

-- Support for SMP guests
-- Support for 64 bit guests on a 64 bit hypervisor
-- Partial support for 32 bit guests on a 64 bit hypervisor: the network
interface works, but the block device doesn't.

The block device can be made to work by #define'ing ALIEN_INTERFACES in blkif.h, but drivers compiled in that way won't work with 32 on 32. The problem here is that blkif_request_t contains extra padding in 64 bit builds, and so is a different size, and so the block ring layout is different.

Other structures with similar problems are handled either by run time tests in the drivers (shared_info_t) or translation wrappers in the hypervisor (xen_feature_info_t, xen_add_to_physmap_t), but trying to do this for the block rings would require far more painful and extensive surgery. I'm inclined to stick with multiply compiling the frontend drivers in the short term, although it'll obviously need doing in a slightly less grotty way.

Steven.

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

#9 lore raw

Steven Smith <[email protected]> wrote on 08/08/2006 04:42:15 AM:

Quoted 6 lines

I just put a new version of the PV-on-HVM patches up at
http://www.cl.cam.ac.uk/~sos22/pv-on-hvm/rev8 . These are against 10968:51c227428166 and are otherwise largely unchanged from the previous versions.

Steven.

I have been running some informal performance tests on the rev8 patches. Thought I'd share my finding thus far.

I am finding that disk performance (sequential/random read/write) with the PV xen-vbd driver in an HVM domain is pretty much equal to that of a PV domain. Cool. Not surprising, but cool nonetheless.

At the moment I'm having trouble running a network test (netperf) of the PV xen-vnif driver within our testing framework. I'll post those findings when I get some reliable numbers. Testing on the rev2 version of the patches showed pretty much equal network performance between running on a PV driver in an HVM domain and a PV domain.

I am noticing two odd behaviors with the rev8 patches, though.

1. When I try to create a PV domain, the domain hangs on bootup displaying repeated messages to the console:
netfront: Bad rx response id 1.
netfront: Bad rx response id 0.
netfront: Bad rx response id 1.
netfront: Bad rx response id 0.
...

I had to reboot from an unpatched changeset 10968 build to get the performance numbers for a PV domain. (Hence, I am not comparing numbers from the exact same code base, which is one reason why the tests are "informal".)

I haven't dug into the cause of this problem yet.

2. When I destroy the HVM domain it stays in the zombie state. dib:~ # xm list
Name ID Mem(MiB) VCPUs State Time(s)

Domain-0                           0      768     1 r-----  2328.4
Zombie-hvm1                        1      768     1 -----d  1502.6

I'm not sure how to debug this one. Any pointers would be helpful.

Steve D.

#10 lore raw

Paravirtualised drivers for fully virtualised domains, rev9

In reply to Steven Smith

I just put a new version of the PV-on-HVM patches up at
http://www.cl.cam.ac.uk/~sos22/pv-on-hvm/rev9 . These are against 10968:51c227428166, as before. Hopefully, the problems some people have been having with network access from paravirtualised domains and domains becoming zombies are now fixed.

Thanks to everyone who submitted bug reports on these.

Steven.

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

#11 lore raw

Re: Paravirtualised drivers for fully virtualised domains, rev9

Steven Smith <[email protected]> wrote on 08/10/2006 06:08:38 AM:

Quoted 7 lines

I just put a new version of the PV-on-HVM patches up at
http://www.cl.cam.ac.uk/~sos22/pv-on-hvm/rev9 . These are against 10968:51c227428166, as before. Hopefully, the problems some people have been having with network access from paravirtualised domains and domains becoming zombies are now fixed.

Thanks to everyone who submitted bug reports on these.

Hi, Steve.

Thought I'd share my findings so far with rev9.

The good news is that I don't get zombies anymore. The bad news is that I'm still getting very poor network performance running netperf, worse than a fully virtualized domain. I thought it was something wrong with my test setup when I was testing rev8, but the test setup looks good and the results are repeatable.

Here is what I have found so far in trying to chase down the cause of the slowdown.
The qemu-dm process is running 99.9% of the CPU on dom0. I ran xenoprofile to see what functions are chewing up the most time. Here are the first several lines of output from the xenoprofile report:

1316786 17.1956 vmlinux-2.6.16.13-xen0-up vmlinux-2.6.16.13-xen0-up system_call
1243487 16.2385 vmlinux-2.6.16.13-xen0-up vmlinux-2.6.16.13-xen0-up do_select
492967 6.4376 vmlinux-2.6.16.13-xen0-up vmlinux-2.6.16.13-xen0-up
do_gettimeofday
467692 6.1075 vmlinux-2.6.16.13-xen0-up vmlinux-2.6.16.13-xen0-up
sys_select

376844    4.9211  vmlinux-2.6.16.13-xen0-up vmlinux-2.6.16.13-xen0-up fget
330483    4.3157  vmlinux-2.6.16.13-xen0-up vmlinux-2.6.16.13-xen0-up

sys_clock_gettime
291153 3.8021 vmlinux-2.6.16.13-xen0-up vmlinux-2.6.16.13-xen0-up
ktime_get_ts
291098 3.8014 vmlinux-2.6.16.13-xen0-up vmlinux-2.6.16.13-xen0-up
memset
249732 3.2612 xen-unstable-syms xen-unstable-syms
write_cr3
195102 2.5478 vmlinux-2.6.16.13-xen0-up vmlinux-2.6.16.13-xen0-up
fget_light
190663 2.4898 vmlinux-2.6.16.13-xen0-up vmlinux-2.6.16.13-xen0-up
__kmalloc
183748 2.3995 vmlinux-2.6.16.13-xen0-up vmlinux-2.6.16.13-xen0-up
tty_poll
152136 1.9867 vmlinux-2.6.16.13-xen0-up vmlinux-2.6.16.13-xen0-up
copy_user_generic
129317 1.6887 vmlinux-2.6.16.13-xen0-up vmlinux-2.6.16.13-xen0-up
tun_chr_poll
115066 1.5026 vmlinux-2.6.16.13-xen0-up vmlinux-2.6.16.13-xen0-up
getnstimeofday
94228 1.2305 vmlinux-2.6.16.13-xen0-up vmlinux-2.6.16.13-xen0-up
wait_for_completion_interruptible
85598 1.1178 vmlinux-2.6.16.13-xen0-up vmlinux-2.6.16.13-xen0-up
copy_from_user
83495 1.0903 qemu-dm qemu-dm
qemu_run_timers
82606 1.0787 xen-unstable-syms xen-unstable-syms
syscall_enter

82507     1.0774  xen-unstable-syms        xen-unstable-syms        FLT2
76960     1.0050  qemu-dm                  qemu-dm

main_loop_wait
71759 0.9371 xen-unstable-syms xen-unstable-syms
toggle_guest_mode
47744 0.6235 vmlinux-2.6.16.13-xen0-up vmlinux-2.6.16.13-xen0-up
sys_read
44890 0.5862 vmlinux-2.6.16.13-xen0-up vmlinux-2.6.16.13-xen0-up
pipe_poll
40506 0.5290 vmlinux-2.6.16.13-xen0-up vmlinux-2.6.16.13-xen0-up
pty_chars_in_buffer
40210 0.5251 librt-2.4.so librt-2.4.so
clock_gettime
37866 0.4945 vmlinux-2.6.16.13-xen0-up vmlinux-2.6.16.13-xen0-up
normal_poll
35160 0.4591 vmlinux-2.6.16.13-xen0-up vmlinux-2.6.16.13-xen0-up
tty_paranoia_check
34715 0.4533 vmlinux-2.6.16.13-xen0-up vmlinux-2.6.16.13-xen0-up
poll_initwait
34225 0.4469 xen-unstable-syms xen-unstable-syms
test_guest_events
32643 0.4263 xen-unstable-syms xen-unstable-syms
restore_all_guest
31101 0.4061 vmlinux-2.6.16.13-xen0-up vmlinux-2.6.16.13-xen0-up
posix_ktime_get_ts

29352     0.3833  qemu-dm                  qemu-dm                  DMA_run
27741     0.3623  vmlinux-2.6.16.13-xen0-up vmlinux-2.6.16.13-xen0-up

vfs_read
27443 0.3584 papps1-syms papps1-syms (no
symbols)
26663 0.3482 qemu-dm qemu-dm
main_loop

26283     0.3432  vmlinux-2.6.16.13-xen0-up vmlinux-2.6.16.13-xen0-up kfree
24446     0.3192  xen-unstable-syms        xen-unstable-syms
__copy_from_user_ll
23117     0.3019  xen-unstable-syms        xen-unstable-syms        do_iret
22559     0.2946  vmlinux-2.6.16.13-xen0-up vmlinux-2.6.16.13-xen0-up fput
20354     0.2658  vmlinux-2.6.16.13-xen0-up vmlinux-2.6.16.13-xen0-up

__wake_up_common
19516 0.2549 vmlinux-2.6.16.13-xen0-up vmlinux-2.6.16.13-xen0-up
tty_ldisc_deref
19290 0.2519 xen-unstable-syms xen-unstable-syms
test_all_events
18499 0.2416 vmlinux-2.6.16.13-xen0-up vmlinux-2.6.16.13-xen0-up
rw_verify_area
17759 0.2319 vmlinux-2.6.16.13-xen0-up vmlinux-2.6.16.13-xen0-up
__wake_up
13282 0.1734 xen-unstable-syms xen-unstable-syms
create_bounce_frame
11968 0.1563 vmlinux-2.6.16.13-xen0-up vmlinux-2.6.16.13-xen0-up
hypercall_page
11211 0.1464 vmlinux-2.6.16.13-xen0-up vmlinux-2.6.16.13-xen0-up
set_normalized_timespec
11127 0.1453 vmlinux-2.6.16.13-xen0-up vmlinux-2.6.16.13-xen0-up
sysret_check

10494     0.1370  xen-unstable-syms        xen-unstable-syms        FLT131
10467     0.1367  pxen1-syms               pxen1-syms

vmx_asm_vmexit_handler
9478 0.1238 libpthread-2.4.so libpthread-2.4.so
__pthread_disable_asynccancel
9260 0.1209 vmlinux-2.6.16.13-xen0-up vmlinux-2.6.16.13-xen0-up
copy_to_user
9222 0.1204 vmlinux-2.6.16.13-xen0-up vmlinux-2.6.16.13-xen0-up
sync_buffer
8616 0.1125 vmlinux-2.6.16.13-xen0-up vmlinux-2.6.16.13-xen0-up
tty_ldisc_ref_wait
7985 0.1043 oprofiled oprofiled
odb_insert
6862 0.0896 libpthread-2.4.so libpthread-2.4.so
__read_nocancel

6806      0.0889  xen-unstable-syms        xen-unstable-syms        FLT3
6676      0.0872  qemu-dm                  qemu-dm

cpu_get_clock
6576 0.0859 pxen1-syms pxen1-syms
vmx_load_cpu_guest_regs
6450 0.0842 vmlinux-2.6.16.13-xen0-up vmlinux-2.6.16.13-xen0-up
evtchn_poll
6349 0.0829 vmlinux-2.6.16.13-xen0-up vmlinux-2.6.16.13-xen0-up
pty_write_room
5978 0.0781 qemu-dm qemu-dm
qemu_get_clock
5906 0.0771 pxen1-syms pxen1-syms
resync_all
5745 0.0750 oprofiled oprofiled
opd_process_samples
5738 0.0749 vmlinux-2.6.16.13-xen0-up vmlinux-2.6.16.13-xen0-up
tty_ldisc_try
4943 0.0645 oprofiled oprofiled
sfile_find
4803 0.0627 xen-unstable-syms xen-unstable-syms
pit_read_counter
4194 0.0548 xen-unstable-syms xen-unstable-syms
copy_from_user
4007 0.0523 pxen1-syms pxen1-syms
vmx_store_cpu_guest_regs
3838 0.0501 vmlinux-2.6.16.13-xen0-up vmlinux-2.6.16.13-xen0-up
n_tty_chars_in_buffer

3507      0.0458  xen-unstable-syms        xen-unstable-syms        FLT6
3501      0.0457  xen-unstable-syms        xen-unstable-syms        FLT4
3474      0.0454  oprofiled                oprofiled
pop_buffer_value
3436      0.0449  xen-unstable-syms        xen-unstable-syms        FLT11
3283      0.0429  vmlinux-2.6.16.13-xen0-up vmlinux-2.6.16.13-xen0-up

poll_freewait
3260 0.0426 pxen1-syms pxen1-syms
vmx_vmexit_handler

xen-unstable-syms is the Xen hypervisor running on behalf of dom0. pxen1-syms is the Xen hypervisor running on behalf of the HVM domain. vmlinux-2.6.16.13-xen0-up is the kernel running in dom0.

It appears that a lot of time is spent running timers and getting the current time. Not being familiar with the code, I am now crawling through it to see how timers are handled and how the xen-vnif PV driver uses them. I'm also looking for potential differences between rev2 and rev8 since the network performance of rev2 was pretty equal to that of a PV domain. Knowing the code, you may have a solution before I find the problem.

Steve D.

P.S. This just in from a test running while I typed the above. I noticed that qemu will start a "gui_timer" when VNC is not used. I normally run without graphics (nographic=1 in the domain config file). I changed the config file to use VNC. The qemu-dm CPU utilization in dom0 dropped to
below 10%. The network performance improved from 0.19 Mb/s to 9.75 Mb/s
(still less than the 23.07 Mb/s for a fully virtualized domain). It appears there is some interaction between using the xen-vnif driver and the qemu timer code. I'm still exploring.

#12 lore raw

Re: Paravirtualised drivers for fully virtualised domains, rev9

Quoted 3 lines

Here is what I have found so far in trying to chase down the cause of the slowdown.
The qemu-dm process is running 99.9% of the CPU on dom0.

That seems very wrong. When I try this, the device model is almost completely idle. Could you see what strace says, please, or if there are any strange messages in the /var/log/qemu-dm. file?

Quoted 3 lines

It appears that a lot of time is spent running timers and getting the current time. Not being familiar with the code, I am now crawling through it to see how timers are handled and how the xen-vnif PV driver uses them.

Timer handling isn't really changed by any of these patches. Patch 02.ioemu_xen_evtchns.diff is in vaguely the same area, but I can't see how it could cause the problems you're seeing, assuming your hypervisor and libxc are up to date.

What changeset of xen-unstable did you apply the patches to?

Quoted 6 lines

P.S. This just in from a test running while I typed the above. I noticed that qemu will start a "gui_timer" when VNC is not used. I normally run without graphics (nographic=1 in the domain config file). I changed the config file to use VNC. The qemu-dm CPU utilization in dom0 dropped to
below 10%. The network performance improved from 0.19 Mb/s to 9.75 Mb/s
(still less than the 23.07 Mb/s for a fully virtualized domain).

When I try this, I see about 1600Mb/s between dom0 and a paravirtualised domU, about 30Mb/s between dom0 and an ioemu domU, and about 1200Mb/s between dom0 and an HVM domU running these drivers, all collected using netpipe-tcp. That is a regression, but much smaller than you're seeing.

There are a couple of obvious things to check:

1) Do the statistics reported by ifconfig show any errors?
2) How often is the event channel interrupt firing according to /proc/interrupts? I see about 50k-150k/second.
3) Is there any packet loss when you ping a domain? Start your test and run a ping in parallel.

The other thing is that these drivers seem to be very sensitive to kernel debugging options in the domU. If you've got anything enabled in the kernel hacking menu it might be worth trying again with that switched off.

Quoted 2 lines

It appears there is some interaction between using the xen-vnif driver and the qemu timer code. I'm still exploring.

I'd be happier if I could reproduce this problem here. Are you running SMP? PAE? 64 bit? What kernel are you running in the domU?

Steven.

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

#13 lore raw

Re: Paravirtualised drivers for fully virtualised domains, rev9

Quoted 6 lines · Steven Smith
Quoted 3 lines

Here is what I have found so far in trying to chase down the cause of the slowdown.
The qemu-dm process is running 99.9% of the CPU on dom0.

That seems very wrong. When I try this, the device model is almost completely idle. Could you see what strace says, please, or if there are any strange messages in the /var/log/qemu-dm. file?

I haven't tried the patches being discussed in this thread but I'm seeing similar problems with qemu-dm anyway...

I've been looking into bugzilla 725 and I'm also seeing 100% cpu usage by qemu-dm. xm-test uses the nographic flag and I find that if this is not set then the cpu usage drops to normal levels and the test passes.

Quoted 3 lines
Quoted 3 lines

It appears that a lot of time is spent running timers and getting the current time.

Yes, this is what I was seeing with the nographic flag set.

Quoted 8 lines

Not being familiar with the code, I am now crawling through

Quoted 1 line

it to see how timers are handled and how the xen-vnif PV driver uses them.

Timer handling isn't really changed by any of these patches. Patch 02.ioemu_xen_evtchns.diff is in vaguely the same area, but I can't see how it could cause the problems you're seeing, assuming your hypervisor and libxc are up to date.

What changeset of xen-unstable did you apply the patches to?

I've been seeing the problem on recent unstable changesets without the patches. Changesets 10992, 10949 for example.

Quoted 8 lines
Quoted 4 lines

P.S. This just in from a test running while I typed the above. I noticed that qemu will start a "gui_timer" when VNC is not used. I normally run without graphics (nographic=1 in the domain config file).

I changed the

Quoted 2 lines

config file to use VNC. The qemu-dm CPU utilization in dom0 dropped to below 10%.

Yep, that's what I see without the patches.

Quoted 31 lines

The network performance improved from 0.19 Mb/s to 9.75 Mb/s

Quoted 1 line

(still less than the 23.07 Mb/s for a fully virtualized domain).

When I try this, I see about 1600Mb/s between dom0 and a paravirtualised domU, about 30Mb/s between dom0 and an ioemu domU, and about 1200Mb/s between dom0 and an HVM domU running these drivers, all collected using netpipe-tcp. That is a regression, but much smaller than you're seeing.

There are a couple of obvious things to check:

1) Do the statistics reported by ifconfig show any errors?
2) How often is the event channel interrupt firing according to /proc/interrupts? I see about 50k-150k/second.
3) Is there any packet loss when you ping a domain? Start your test and run a ping in parallel.

The other thing is that these drivers seem to be very sensitive to kernel debugging options in the domU. If you've got anything enabled in the kernel hacking menu it might be worth trying again with that switched off.

Quoted 2 lines

It appears there is some interaction between using the xen-vnif driver and the qemu timer code. I'm still exploring.

I'd be happier if I could reproduce this problem here. Are you running SMP? PAE? 64 bit? What kernel are you running in the domU?

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

#14 lore raw

Re: Paravirtualised drivers for fully virtualised domains, rev9

Quoted 9 lines
Quoted 6 lines
Quoted 3 lines

Here is what I have found so far in trying to chase down the cause of the slowdown.
The qemu-dm process is running 99.9% of the CPU on dom0.

That seems very wrong. When I try this, the device model is almost completely idle. Could you see what strace says, please, or if there are any strange messages in the /var/log/qemu-dm. file?

I've been looking into bugzilla 725 and I'm also seeing 100% cpu usage by qemu-dm. xm-test uses the nographic flag and I find that if this is not set then the cpu usage drops to normal levels and the test passes.

Does the attached patch help?

Steven.

tools/ioemu/vl.c +1 -1
diff -r fd10729d891f tools/ioemu/vl.c
@@ -6036,7 +6036,7 @@ int main(int argc, char **argv)
                 }
                 break;
             case QEMU_OPTION_nographic:
-                pstrcpy(monitor_device, sizeof(monitor_device), "stdio");
+                pstrcpy(monitor_device, sizeof(monitor_device), "null");
                 if(!strcmp(serial_devices[0], "vc"))
                     pstrcpy(serial_devices[0], sizeof(serial_devices[0]),
                             "stdio");

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

#15 lore raw

Re: Paravirtualised drivers for fully virtualised domains, rev9

In reply to Steven Smith

Steven Smith <[email protected]> wrote on 08/11/2006 05:17:04 AM:

Quoted 1 line
Quoted 1 line

Here is what I have found so far in trying to chase down the cause of

the

Quoted 5 lines
Quoted 2 lines

slowdown.
The qemu-dm process is running 99.9% of the CPU on dom0.

That seems very wrong. When I try this, the device model is almost completely idle. Could you see what strace says, please, or if there are any strange messages in the /var/log/qemu-dm. file?

Looks like I jumped the gun in relating the 99.9% CPU usage for qemu-dm and the network. I start up the HVM domain and without running any tests qemu-dm is chewing up 99.9% of the CPU in dom0. So it appears that the 100% CPU qemu usage is a problem by itself. Looks like the same problem Harry Butterworth is seeing.

Quoted 2 lines
Quoted 2 lines

It appears that a lot of time is spent running timers and getting the current time. Not being familiar with the code, I am now crawling

through

Quoted 1 line
Quoted 1 line

it to see how timers are handled and how the xen-vnif PV driver uses

them.

Quoted 6 lines

Timer handling isn't really changed by any of these patches. Patch 02.ioemu_xen_evtchns.diff is in vaguely the same area, but I can't see how it could cause the problems you're seeing, assuming your hypervisor and libxc are up to date.

What changeset of xen-unstable did you apply the patches to?

10968

Quoted 1 line
Quoted 1 line

P.S. This just in from a test running while I typed the above. I

noticed

Quoted 1 line
Quoted 1 line

that qemu will start a "gui_timer" when VNC is not used. I normally

run

Quoted 1 line
Quoted 1 line

without graphics (nographic=1 in the domain config file). I changed

the

Quoted 2 lines
Quoted 2 lines

config file to use VNC. The qemu-dm CPU utilization in dom0 dropped to
below 10%. The network performance improved from 0.19 Mb/s to 9.75

Mb/s

Quoted 10 lines
Quoted 1 line

(still less than the 23.07 Mb/s for a fully virtualized domain).

When I try this, I see about 1600Mb/s between dom0 and a paravirtualised domU, about 30Mb/s between dom0 and an ioemu domU, and about 1200Mb/s between dom0 and an HVM domU running these drivers, all collected using netpipe-tcp. That is a regression, but much smaller than you're seeing.

There are a couple of obvious things to check:

1) Do the statistics reported by ifconfig show any errors?

No errors.

Quoted 2 lines

2) How often is the event channel interrupt firing according to /proc/interrupts? I see about 50k-150k/second.

I'm seeing ~ 500/s when netpipe-tcp reports decent throughput at smaller buffer sizes and then ~50/s when the throughput drops at larger buffer sizes.

Quoted 2 lines

3) Is there any packet loss when you ping a domain? Start your test and run a ping in parallel.

No packet loss.

Quoted 4 lines

The other thing is that these drivers seem to be very sensitive to kernel debugging options in the domU. If you've got anything enabled in the kernel hacking menu it might be worth trying again with that switched off.

Kernel debugging is on. I also have Oprofile enabled. I'll build a kernel without those and see if it helps.

Quoted 4 lines
Quoted 2 lines

It appears there is some interaction between using the xen-vnif driver and the qemu timer code. I'm still exploring.

I'd be happier if I could reproduce this problem here. Are you running SMP? PAE? 64 bit? What kernel are you running in the domU?

UP kernels in both the domU and dom0 (although the scheduler likes to move the 1 vcpu in dom0 around to different physical CPUs). 64-bit kernels on both.
Steve D.

#16 lore raw

Re: Paravirtualised drivers for fully virtualised domains, rev9

Quoted 4 lines
Quoted 1 line
Quoted 1 line

Here is what I have found so far in trying to chase down the cause of

the

Quoted 2 lines
Quoted 2 lines

slowdown.
The qemu-dm process is running 99.9% of the CPU on dom0.

Quoted 8 lines
Quoted 3 lines

That seems very wrong. When I try this, the device model is almost completely idle. Could you see what strace says, please, or if there are any strange messages in the /var/log/qemu-dm. file?

Looks like I jumped the gun in relating the 99.9% CPU usage for qemu-dm and the network. I start up the HVM domain and without running any tests qemu-dm is chewing up 99.9% of the CPU in dom0. So it appears that the 100% CPU qemu usage is a problem by itself. Looks like the same problem Harry Butterworth is seeing.

qemu-dm misbehaving could certainly lead to the netif going very slowly.

Quoted 5 lines
Quoted 2 lines

2) How often is the event channel interrupt firing according to /proc/interrupts? I see about 50k-150k/second.

I'm seeing ~ 500/s when netpipe-tcp reports decent throughput at smaller buffer sizes and then ~50/s when the throughput drops at larger buffer sizes.

How large do they have to be to cause problems?

Quoted 6 lines
Quoted 4 lines

The other thing is that these drivers seem to be very sensitive to kernel debugging options in the domU. If you've got anything enabled in the kernel hacking menu it might be worth trying again with that switched off.

Kernel debugging is on. I also have Oprofile enabled. I'll build a kernel without those and see if it helps.

Worth a shot. It shouldn't cause the problems with qemu, though.

Quoted 7 lines
Quoted 4 lines
Quoted 2 lines

It appears there is some interaction between using the xen-vnif driver and the qemu timer code. I'm still exploring.

I'd be happier if I could reproduce this problem here. Are you running SMP? PAE? 64 bit? What kernel are you running in the domU?

UP kernels in both the domU and dom0 (although the scheduler likes to move the 1 vcpu in dom0 around to different physical CPUs). 64-bit kernels on both.

I've mostly been testing with 32 bit PAE. I'll have a go with a 64 bit system on Monday.

Thanks,

Steven.

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

#17 lore raw

Re: Paravirtualised drivers for fully virtualised domains, rev9

Steven Smith <[email protected]> wrote on 08/12/2006 03:32:23 AM:

Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line

Here is what I have found so far in trying to chase down the cause

of

Quoted 7 lines
Quoted 7 lines

the

Quoted 5 lines
Quoted 2 lines

slowdown.
The qemu-dm process is running 99.9% of the CPU on dom0.

That seems very wrong. When I try this, the device model is almost completely idle. Could you see what strace says, please, or if there are any strange messages in the /var/log/qemu-dm. file?

Looks like I jumped the gun in relating the 99.9% CPU usage for qemu-dm

and

Quoted 3 lines
Quoted 3 lines

the network. I start up the HVM domain and without running any tests qemu-dm is chewing up 99.9% of the CPU in dom0. So it appears that the 100% CPU qemu usage is a problem by itself. Looks like the same

problem

Quoted 3 lines
Quoted 1 line

Harry Butterworth is seeing.

qemu-dm misbehaving could certainly lead to the netif going very slowly.

Agreed. I applied the patch to sent to Harry. I appears to fix the 99.9% CPU usage problem.

Quoted 3 lines
Quoted 3 lines
Quoted 2 lines

2) How often is the event channel interrupt firing according to /proc/interrupts? I see about 50k-150k/second.

I'm seeing ~ 500/s when netpipe-tcp reports decent throughput at

smaller

Quoted 3 lines
Quoted 2 lines

buffer sizes and then ~50/s when the throughput drops at larger buffer sizes.

How large do they have to be to cause problems?

I'm noticing a drop off in throughput at a buffer size of 3069. Here is a snip from the output from netpipe-tcp.

 43:    1021 bytes    104 times -->     20.27 Mbps in     384.28 usec
 44:    1024 bytes    129 times -->     20.14 Mbps in     387.86 usec
 45:    1027 bytes    129 times -->     20.17 Mbps in     388.46 usec
 46:    1533 bytes    129 times -->     22.94 Mbps in     509.95 usec
 47:    1536 bytes    130 times -->     23.00 Mbps in     509.48 usec
 48:    1539 bytes    130 times -->     23.12 Mbps in     507.92 usec
 49:    2045 bytes     66 times -->     30.02 Mbps in     519.66 usec
 50:    2048 bytes     96 times -->     30.50 Mbps in     512.35 usec
 51:    2051 bytes     97 times -->     30.61 Mbps in     511.24 usec
 52:    3069 bytes     98 times -->      0.61 Mbps in   38672.52 usec
 53:    3072 bytes      3 times -->      0.48 Mbps in   48633.50 usec
 54:    3075 bytes      3 times -->      0.48 Mbps in   48542.50 usec
 55:    4093 bytes      3 times -->      0.64 Mbps in   48516.35 usec
 56:    4096 bytes      3 times -->      0.65 Mbps in   48449.48 usec
 57:    4099 bytes      3 times -->      0.64 Mbps in   48575.84 usec

The throughput remains low for the remainder of the buffer sizes which go to 49155 before the benchmarks exits due to the requests taking more than a second.

Quoted 5 lines
Quoted 5 lines
Quoted 4 lines

The other thing is that these drivers seem to be very sensitive to kernel debugging options in the domU. If you've got anything enabled in the kernel hacking menu it might be worth trying again with that switched off.

Kernel debugging is on. I also have Oprofile enabled. I'll build a

kernel

Quoted 2 lines
Quoted 1 line

without those and see if it helps.

Worth a shot. It shouldn't cause the problems with qemu, though.

I built a kernel without kernel debugging and without instrumentation. The results were very similar.

 43:    1021 bytes    104 times -->     20.27 Mbps in     384.28 usec
 44:    1024 bytes    129 times -->     20.30 Mbps in     384.91 usec
 45:    1027 bytes    130 times -->     20.19 Mbps in     388.02 usec
 46:    1533 bytes    129 times -->     22.97 Mbps in     509.25 usec
 47:    1536 bytes    130 times -->     23.02 Mbps in     509.12 usec
 48:    1539 bytes    131 times -->     23.04 Mbps in     509.65 usec
 49:    2045 bytes     65 times -->     30.41 Mbps in     513.07 usec
 50:    2048 bytes     97 times -->     30.49 Mbps in     512.49 usec
 51:    2051 bytes     97 times -->     30.45 Mbps in     513.85 usec
 52:    3069 bytes     97 times -->      0.75 Mbps in   31141.34 usec
 53:    3072 bytes      3 times -->      0.48 Mbps in   48596.50 usec
 54:    3075 bytes      3 times -->      0.48 Mbps in   48876.17 usec
 55:    4093 bytes      3 times -->      0.64 Mbps in   48489.33 usec
 56:    4096 bytes      3 times -->      0.64 Mbps in   48606.63 usec
 57:    4099 bytes      3 times -->      0.64 Mbps in   48568.33 usec

Again, the throughput remains low for the remainder of the buffer sizes which go to 49155

The above tests were run to netpipe-tcp running on another machine. When I run to netpipe-tcp running in dom0 I get better throughput but also some strange behavior. Again, a snip from the output.

 43:    1021 bytes    606 times -->    140.14 Mbps in      55.58 usec
 44:    1024 bytes    898 times -->    141.16 Mbps in      55.35 usec
 45:    1027 bytes    905 times -->    138.93 Mbps in      56.40 usec
 46:    1533 bytes    890 times -->    133.74 Mbps in      87.45 usec
 47:    1536 bytes    762 times -->    132.82 Mbps in      88.23 usec
 48:    1539 bytes    756 times -->    132.01 Mbps in      88.95 usec
 49:    2045 bytes    376 times -->    172.36 Mbps in      90.52 usec
 50:    2048 bytes    552 times -->    177.41 Mbps in      88.07 usec
 51:    2051 bytes    568 times -->    176.12 Mbps in      88.85 usec
 52:    3069 bytes    564 times -->      0.44 Mbps in   53173.74 usec
 53:    3072 bytes      3 times -->      0.44 Mbps in   53249.32 usec
 54:    3075 bytes      3 times -->      0.50 Mbps in   46639.64 usec
 55:    4093 bytes      3 times -->    321.94 Mbps in      97.00 usec
 56:    4096 bytes    515 times -->    287.05 Mbps in     108.87 usec
 57:    4099 bytes    459 times -->      2.69 Mbps in   11615.94 usec
 58:    6141 bytes      4 times -->      0.63 Mbps in   74535.64 usec
 59:    6144 bytes      3 times -->      0.35 Mbps in  133242.01 usec
 60:    6147 bytes      3 times -->      0.35 Mbps in  133311.47 usec
 61:    8189 bytes      3 times -->      0.62 Mbps in  100391.51 usec
 62:    8192 bytes      3 times -->      1.05 Mbps in   59535.66 usec
 63:    8195 bytes      3 times -->      0.63 Mbps in   99598.69 usec
 64:   12285 bytes      3 times -->      0.47 Mbps in  199974.34 usec
 65:   12288 bytes      3 times -->      4.70 Mbps in   19933.34 usec
 66:   12291 bytes      3 times -->      4.70 Mbps in   19933.30 usec
 67:   16381 bytes      3 times -->      0.71 Mbps in  176984.35 usec
 68:   16384 bytes      3 times -->      0.93 Mbps in  134929.50 usec
 69:   16387 bytes      3 times -->      0.93 Mbps in  134930.33 usec

The throughput drops at a buffer size of 3069 as in the prior runs, but it regains at 4093 and 4096, and then drops off again for the remainder of the test.

I don't know offhand why the throughput drops off. I'll look into it. Any tips would be helpful.

For comparison, an FV domU running netpipe-tcp to another machine will ramp up to about 20 Mbps at a buffer size of around 128 KB and then taper off to 17 Mbps. A PV domU will ramp up to around 750 Mbps at a buffer size of about 2 MB and maintain that throughput to an 8 MB buffer when the test stopped. On dom0 netpipe-tcp running to another machine ramps up to around 850 Mbps at a buffer sizes from 3 MB to 8 MB where the test stopped.

Steve D.

#18 lore raw

Re: Paravirtualised drivers for fully virtualised domains, rev9

Quoted 11 lines
Quoted 1 line
Quoted 1 line

Looks like I jumped the gun in relating the 99.9% CPU usage for qemu-dm

and

Quoted 3 lines
Quoted 3 lines

the network. I start up the HVM domain and without running any tests qemu-dm is chewing up 99.9% of the CPU in dom0. So it appears that the 100% CPU qemu usage is a problem by itself. Looks like the same

problem

Quoted 3 lines
Quoted 1 line

Harry Butterworth is seeing.

qemu-dm misbehaving could certainly lead to the netif going very slowly.

Agreed. I applied the patch to sent to Harry. I appears to fix the 99.9% CPU usage problem.

Great, thanks.

Quoted 9 lines
Quoted 3 lines
Quoted 3 lines
Quoted 2 lines

2) How often is the event channel interrupt firing according to /proc/interrupts? I see about 50k-150k/second.

I'm seeing ~ 500/s when netpipe-tcp reports decent throughput at

smaller

Quoted 3 lines
Quoted 2 lines

buffer sizes and then ~50/s when the throughput drops at larger buffer sizes.

How large do they have to be to cause problems?

I'm noticing a drop off in throughput at a buffer size of 3069. Here is a snip from the output from netpipe-tcp.

What are the MTUs on the interfaces, according to ifconfig, in dom0 and domU?

Quoted 2 lines

I don't know offhand why the throughput drops off. I'll look into it. Any tips would be helpful.

tcpdump in the domU and dom0 might be enlightening, just to see if any packets are getting dropped or truncated. The connections probably slow enough when it's misbehaving for it to keep up.

Are you running through the bridge? It's unlikely to be that, but it would be good to eliminate it as a variable by doing some domU<->dom0 tests without it involved.

What version of Linux are you running in the domU? Does it have any patches applied?

Steven.

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

#19 lore raw

Re: Paravirtualised drivers for fully virtualised domains, rev9

Steven Smith <[email protected]> wrote on 08/15/2006 02:27:50 AM:

Quoted 5 lines
Quoted 5 lines
Quoted 3 lines
Quoted 3 lines
Quoted 2 lines

2) How often is the event channel interrupt firing according to /proc/interrupts? I see about 50k-150k/second.

I'm seeing ~ 500/s when netpipe-tcp reports decent throughput at

smaller

Quoted 1 line
Quoted 1 line

buffer sizes and then ~50/s when the throughput drops at larger

buffer

Quoted 3 lines
Quoted 3 lines
Quoted 2 lines
Quoted 1 line

sizes.

How large do they have to be to cause problems?

I'm noticing a drop off in throughput at a buffer size of 3069. Here

is a

Quoted 3 lines
Quoted 1 line

snip from the output from netpipe-tcp.

What are the MTUs on the interfaces, according to ifconfig, in dom0 and domU?

MTUs on all the interfaces are 1500.

Quoted 1 line
Quoted 1 line

I don't know offhand why the throughput drops off. I'll look into it.

Any

Quoted 4 lines
Quoted 1 line

tips would be helpful.

tcpdump in the domU and dom0 might be enlightening, just to see if any packets are getting dropped or truncated. The connections probably slow enough when it's misbehaving for it to keep up.

tcpdump on both dom0 and domU shows no packets dropped and none truncated.

I noticed lines such as:

16:28:18.596654 IP dib.ltc.austin.ibm.com > hvm1.ltc.austin.ibm.com: ICMP dib.ltc.austin.ibm.com unreachable - need to frag (mtu 1500), length 556

in the tcpdump output during the slow down. (dib.ltc.austin.ibm.com is dom0.) Knowing very little about the TCP protocol, I'm not sure if that indicates a problem.

Quoted 3 lines

Are you running through the bridge? It's unlikely to be that, but it would be good to eliminate it as a variable by doing some domU<->dom0 tests without it involved.

I am running through the bridge, the default Xen setup.

I doubt the bridge is the problem since I also use the bridge for a PV domU and an FV domU and those don't see a slowdown.

Quoted 2 lines

What version of Linux are you running in the domU? Does it have any patches applied?

SLES 10 beta 10. (Yes, SLES 10 has released. We haven't updated our automated testing framework yet.) I'm running a 2.6.16.13 kernel.org kernel, the current base kernel for xen-unstable. No patches applied.

Here is the kernel config from /proc/config.gz in the HVM domU. (See attached file: hvm_kernel_config)

Thanks for your attention.

Steve D.

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

#20 lore raw

Re: Paravirtualised drivers for fully virtualised domains, rev9

In reply to Steve Dobbelstein
Quoted 5 lines

The good news is that I don't get zombies anymore. The bad news is that I'm still getting very poor network performance running netperf, worse than a fully virtualized domain. I thought it was something wrong with my test setup when I was testing rev8, but the test setup looks good and the results are repeatable.

This should be fixed in rev11.

Thanks,

Steven.

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

#21 lore raw

Paravirtualised drivers for fully virtualised domains, rev11

In reply to Steven Smith

There's a new version of this patch up at
http://www.cl.cam.ac.uk/~sos22/pv-on-hvm/rev11 . The main change here is that I now do a slightly more thorough job of disabling GSO when compiled against kernels which don't support it. These patches should apply against changeset 11139:ff124973a28a.

Steven.

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