From owner-dev-commits-src-main@freebsd.org Tue Jan 19 05:08:24 2021 Return-Path: Delivered-To: dev-commits-src-main@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id F29A74E5584; Tue, 19 Jan 2021 05:08:23 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4DKc9y2J9cz4XFN; Tue, 19 Jan 2021 05:08:22 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 99039208E4; Tue, 19 Jan 2021 05:08:17 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 10J58HAj085870; Tue, 19 Jan 2021 05:08:17 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 10J58H4u085869; Tue, 19 Jan 2021 05:08:17 GMT (envelope-from git) Date: Tue, 19 Jan 2021 05:08:17 GMT Message-Id: <202101190508.10J58H4u085869@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Bryan Venteicher Subject: git: baa5234fbec6 - main - if_vtnet: Move the Tx interrupt threshold into the Txq structure MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: bryanv X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: baa5234fbec6befdc6c3fd7beea2f318e7e97d0c Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-main@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for the main branch of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 19 Jan 2021 05:08:24 -0000 The branch main has been updated by bryanv: URL: https://cgit.FreeBSD.org/src/commit/?id=baa5234fbec6befdc6c3fd7beea2f318e7e97d0c commit baa5234fbec6befdc6c3fd7beea2f318e7e97d0c Author: Bryan Venteicher AuthorDate: 2021-01-19 04:55:24 +0000 Commit: Bryan Venteicher CommitDate: 2021-01-19 04:55:24 +0000 if_vtnet: Move the Tx interrupt threshold into the Txq structure Reviewed by: grehan (mentor) Differential Revision: https://reviews.freebsd.org/D27911 --- sys/dev/virtio/network/if_vtnet.c | 67 +++++++++++++++++------------------- sys/dev/virtio/network/if_vtnetvar.h | 2 +- 2 files changed, 33 insertions(+), 36 deletions(-) diff --git a/sys/dev/virtio/network/if_vtnet.c b/sys/dev/virtio/network/if_vtnet.c index f55bd59ef749..39009a1de3f0 100644 --- a/sys/dev/virtio/network/if_vtnet.c +++ b/sys/dev/virtio/network/if_vtnet.c @@ -140,6 +140,7 @@ static void vtnet_rx_vq_process(struct vtnet_rxq *rxq, int tries); static void vtnet_rx_vq_intr(void *); static void vtnet_rxq_tq_intr(void *, int); +static int vtnet_txq_intr_threshold(struct vtnet_txq *); static int vtnet_txq_below_threshold(struct vtnet_txq *); static int vtnet_txq_notify(struct vtnet_txq *); static void vtnet_txq_free_mbufs(struct vtnet_txq *); @@ -219,7 +220,6 @@ static void vtnet_set_macaddr(struct vtnet_softc *); static void vtnet_attached_set_macaddr(struct vtnet_softc *); static void vtnet_vlan_tag_remove(struct mbuf *); static void vtnet_set_rx_process_limit(struct vtnet_softc *); -static void vtnet_set_tx_intr_threshold(struct vtnet_softc *); static void vtnet_setup_rxq_sysctl(struct sysctl_ctx_list *, struct sysctl_oid_list *, struct vtnet_rxq *); @@ -1090,7 +1090,6 @@ vtnet_setup_interface(struct vtnet_softc *sc) } vtnet_set_rx_process_limit(sc); - vtnet_set_tx_intr_threshold(sc); DEBUGNET_SET(ifp, vtnet); @@ -2024,15 +2023,42 @@ vtnet_rxq_tq_intr(void *xrxq, int pending) } static int -vtnet_txq_below_threshold(struct vtnet_txq *txq) +vtnet_txq_intr_threshold(struct vtnet_txq *txq) { struct vtnet_softc *sc; - struct virtqueue *vq; + int threshold; sc = txq->vtntx_sc; + + /* + * The Tx interrupt is disabled until the queue free count falls + * below our threshold. Completed frames are drained from the Tx + * virtqueue before transmitting new frames and in the watchdog + * callout, so the frequency of Tx interrupts is greatly reduced, + * at the cost of not freeing mbufs as quickly as they otherwise + * would be. + */ + threshold = virtqueue_size(txq->vtntx_vq) / 4; + + /* + * Without indirect descriptors, leave enough room for the most + * segments we handle. + */ + if ((sc->vtnet_flags & VTNET_FLAG_INDIRECT) == 0 && + threshold < sc->vtnet_tx_nsegs) + threshold = sc->vtnet_tx_nsegs; + + return (threshold); +} + +static int +vtnet_txq_below_threshold(struct vtnet_txq *txq) +{ + struct virtqueue *vq; + vq = txq->vtntx_vq; - return (virtqueue_nfree(vq) <= sc->vtnet_tx_intr_thresh); + return (virtqueue_nfree(vq) <= txq->vtntx_intr_threshold); } static int @@ -3058,6 +3084,7 @@ vtnet_init_tx_queues(struct vtnet_softc *sc) for (i = 0; i < sc->vtnet_act_vq_pairs; i++) { txq = &sc->vtnet_txqs[i]; txq->vtntx_watchdog = 0; + txq->vtntx_intr_threshold = vtnet_txq_intr_threshold(txq); #ifdef DEV_NETMAP netmap_reset(NA(sc->vtnet_ifp), NR_TX, i, 0); #endif /* DEV_NETMAP */ @@ -3749,36 +3776,6 @@ vtnet_set_rx_process_limit(struct vtnet_softc *sc) sc->vtnet_rx_process_limit = limit; } -static void -vtnet_set_tx_intr_threshold(struct vtnet_softc *sc) -{ - int size, thresh; - - size = virtqueue_size(sc->vtnet_txqs[0].vtntx_vq); - - /* - * The Tx interrupt is disabled until the queue free count falls - * below our threshold. Completed frames are drained from the Tx - * virtqueue before transmitting new frames and in the watchdog - * callout, so the frequency of Tx interrupts is greatly reduced, - * at the cost of not freeing mbufs as quickly as they otherwise - * would be. - * - * N.B. We assume all the Tx queues are the same size. - */ - thresh = size / 4; - - /* - * Without indirect descriptors, leave enough room for the most - * segments we handle. - */ - if ((sc->vtnet_flags & VTNET_FLAG_INDIRECT) == 0 && - thresh < sc->vtnet_tx_nsegs) - thresh = sc->vtnet_tx_nsegs; - - sc->vtnet_tx_intr_thresh = thresh; -} - static void vtnet_setup_rxq_sysctl(struct sysctl_ctx_list *ctx, struct sysctl_oid_list *child, struct vtnet_rxq *rxq) diff --git a/sys/dev/virtio/network/if_vtnetvar.h b/sys/dev/virtio/network/if_vtnetvar.h index 4189bb4d966f..82dd2514472d 100644 --- a/sys/dev/virtio/network/if_vtnetvar.h +++ b/sys/dev/virtio/network/if_vtnetvar.h @@ -112,6 +112,7 @@ struct vtnet_txq { #endif int vtntx_id; int vtntx_watchdog; + int vtntx_intr_threshold; struct vtnet_txq_stats vtntx_stats; struct taskqueue *vtntx_tq; struct task vtntx_intrtask; @@ -161,7 +162,6 @@ struct vtnet_softc { int vtnet_rx_nsegs; int vtnet_rx_nmbufs; int vtnet_rx_clustersz; - int vtnet_tx_intr_thresh; int vtnet_tx_nsegs; int vtnet_if_flags; int vtnet_max_mtu;