lguest: Debugging patch for lguest network performance
---
 Documentation/lguest/lguest.c |   15 +++++++++++++++
 1 file changed, 15 insertions(+)

diff -r 4eeec0b4475a Documentation/lguest/lguest.c
--- a/Documentation/lguest/lguest.c	Mon Jul 28 11:29:27 2008 +1000
+++ b/Documentation/lguest/lguest.c	Mon Jul 28 11:31:40 2008 +1000
@@ -173,6 +173,8 @@ struct virtqueue
 	/* Is this blocked awaiting a timer? */
 	bool blocked;
 };
+
+static unsigned int net_xmit_notify, net_recv_notify;
 
 /* Remember the arguments to the program so we can "reboot" */
 static char **main_args;
@@ -866,6 +868,9 @@ static bool handle_console_input(int fd,
 				/* Just in case Waker is blocked in BREAK, send
 				 * unbreak now. */
 				write(fd, args, sizeof(args));
+				printf("network xmit %u recv %u timeout %u usec %u\n",
+				       net_xmit_notify, net_recv_notify,
+				       net_timeout, timeout_usec);
 				exit(2);
 			}
 			abort->count = 0;
@@ -885,6 +890,8 @@ static void handle_console_output(int fd
 	unsigned int head, out, in;
 	int len;
 	struct iovec iov[vq->vring.num];
+
+	net_xmit_notify++;
 
 	/* Keep getting output buffers from the Guest until we run out. */
 	while ((head = get_vq_desc(vq, iov, &out, &in)) != vq->vring.num) {
@@ -994,6 +1001,14 @@ static bool handle_tun_input(int fd, str
  * delivery because Guest didn't have any buffers. */
 static void enable_fd(int fd, struct virtqueue *vq, bool timeout)
 {
+	add_device_fd(vq->dev->fd);
+	/* Tell waker to listen to it again */
+	write(waker_fd, &vq->dev->fd, sizeof(vq->dev->fd));
+}
+
+static void net_enable_fd(int fd, struct virtqueue *vq)
+{
+	net_recv_notify++;
 	add_device_fd(vq->dev->fd);
 	/* Snap the Waker out of its select loop. */
 	write(waker_fds.pipe[1], "", 1);
