提交 95c517c0 编写于 作者: R Rusty Russell

lguest: avoid sending interrupts to Guest when no activity occurs.

If we track how many buffers we've used, we can tell whether we really
need to interrupt the Guest.  This happens as a side effect of
spurious notifications.

Spurious notifications happen because it can take a while before the
Host thread wakes up and sets the VRING_USED_F_NO_NOTIFY flag, and
meanwhile the Guest can more notifications.

A real fix would be to use wake counts, rather than a suppression
flag, but the practical difference is generally in the noise: the
interrupt is usually coalesced into a pending one anyway so we just
save a system call which isn't clearly measurable.

				Secs	Spurious IRQS
1G TCP Guest->Host:		3.93	58
1M normal pings:		100	72
1M 1k pings (-l 120):		57	492904
Signed-off-by: NRusty Russell <rusty@rustcorp.com.au>
上级 38bc2b8c
...@@ -151,6 +151,9 @@ struct virtqueue ...@@ -151,6 +151,9 @@ struct virtqueue
/* Last available index we saw. */ /* Last available index we saw. */
u16 last_avail_idx; u16 last_avail_idx;
/* How many are used since we sent last irq? */
unsigned int pending_used;
/* Eventfd where Guest notifications arrive. */ /* Eventfd where Guest notifications arrive. */
int eventfd; int eventfd;
...@@ -556,6 +559,11 @@ static void trigger_irq(struct virtqueue *vq) ...@@ -556,6 +559,11 @@ static void trigger_irq(struct virtqueue *vq)
{ {
unsigned long buf[] = { LHREQ_IRQ, vq->config.irq }; unsigned long buf[] = { LHREQ_IRQ, vq->config.irq };
/* Don't inform them if nothing used. */
if (!vq->pending_used)
return;
vq->pending_used = 0;
/* If they don't want an interrupt, don't send one, unless empty. */ /* If they don't want an interrupt, don't send one, unless empty. */
if ((vq->vring.avail->flags & VRING_AVAIL_F_NO_INTERRUPT) if ((vq->vring.avail->flags & VRING_AVAIL_F_NO_INTERRUPT)
&& lg_last_avail(vq) != vq->vring.avail->idx) && lg_last_avail(vq) != vq->vring.avail->idx)
...@@ -647,6 +655,7 @@ static void add_used(struct virtqueue *vq, unsigned int head, int len) ...@@ -647,6 +655,7 @@ static void add_used(struct virtqueue *vq, unsigned int head, int len)
/* Make sure buffer is written before we update index. */ /* Make sure buffer is written before we update index. */
wmb(); wmb();
vq->vring.used->idx++; vq->vring.used->idx++;
vq->pending_used++;
} }
/* And here's the combo meal deal. Supersize me! */ /* And here's the combo meal deal. Supersize me! */
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册