[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PATCH 01/13] net: notify iothread after flushing queue
From: |
Stefan Hajnoczi |
Subject: |
[Qemu-devel] [PATCH 01/13] net: notify iothread after flushing queue |
Date: |
Fri, 14 Sep 2012 09:46:48 +0100 |
From: Paolo Bonzini <address@hidden>
virtio-net has code to flush the queue and notify the iothread
whenever new receive buffers are added by the guest. That is
fine, and indeed we need to do the same in all other drivers.
However, notifying the iothread should be work for the network
subsystem. And since we are at it we can add a little smartness:
if some of the queued packets already could not be delivered,
there is no need to notify the iothread.
Reported-by: Luigi Rizzo <address@hidden>
Cc: Stefan Hajnoczi <address@hidden>
Cc: Jan Kiszka <address@hidden>
Signed-off-by: Paolo Bonzini <address@hidden>
Reviewed-by: Amos Kong <address@hidden>
Signed-off-by: Stefan Hajnoczi <address@hidden>
---
hw/virtio-net.c | 4 ----
net.c | 7 ++++++-
net/queue.c | 5 +++--
net/queue.h | 2 +-
4 files changed, 10 insertions(+), 8 deletions(-)
diff --git a/hw/virtio-net.c b/hw/virtio-net.c
index b1998b2..6490743 100644
--- a/hw/virtio-net.c
+++ b/hw/virtio-net.c
@@ -447,10 +447,6 @@ static void virtio_net_handle_rx(VirtIODevice *vdev,
VirtQueue *vq)
VirtIONet *n = to_virtio_net(vdev);
qemu_flush_queued_packets(&n->nic->nc);
-
- /* We now have RX buffers, signal to the IO thread to break out of the
- * select to re-poll the tap file descriptor */
- qemu_notify_event();
}
static int virtio_net_can_receive(NetClientState *nc)
diff --git a/net.c b/net.c
index e5d25d4..d9ba1e5 100644
--- a/net.c
+++ b/net.c
@@ -357,7 +357,12 @@ void qemu_flush_queued_packets(NetClientState *nc)
{
nc->receive_disabled = 0;
- qemu_net_queue_flush(nc->send_queue);
+ if (qemu_net_queue_flush(nc->send_queue)) {
+ /* We emptied the queue successfully, signal to the IO thread to repoll
+ * the file descriptor (for tap, for example).
+ */
+ qemu_notify_event();
+ }
}
static ssize_t qemu_send_packet_async_with_flags(NetClientState *sender,
diff --git a/net/queue.c b/net/queue.c
index e8030aa..6e64091 100644
--- a/net/queue.c
+++ b/net/queue.c
@@ -228,7 +228,7 @@ void qemu_net_queue_purge(NetQueue *queue, NetClientState
*from)
}
}
-void qemu_net_queue_flush(NetQueue *queue)
+bool qemu_net_queue_flush(NetQueue *queue)
{
while (!QTAILQ_EMPTY(&queue->packets)) {
NetPacket *packet;
@@ -244,7 +244,7 @@ void qemu_net_queue_flush(NetQueue *queue)
packet->size);
if (ret == 0) {
QTAILQ_INSERT_HEAD(&queue->packets, packet, entry);
- break;
+ return false;
}
if (packet->sent_cb) {
@@ -253,4 +253,5 @@ void qemu_net_queue_flush(NetQueue *queue)
g_free(packet);
}
+ return true;
}
diff --git a/net/queue.h b/net/queue.h
index 9d44a9b..fc02b33 100644
--- a/net/queue.h
+++ b/net/queue.h
@@ -53,6 +53,6 @@ ssize_t qemu_net_queue_send_iov(NetQueue *queue,
NetPacketSent *sent_cb);
void qemu_net_queue_purge(NetQueue *queue, NetClientState *from);
-void qemu_net_queue_flush(NetQueue *queue);
+bool qemu_net_queue_flush(NetQueue *queue);
#endif /* QEMU_NET_QUEUE_H */
--
1.7.10.4
- [Qemu-devel] [PULL 00/13] Net patches, Stefan Hajnoczi, 2012/09/14
- [Qemu-devel] [PULL 00/13] Net patches, Stefan Hajnoczi, 2012/09/14
- [Qemu-devel] [PATCH 02/13] e1000: flush queue whenever can_receive can go from false to true, Stefan Hajnoczi, 2012/09/14
- [Qemu-devel] [PATCH 01/13] net: notify iothread after flushing queue,
Stefan Hajnoczi <=
- [Qemu-devel] [PATCH 03/13] xen: flush queue when getting an event, Stefan Hajnoczi, 2012/09/14
- [Qemu-devel] [PATCH 04/13] eepro100: Fix network hang when rx buffers run out, Stefan Hajnoczi, 2012/09/14
- [Qemu-devel] [PATCH 05/13] net: add receive_disabled logic to iov delivery path, Stefan Hajnoczi, 2012/09/14
- [Qemu-devel] [PATCH 07/13] net: add -netdev options to man page, Stefan Hajnoczi, 2012/09/14
- [Qemu-devel] [PATCH 08/13] net: clean up usbnet_receive(), Stefan Hajnoczi, 2012/09/14
- [Qemu-devel] [PATCH 06/13] net: do not report queued packets as sent, Stefan Hajnoczi, 2012/09/14
- [Qemu-devel] [PATCH 11/13] net: asynchronous send/receive infrastructure for net/socket.c, Stefan Hajnoczi, 2012/09/14
- [Qemu-devel] [PATCH 09/13] net: fix usbnet_receive() packet drops, Stefan Hajnoczi, 2012/09/14
- [Qemu-devel] [PATCH 12/13] net: EAGAIN handling for net/socket.c UDP, Stefan Hajnoczi, 2012/09/14
- [Qemu-devel] [PATCH 10/13] net: broadcast hub packets if at least one port can receive, Stefan Hajnoczi, 2012/09/14