svn commit: r283048 - head/sys/dev/sfxge

Andrew Rybchenko arybchik at FreeBSD.org
Mon May 18 06:02:23 UTC 2015


Author: arybchik
Date: Mon May 18 06:02:22 2015
New Revision: 283048
URL: https://svnweb.freebsd.org/changeset/base/283048

Log:
  sfxge: fix overflow queue freeze
  
  If TxQ lock is obtained, deferred packet list shold be serviced even if
  the packet addition fails because of overflow.
  
  Without the patch freeze happens if:
   - queue is not blocked (i.e. completion does not trigger unblock and service)
   - put-list overflow (1024 entries)
   - sfxge_tx_packet_add() acquires TxQ lock just as it is released it in
     sfxge_tx_qdpl_service() on the second CPU but before pending check
   - sfxge_tx_packet_add() swizzles put-list to get-list, fails because of
     non-tcp get-list overflow and returns without packet list service
   - sfxge_tx_qdpl_service() on the second CPU checks that there are no
     pending packets in the put-list and returns
  
  Other possible solution is to guaranee that maximum length of the put-list
  is less than maximum length of any get-list.
  
  Reviewed by:    gnn
  Sponsored by:   Solarflare Communications, Inc.
  MFC after:      2 days
  Differential Revision: https://reviews.freebsd.org/D2562

Modified:
  head/sys/dev/sfxge/sfxge_tx.c

Modified: head/sys/dev/sfxge/sfxge_tx.c
==============================================================================
--- head/sys/dev/sfxge/sfxge_tx.c	Mon May 18 02:11:09 2015	(r283047)
+++ head/sys/dev/sfxge/sfxge_tx.c	Mon May 18 06:02:22 2015	(r283048)
@@ -619,18 +619,12 @@ sfxge_tx_packet_add(struct sfxge_txq *tx
 		sfxge_tx_qdpl_swizzle(txq);
 
 		rc = sfxge_tx_qdpl_put_locked(txq, m);
-		if (rc != 0) {
-			SFXGE_TXQ_UNLOCK(txq);
-			return (rc);
-		}
 
 		/* 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)
-			return (rc);
 
 		/*
 		 * Try to grab the lock again.
@@ -639,7 +633,7 @@ 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.
 		 */
-		if (SFXGE_TXQ_TRYLOCK(txq)) {
+		if ((rc == 0) && SFXGE_TXQ_TRYLOCK(txq)) {
 			sfxge_tx_qdpl_service(txq);
 			/* Lock has been dropped. */
 		}
@@ -647,7 +641,7 @@ sfxge_tx_packet_add(struct sfxge_txq *tx
 
 	SFXGE_TXQ_LOCK_ASSERT_NOTOWNED(txq);
 
-	return (0);
+	return (rc);
 }
 
 static void


More information about the svn-src-all mailing list