From owner-svn-src-all@freebsd.org Mon Jun 15 19:46:35 2020 Return-Path: Delivered-To: svn-src-all@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 14AE9341B35; Mon, 15 Jun 2020 19:46:35 +0000 (UTC) (envelope-from vmaffione@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 "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 49m1zt6nl6z4g42; Mon, 15 Jun 2020 19:46:34 +0000 (UTC) (envelope-from vmaffione@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id E477522FC3; Mon, 15 Jun 2020 19:46:34 +0000 (UTC) (envelope-from vmaffione@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id 05FJkYkk036215; Mon, 15 Jun 2020 19:46:34 GMT (envelope-from vmaffione@FreeBSD.org) Received: (from vmaffione@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id 05FJkYZR036214; Mon, 15 Jun 2020 19:46:34 GMT (envelope-from vmaffione@FreeBSD.org) Message-Id: <202006151946.05FJkYZR036214@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: vmaffione set sender to vmaffione@FreeBSD.org using -f From: Vincenzo Maffione Date: Mon, 15 Jun 2020 19:46:34 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r362204 - head/sys/dev/virtio/network X-SVN-Group: head X-SVN-Commit-Author: vmaffione X-SVN-Commit-Paths: head/sys/dev/virtio/network X-SVN-Commit-Revision: 362204 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.33 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 15 Jun 2020 19:46:35 -0000 Author: vmaffione Date: Mon Jun 15 19:46:34 2020 New Revision: 362204 URL: https://svnweb.freebsd.org/changeset/base/362204 Log: if_vtnet: let vtnet_rx_vq_intr() and vtnet_rxq_tq_intr() share code Since the two functions are similar, introduce a common function (vtnet_rx_vq_process()) to share common code. This also improves locking, by ensuring vrxs_rescheduled is accessed under the RXQ lock, and taskqueue_enqueue() is not called under the lock (therefore avoiding a spurious duplicate lock warning). Reported by: jrtc27 MFC after: 2 weeks Modified: head/sys/dev/virtio/network/if_vtnet.c Modified: head/sys/dev/virtio/network/if_vtnet.c ============================================================================== --- head/sys/dev/virtio/network/if_vtnet.c Mon Jun 15 19:38:48 2020 (r362203) +++ head/sys/dev/virtio/network/if_vtnet.c Mon Jun 15 19:46:34 2020 (r362204) @@ -128,6 +128,7 @@ static int vtnet_rxq_merged_eof(struct vtnet_rxq *, st static void vtnet_rxq_input(struct vtnet_rxq *, struct mbuf *, struct virtio_net_hdr *); static int vtnet_rxq_eof(struct vtnet_rxq *); +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); @@ -1915,20 +1916,17 @@ vtnet_rxq_eof(struct vtnet_rxq *rxq) } static void -vtnet_rx_vq_intr(void *xrxq) +vtnet_rx_vq_process(struct vtnet_rxq *rxq, int tries) { struct vtnet_softc *sc; - struct vtnet_rxq *rxq; struct ifnet *ifp; - int tries, more; + int more; #ifdef DEV_NETMAP int nmirq; #endif /* DEV_NETMAP */ - rxq = xrxq; sc = rxq->vtnrx_sc; ifp = sc->vtnet_ifp; - tries = 0; if (__predict_false(rxq->vtnrx_id >= sc->vtnet_act_vq_pairs)) { /* @@ -1976,58 +1974,32 @@ again: * This is an occasional condition or race (when !more), * so retry a few times before scheduling the taskqueue. */ - if (tries++ < VTNET_INTR_DISABLE_RETRIES) + if (tries-- > 0) goto again; - VTNET_RXQ_UNLOCK(rxq); rxq->vtnrx_stats.vrxs_rescheduled++; + VTNET_RXQ_UNLOCK(rxq); taskqueue_enqueue(rxq->vtnrx_tq, &rxq->vtnrx_intrtask); } else VTNET_RXQ_UNLOCK(rxq); } static void -vtnet_rxq_tq_intr(void *xrxq, int pending) +vtnet_rx_vq_intr(void *xrxq) { - struct vtnet_softc *sc; struct vtnet_rxq *rxq; - struct ifnet *ifp; - int more; -#ifdef DEV_NETMAP - int nmirq; -#endif /* DEV_NETMAP */ rxq = xrxq; - sc = rxq->vtnrx_sc; - ifp = sc->vtnet_ifp; + vtnet_rx_vq_process(rxq, VTNET_INTR_DISABLE_RETRIES); +} - VTNET_RXQ_LOCK(rxq); +static void +vtnet_rxq_tq_intr(void *xrxq, int pending) +{ + struct vtnet_rxq *rxq; -#ifdef DEV_NETMAP - nmirq = netmap_rx_irq(ifp, rxq->vtnrx_id, &more); - if (nmirq != NM_IRQ_PASS) { - VTNET_RXQ_UNLOCK(rxq); - if (nmirq == NM_IRQ_RESCHED) { - taskqueue_enqueue(rxq->vtnrx_tq, &rxq->vtnrx_intrtask); - } - return; - } -#endif /* DEV_NETMAP */ - - if ((ifp->if_drv_flags & IFF_DRV_RUNNING) == 0) { - VTNET_RXQ_UNLOCK(rxq); - return; - } - - more = vtnet_rxq_eof(rxq); - if (more || vtnet_rxq_enable_intr(rxq) != 0) { - if (!more) - vtnet_rxq_disable_intr(rxq); - rxq->vtnrx_stats.vrxs_rescheduled++; - taskqueue_enqueue(rxq->vtnrx_tq, &rxq->vtnrx_intrtask); - } - - VTNET_RXQ_UNLOCK(rxq); + rxq = xrxq; + vtnet_rx_vq_process(rxq, 0); } static int