From owner-svn-src-all@FreeBSD.ORG Sat May 16 05:37:48 2015 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id B6D7C9EB; Sat, 16 May 2015 05:37:48 +0000 (UTC) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:1900:2254:2068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 8C94018C4; Sat, 16 May 2015 05:37:48 +0000 (UTC) Received: from svn.freebsd.org ([127.0.1.70]) by svn.freebsd.org (8.14.9/8.14.9) with ESMTP id t4G5bmho036259; Sat, 16 May 2015 05:37:48 GMT (envelope-from arybchik@FreeBSD.org) Received: (from arybchik@localhost) by svn.freebsd.org (8.14.9/8.14.9/Submit) id t4G5bm7w036258; Sat, 16 May 2015 05:37:48 GMT (envelope-from arybchik@FreeBSD.org) Message-Id: <201505160537.t4G5bm7w036258@svn.freebsd.org> X-Authentication-Warning: svn.freebsd.org: arybchik set sender to arybchik@FreeBSD.org using -f From: Andrew Rybchenko Date: Sat, 16 May 2015 05:37:48 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r282997 - head/sys/dev/sfxge X-SVN-Group: head 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.20 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: Sat, 16 May 2015 05:37:48 -0000 Author: arybchik Date: Sat May 16 05:37:47 2015 New Revision: 282997 URL: https://svnweb.freebsd.org/changeset/base/282997 Log: sfxge: get rid of locked variable in sfxge_tx_packet_add() Now each branch has one and only one possible TxQ lock state. It simplifies understanding of the code. Reviewed by: gnn Sponsored by: Solarflare Communications, Inc. MFC after: 2 days Differential Revision: https://reviews.freebsd.org/D2551 Modified: head/sys/dev/sfxge/sfxge_tx.c Modified: head/sys/dev/sfxge/sfxge_tx.c ============================================================================== --- head/sys/dev/sfxge/sfxge_tx.c Sat May 16 05:36:40 2015 (r282996) +++ head/sys/dev/sfxge/sfxge_tx.c Sat May 16 05:37:47 2015 (r282997) @@ -602,7 +602,6 @@ sfxge_tx_qdpl_put_unlocked(struct sfxge_ int sfxge_tx_packet_add(struct sfxge_txq *txq, struct mbuf *m) { - int locked; int rc; if (!SFXGE_LINK_UP(txq->sc)) { @@ -616,9 +615,7 @@ sfxge_tx_packet_add(struct sfxge_txq *tx * the packet will be appended to the "get list" of the deferred * packet list. Otherwise, it will be pushed on the "put list". */ - locked = SFXGE_TXQ_TRYLOCK(txq); - - if (locked) { + if (SFXGE_TXQ_TRYLOCK(txq)) { /* First swizzle put-list to get-list to keep order */ sfxge_tx_qdpl_swizzle(txq); @@ -627,6 +624,10 @@ sfxge_tx_packet_add(struct sfxge_txq *tx SFXGE_TXQ_UNLOCK(txq); goto fail; } + + /* Try to service the list. */ + sfxge_tx_qdpl_service(txq); + /* Lock has been dropped. */ } else { rc = sfxge_tx_qdpl_put_unlocked(txq, m); if (rc != 0) @@ -639,14 +640,13 @@ sfxge_tx_packet_add(struct sfxge_txq *tx * the deferred packet list. If we are not able to get * the lock, another thread is processing the list. */ - locked = SFXGE_TXQ_TRYLOCK(txq); + if (SFXGE_TXQ_TRYLOCK(txq)) { + sfxge_tx_qdpl_service(txq); + /* Lock has been dropped. */ + } } - if (locked) { - /* Try to service the list. */ - sfxge_tx_qdpl_service(txq); - /* Lock has been dropped. */ - } + SFXGE_TXQ_LOCK_ASSERT_NOTOWNED(txq); return (0);