---
 Documentation/lguest/lguest.c |   20 ++++++++++++++++++--
 kernel/stop_machine.c         |    4 ++++
 2 files changed, 22 insertions(+), 2 deletions(-)

diff -r e125e80ff266 Documentation/lguest/lguest.c
--- a/Documentation/lguest/lguest.c	Tue Jul 01 21:17:44 2008 +1000
+++ b/Documentation/lguest/lguest.c	Wed Jul 02 16:53:16 2008 +1000
@@ -161,6 +161,12 @@ struct virtqueue
 
 	/* Outstanding buffers */
 	unsigned int inflight;
+
+	/* Maximum number of buffers pending last time we timed out. */
+	unsigned int last_timeout_bufs;
+
+	/* Threshold we're aiming for notifications. */
+	unsigned int threshold;
 
 	/* Is this blocked awaiting a timer? */
 	bool blocked;
@@ -935,9 +941,16 @@ static void handle_net_output(int fd, st
 		num++;
 	}
 
-	/* Block further kicks, and set up a timer if we saw anything. */
-	if (!timeout && num)
+	if (timeout)
+		vq->last_timeout_bufs = num;
+	else if (num) {
+		/* Block further kicks and set up a timer if we saw anything. */
 		block_vq(vq);
+		if (vq->threshold < vq->last_timeout_bufs)
+			vq->threshold++;
+		vring_avail_threshold(&vq->vring)
+			= vq->vring.avail->idx + vq->threshold;
+	}
 }
 
 /* This is where we handle a packet coming in from the tun device to our
@@ -1212,6 +1225,8 @@ static void add_virtqueue(struct device 
 	vq->next = NULL;
 	vq->dev = dev;
 	vq->inflight = 0;
+	vq->last_timeout_bufs = 0;
+	vq->threshold = 0;
 	vq->blocked = false;
 
 	/* Initialize the configuration. */
@@ -1557,6 +1572,7 @@ static void setup_tun_net(char *arg)
 	/* Tell Guest what MAC address to use. */
 	add_feature(dev, VIRTIO_NET_F_MAC);
 	add_feature(dev, VIRTIO_F_NOTIFY_ON_EMPTY);
+	add_feature(dev, VIRTIO_RING_F_THRESHOLD);
 	/* Expect Guest to handle everything except UFO */
 	add_feature(dev, VIRTIO_NET_F_CSUM);
 	add_feature(dev, VIRTIO_NET_F_GUEST_CSUM);
diff -r e125e80ff266 kernel/stop_machine.c
--- a/kernel/stop_machine.c	Tue Jul 01 21:17:44 2008 +1000
+++ b/kernel/stop_machine.c	Wed Jul 02 16:53:16 2008 +1000
@@ -192,6 +192,9 @@ static void ipi_func(void *info)
 	struct ipi_data *ipi = info;
 	bool ok = false;
 
+	printk("get_irq_regs(%i) = %p\n", smp_processor_id(), get_irq_regs());
+	goto fail;
+
 	if (user_mode(get_irq_regs()))
 		ok = true;
 	else {
@@ -206,6 +209,7 @@ static void ipi_func(void *info)
 #endif
 	}
 
+fail:
 	if (!ok) {
 		/* Mark our failure before acking. */
 		atomic_inc(&ipi->failed);
