Date: Fri, 14 Oct 2011 06:38:45 +0000 (UTC) From: Adrian Chadd <adrian@FreeBSD.org> To: src-committers@freebsd.org, svn-src-user@freebsd.org Subject: svn commit: r226357 - user/adrian/if_ath_tx/sys/dev/ath Message-ID: <201110140638.p9E6cjIQ050627@svn.freebsd.org>
next in thread | raw e-mail | index | archive | help
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<<qnum; - int r; - ATH_LOCK(sc); - /* - * This needs to check whether the bit is set, and clear it - * if it is. This is what the HAL functionality did. - */ - r = sc->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.
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201110140638.p9E6cjIQ050627>