From owner-p4-projects@FreeBSD.ORG Thu Sep 27 19:18:07 2007 Return-Path: Delivered-To: p4-projects@freebsd.org Received: by hub.freebsd.org (Postfix, from userid 32767) id 09E3116A41B; Thu, 27 Sep 2007 19:18:07 +0000 (UTC) Delivered-To: perforce@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id BFC1A16A418 for ; Thu, 27 Sep 2007 19:18:06 +0000 (UTC) (envelope-from kmacy@freebsd.org) Received: from repoman.freebsd.org (repoman.freebsd.org [IPv6:2001:4f8:fff6::29]) by mx1.freebsd.org (Postfix) with ESMTP id 83F9113C457 for ; Thu, 27 Sep 2007 19:18:06 +0000 (UTC) (envelope-from kmacy@freebsd.org) Received: from repoman.freebsd.org (localhost [127.0.0.1]) by repoman.freebsd.org (8.14.1/8.14.1) with ESMTP id l8RJI6Nt054293 for ; Thu, 27 Sep 2007 19:18:06 GMT (envelope-from kmacy@freebsd.org) Received: (from perforce@localhost) by repoman.freebsd.org (8.14.1/8.14.1/Submit) id l8RJI5e9054290 for perforce@freebsd.org; Thu, 27 Sep 2007 19:18:05 GMT (envelope-from kmacy@freebsd.org) Date: Thu, 27 Sep 2007 19:18:05 GMT Message-Id: <200709271918.l8RJI5e9054290@repoman.freebsd.org> X-Authentication-Warning: repoman.freebsd.org: perforce set sender to kmacy@freebsd.org using -f From: Kip Macy To: Perforce Change Reviews Cc: Subject: PERFORCE change 126871 for review X-BeenThere: p4-projects@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: p4 projects tree changes List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 27 Sep 2007 19:18:07 -0000 http://perforce.freebsd.org/chv.cgi?CH=126871 Change 126871 by kmacy@kmacy_home:ethng on 2007/09/27 19:17:19 - free pending mbufs and tx descriptors when the port is down - reduce service thread priority to timeshare after first tx iteration to prevent starvation of ithread which we need to update the count of processed descriptors Affected files ... .. //depot/projects/ethng/src/sys/dev/cxgb/cxgb_multiq.c#20 edit Differences ... ==== //depot/projects/ethng/src/sys/dev/cxgb/cxgb_multiq.c#20 (text+ko) ==== @@ -103,7 +103,7 @@ SYSCTL_UINT(_hw_cxgb, OID_AUTO, sleep_ticks, CTLFLAG_RDTUN, &sleep_ticks, 0, "ticks to sleep between checking pcpu queues"); -int cxgb_txq_mbuf_ring_size = 2048; +int cxgb_txq_mbuf_ring_size = TX_ETH_Q_SIZE; TUNABLE_INT("hw.cxgb.txq_mr_size", &cxgb_txq_mbuf_ring_size); SYSCTL_UINT(_hw_cxgb, OID_AUTO, txq_mr_size, CTLFLAG_RDTUN, &cxgb_txq_mbuf_ring_size, 0, "size of per-queue mbuf ring"); @@ -349,6 +349,8 @@ m_freem(m); while ((m = mbuf_ring_dequeue(&txq->txq_mr)) != NULL) m_freem(m); + + t3_free_tx_desc_all(txq); } static int @@ -428,21 +430,23 @@ stopped = isset(&qs->txq_stopped, TXQ_ETH); flush = ((!mbuf_ring_empty(&txq->txq_mr) && !stopped) || txq->immpkt); - max_desc = tx_flush ? 0xffffff : TX_START_MAX_DESC; + max_desc = tx_flush ? TX_ETH_Q_SIZE : TX_START_MAX_DESC; err = flush ? cxgb_tx_common(qs->port->ifp, qs, max_desc) : ENOSPC; if ((tx_flush && flush && err == 0) && !mbuf_ring_empty(&txq->txq_mr)) { -#if 0 struct thread *td = curthread; - thread_lock(td); - sched_prio(td, PRI_MIN_TIMESHARE); - thread_unlock(td); -#endif - if (i++ > 5000) - device_printf(qs->port->adapter->dev, - "mbuf head=%p qsize=%d qlen=%d\n", - txq->sendq.head, txq->sendq.qsize, txq->sendq.qlen); + if (++i > 1) { + thread_lock(td); + sched_prio(td, PRI_MIN_TIMESHARE); + thread_unlock(td); + } + if (i > 50) { + if (cxgb_debug) + device_printf(qs->port->adapter->dev, + "exceeded max enqueue tries\n"); + return (EBUSY); + } goto retry; } err = (initerr != 0) ? initerr : err; @@ -548,7 +552,7 @@ struct adapter *sc = qs->port->adapter; struct sge_txq *txq = &qs->txq[TXQ_ETH]; - int err = 0; + int idleticks, err = 0; td = curthread; @@ -565,9 +569,14 @@ if (qs->qs_flags & QS_EXITING) break; - if ((qs->port->ifp->if_drv_flags && IFF_DRV_RUNNING) == 0) + if ((qs->port->ifp->if_drv_flags && IFF_DRV_RUNNING) == 0) { + idleticks = hz; + if (!mbuf_ring_empty(&txq->txq_mr) || + !mbufq_empty(&txq->sendq)) + cxgb_pcpu_free(qs); goto done; - + } else + idleticks = sleep_ticks; if (mtx_trylock(&txq->lock)) { txq->flags |= TXQ_TRANSMITTING; err = cxgb_pcpu_start_(qs, NULL, TRUE); @@ -575,7 +584,8 @@ mtx_unlock(&txq->lock); } else err = EINPROGRESS; - + + if (mtx_trylock(&qs->rspq.lock)) { process_responses(sc, qs, -1);