From owner-svn-src-user@FreeBSD.ORG Fri Oct 14 06:38:45 2011 Return-Path: Delivered-To: svn-src-user@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 93BCC1065674; Fri, 14 Oct 2011 06:38:45 +0000 (UTC) (envelope-from adrian@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 7A4CF8FC0C; Fri, 14 Oct 2011 06:38:45 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.4/8.14.4) with ESMTP id p9E6cjZV050629; Fri, 14 Oct 2011 06:38:45 GMT (envelope-from adrian@svn.freebsd.org) Received: (from adrian@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id p9E6cjIQ050627; Fri, 14 Oct 2011 06:38:45 GMT (envelope-from adrian@svn.freebsd.org) Message-Id: <201110140638.p9E6cjIQ050627@svn.freebsd.org> From: Adrian Chadd Date: Fri, 14 Oct 2011 06:38:45 +0000 (UTC) To: src-committers@freebsd.org, svn-src-user@freebsd.org X-SVN-Group: user MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r226357 - user/adrian/if_ath_tx/sys/dev/ath X-BeenThere: svn-src-user@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the experimental " user" src tree" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 14 Oct 2011 06:38:45 -0000 Author: adrian Date: Fri Oct 14 06:38:45 2011 New Revision: 226357 URL: http://svn.freebsd.org/changeset/base/226357 Log: Reduce the amount of silly locking overhead which I introduced in a previous commit. This now only grabs the ath lock once when handling the tx queue completion, rather than one per queue. Modified: user/adrian/if_ath_tx/sys/dev/ath/if_ath.c Modified: user/adrian/if_ath_tx/sys/dev/ath/if_ath.c ============================================================================== --- user/adrian/if_ath_tx/sys/dev/ath/if_ath.c Fri Oct 14 03:46:35 2011 (r226356) +++ user/adrian/if_ath_tx/sys/dev/ath/if_ath.c Fri Oct 14 06:38:45 2011 (r226357) @@ -4630,30 +4630,7 @@ ath_tx_processq(struct ath_softc *sc, st return nacked; } -/* - * This is inefficient - it's going to be a lot better - * if the ath_tx_proc* functions took a private snapshot - * of sc_txq_active once, inside the lock, rather than - * calling it multiple times. - * - * So before this makes it into -HEAD, that should be - * implemented. - */ -static __inline int -txqactive(struct ath_softc *sc, int qnum) -{ - u_int32_t txqs = 1<sc_txq_active & txqs; - sc->sc_txq_active &= ~txqs; - ATH_UNLOCK(sc); - return (!! r); -} +#define TXQACTIVE(t, q) ( (t) & (1 << (q))) /* * Deferred processing of transmit interrupt; special-cased @@ -4664,11 +4641,17 @@ ath_tx_proc_q0(void *arg, int npending) { struct ath_softc *sc = arg; struct ifnet *ifp = sc->sc_ifp; + uint32_t txqs; + + ATH_LOCK(sc); + txqs = sc->sc_txq_active; + sc->sc_txq_active &= ~txqs; + ATH_UNLOCK(sc); - if (txqactive(sc, 0) && ath_tx_processq(sc, &sc->sc_txq[0])) + if (TXQACTIVE(txqs, 0) && ath_tx_processq(sc, &sc->sc_txq[0])) /* XXX why is lastrx updated in tx code? */ sc->sc_lastrx = ath_hal_gettsf64(sc->sc_ah); - if (txqactive(sc, sc->sc_cabq->axq_qnum)) + if (TXQACTIVE(txqs, sc->sc_cabq->axq_qnum)) ath_tx_processq(sc, sc->sc_cabq); ifp->if_drv_flags &= ~IFF_DRV_OACTIVE; sc->sc_wd_timer = 0; @@ -4689,20 +4672,26 @@ ath_tx_proc_q0123(void *arg, int npendin struct ath_softc *sc = arg; struct ifnet *ifp = sc->sc_ifp; int nacked; + uint32_t txqs; + + ATH_LOCK(sc); + txqs = sc->sc_txq_active; + sc->sc_txq_active &= ~txqs; + ATH_UNLOCK(sc); /* * Process each active queue. */ nacked = 0; - if (txqactive(sc, 0)) + if (TXQACTIVE(txqs, 0)) nacked += ath_tx_processq(sc, &sc->sc_txq[0]); - if (txqactive(sc, 1)) + if (TXQACTIVE(txqs, 1)) nacked += ath_tx_processq(sc, &sc->sc_txq[1]); - if (txqactive(sc, 2)) + if (TXQACTIVE(txqs, 2)) nacked += ath_tx_processq(sc, &sc->sc_txq[2]); - if (txqactive(sc, 3)) + if (TXQACTIVE(txqs, 3)) nacked += ath_tx_processq(sc, &sc->sc_txq[3]); - if (txqactive(sc, sc->sc_cabq->axq_qnum)) + if (TXQACTIVE(txqs, sc->sc_cabq->axq_qnum)) ath_tx_processq(sc, sc->sc_cabq); if (nacked) sc->sc_lastrx = ath_hal_gettsf64(sc->sc_ah); @@ -4725,13 +4714,19 @@ ath_tx_proc(void *arg, int npending) struct ath_softc *sc = arg; struct ifnet *ifp = sc->sc_ifp; int i, nacked; + uint32_t txqs; + + ATH_LOCK(sc); + txqs = sc->sc_txq_active; + sc->sc_txq_active &= ~txqs; + ATH_UNLOCK(sc); /* * Process each active queue. */ nacked = 0; for (i = 0; i < HAL_NUM_TX_QUEUES; i++) - if (ATH_TXQ_SETUP(sc, i) && txqactive(sc, i)) + if (ATH_TXQ_SETUP(sc, i) && TXQACTIVE(txqs, i)) nacked += ath_tx_processq(sc, &sc->sc_txq[i]); if (nacked) sc->sc_lastrx = ath_hal_gettsf64(sc->sc_ah); @@ -4744,6 +4739,7 @@ ath_tx_proc(void *arg, int npending) ath_start(ifp); } +#undef TXQACTIVE /* * Return a buffer to the pool.