[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PATCH 17/60] net: notify iothread after flushing queue
From: |
Michael Tokarev |
Subject: |
[Qemu-devel] [PATCH 17/60] net: notify iothread after flushing queue |
Date: |
Mon, 4 Feb 2013 14:40:27 +0400 |
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>
(cherry picked from commit 987a9b4800003567b1a47a379255e886a77d57ea)
Conflicts (backport):
net.c
net/queue.h
Signed-off-by: Michael Tokarev <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 3f190d4..0974945 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(VLANClientState *nc)
diff --git a/net.c b/net.c
index 1922d8a..fa846ae 100644
--- a/net.c
+++ b/net.c
@@ -491,7 +491,12 @@ void qemu_flush_queued_packets(VLANClientState *vc)
queue = vc->send_queue;
}
- qemu_net_queue_flush(queue);
+ if (qemu_net_queue_flush(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(VLANClientState *sender,
diff --git a/net/queue.c b/net/queue.c
index 1ab5247..395cbd2 100644
--- a/net/queue.c
+++ b/net/queue.c
@@ -232,7 +232,7 @@ void qemu_net_queue_purge(NetQueue *queue, VLANClientState
*from)
}
}
-void qemu_net_queue_flush(NetQueue *queue)
+bool qemu_net_queue_flush(NetQueue *queue)
{
while (!QTAILQ_EMPTY(&queue->packets)) {
NetPacket *packet;
@@ -248,7 +248,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) {
@@ -257,4 +257,5 @@ void qemu_net_queue_flush(NetQueue *queue)
g_free(packet);
}
+ return true;
}
diff --git a/net/queue.h b/net/queue.h
index a31958e..4bf6d3c 100644
--- a/net/queue.h
+++ b/net/queue.h
@@ -66,6 +66,6 @@ ssize_t qemu_net_queue_send_iov(NetQueue *queue,
NetPacketSent *sent_cb);
void qemu_net_queue_purge(NetQueue *queue, VLANClientState *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] [PATCH 29/60] usb-storage: fix SYNCHRONIZE_CACHE, (continued)
- [Qemu-devel] [PATCH 48/60] ide: Fix crash with too long PRD, Michael Tokarev, 2013/02/04
- [Qemu-devel] [PATCH 35/60] s390x: fix -initrd in virtio machine, Michael Tokarev, 2013/02/04
- [Qemu-devel] [PATCH 53/60] hw/qxl: qxl_send_events: nop if stopped, Michael Tokarev, 2013/02/04
- [Qemu-devel] [PATCH 17/60] net: notify iothread after flushing queue,
Michael Tokarev <=
- [Qemu-devel] [PATCH 34/60] memory: fix rendering of a region obscured by another, Michael Tokarev, 2013/02/04
- [Qemu-devel] [PATCH 52/60] uhci: Don't queue up packets after one with the SPD flag set, Michael Tokarev, 2013/02/04
- [Qemu-devel] [PATCH 47/60] kvm: fix incorrect length in a loop over kvm dirty pages map, Michael Tokarev, 2013/02/04
- [Qemu-devel] [PATCH 15/60] i386: kvm: bit 10 of CPUID[8000_0001].EDX is reserved, Michael Tokarev, 2013/02/04
- [Qemu-devel] [PATCH 32/60] qed: refuse unaligned zero writes with a backing file, Michael Tokarev, 2013/02/04
- [Qemu-devel] [PATCH 16/60] blockdev: preserve readonly and snapshot states across media changes, Michael Tokarev, 2013/02/04
- [Qemu-devel] [PATCH 46/60] e1000: Discard oversized packets based on SBP|LPE, Michael Tokarev, 2013/02/04
- [Qemu-devel] [PATCH 45/60] e1000: Discard packets that are too long if !SBP and !LPE, Michael Tokarev, 2013/02/04
- [Qemu-devel] [PATCH 33/60] e1000: drop check_rxov, always treat RX ring with RDH == RDT as empty, Michael Tokarev, 2013/02/04
- [Qemu-devel] [PATCH 07/60] cpu_physical_memory_write_rom() needs to do TB invalidates, Michael Tokarev, 2013/02/04