summaryrefslogtreecommitdiffstats
path: root/usr.sbin
diff options
context:
space:
mode:
authormav <mav@FreeBSD.org>2015-05-13 10:18:44 +0000
committermav <mav@FreeBSD.org>2015-05-13 10:18:44 +0000
commitf24af427aae00e8dc9b1b76043885c4f874b911b (patch)
treef88455c76a2c336216c67017a37774ebb18206ab /usr.sbin
parent645e8cf00deeef874bee641a2779087f99a97be7 (diff)
downloadFreeBSD-src-f24af427aae00e8dc9b1b76043885c4f874b911b.zip
FreeBSD-src-f24af427aae00e8dc9b1b76043885c4f874b911b.tar.gz
MFC r281764, r282563: Disable RX/TX queues notifications when not needed.
This reduces CPU load and doubles iperf throughput, reaching 2-3Gbit/s. Sponsored by: iXsystems, Inc.
Diffstat (limited to 'usr.sbin')
-rw-r--r--usr.sbin/bhyve/pci_virtio_net.c29
1 files changed, 15 insertions, 14 deletions
diff --git a/usr.sbin/bhyve/pci_virtio_net.c b/usr.sbin/bhyve/pci_virtio_net.c
index f3656b7..32f56ee 100644
--- a/usr.sbin/bhyve/pci_virtio_net.c
+++ b/usr.sbin/bhyve/pci_virtio_net.c
@@ -34,6 +34,7 @@ __FBSDID("$FreeBSD$");
#include <sys/select.h>
#include <sys/uio.h>
#include <sys/ioctl.h>
+#include <machine/atomic.h>
#include <net/ethernet.h>
#include <errno.h>
@@ -393,6 +394,7 @@ pci_vtnet_ping_rxq(void *vsc, struct vqueue_info *vq)
*/
if (sc->vsc_rx_ready == 0) {
sc->vsc_rx_ready = 1;
+ vq->vq_used->vu_flags |= VRING_USED_F_NO_NOTIFY;
}
}
@@ -438,6 +440,7 @@ pci_vtnet_ping_txq(void *vsc, struct vqueue_info *vq)
/* Signal the tx thread for processing */
pthread_mutex_lock(&sc->tx_mtx);
+ vq->vq_used->vu_flags |= VRING_USED_F_NO_NOTIFY;
if (sc->tx_in_progress == 0)
pthread_cond_signal(&sc->tx_cond);
pthread_mutex_unlock(&sc->tx_mtx);
@@ -451,7 +454,7 @@ pci_vtnet_tx_thread(void *param)
{
struct pci_vtnet_softc *sc = param;
struct vqueue_info *vq;
- int have_work, error;
+ int error;
vq = &sc->vsc_queues[VTNET_TXQ];
@@ -465,19 +468,17 @@ pci_vtnet_tx_thread(void *param)
for (;;) {
/* note - tx mutex is locked here */
- do {
- if (sc->resetting)
- have_work = 0;
- else
- have_work = vq_has_descs(vq);
-
- if (!have_work) {
- sc->tx_in_progress = 0;
- error = pthread_cond_wait(&sc->tx_cond,
- &sc->tx_mtx);
- assert(error == 0);
- }
- } while (!have_work);
+ while (sc->resetting || !vq_has_descs(vq)) {
+ vq->vq_used->vu_flags &= ~VRING_USED_F_NO_NOTIFY;
+ mb();
+ if (!sc->resetting && vq_has_descs(vq))
+ break;
+
+ sc->tx_in_progress = 0;
+ error = pthread_cond_wait(&sc->tx_cond, &sc->tx_mtx);
+ assert(error == 0);
+ }
+ vq->vq_used->vu_flags |= VRING_USED_F_NO_NOTIFY;
sc->tx_in_progress = 1;
pthread_mutex_unlock(&sc->tx_mtx);
OpenPOWER on IntegriCloud