From patchwork Fri Aug 29 20:46:28 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Benjamin Poirier X-Patchwork-Id: 384385 X-Patchwork-Delegate: davem@davemloft.net Return-Path: X-Original-To: patchwork-incoming@ozlabs.org Delivered-To: patchwork-incoming@ozlabs.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 58D6414010C for ; Sat, 30 Aug 2014 06:47:58 +1000 (EST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751335AbaH2Uqk (ORCPT ); Fri, 29 Aug 2014 16:46:40 -0400 Received: from mail-pd0-f182.google.com ([209.85.192.182]:43838 "EHLO mail-pd0-f182.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751020AbaH2Uqj (ORCPT ); Fri, 29 Aug 2014 16:46:39 -0400 Received: by mail-pd0-f182.google.com with SMTP id fp1so1181302pdb.13 for ; Fri, 29 Aug 2014 13:46:38 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=sender:from:to:cc:subject:date:message-id; bh=oRDDGW9YnQ+5GIEsjVF4rDCIdrLNo3GsZMH1CFknw2E=; b=zx/vI8sm9IFnYVLbqqMfpk/BID/YhLxrvhmlYHEiFZlK2u86QnnU9my5eukAloeuuu najpL8zY7eeCoC8Dj7kbUnq10Mjuhp+U5s8a4Gcn0EuQKEiigM/uYyxedA4mtUYDFo1S QPkduA9dq1ac/SjOVdnRESuNLpjEpXX1FTHj16Tbn05HT8crsDfeCfkaTqvQJj5TEoA3 maWydWDittSFxq1xI/KQsDBkhcxJDnHDoSMH/MvqQ+Dkhr2ghDbLgLJOAOjWmWW61yoF bEpMS2g9wV0goPuLEL8/DZZFvwlAJu8xQdWFikXSnU3x9SIzW2Mx0JZSySJOfIg14Jly vw/A== X-Received: by 10.66.119.103 with SMTP id kt7mr16012414pab.95.1409345198740; Fri, 29 Aug 2014 13:46:38 -0700 (PDT) Received: from f1.synalogic.ca (adsl-108-203-76-248.dsl.scrm01.sbcglobal.net. [108.203.76.248]) by mx.google.com with ESMTPSA id pa2sm1177522pdb.84.2014.08.29.13.46.37 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 29 Aug 2014 13:46:38 -0700 (PDT) From: Benjamin Poirier To: Prashant Sreedharan , Michael Chan Cc: netdev@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH net v5 1/4] tg3: Limit minimum tx queue wakeup threshold Date: Fri, 29 Aug 2014 13:46:28 -0700 Message-Id: <1409345191-8819-1-git-send-email-bpoirier@suse.de> X-Mailer: git-send-email 1.8.4.5 Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org tx_pending may be set by the user (via ethtool -G) to a low enough value that TG3_TX_WAKEUP_THRESH becomes smaller than MAX_SKB_FRAGS + 1. This may cause the tx queue to be waked when there are in fact not enough descriptors to handle an skb with max frags. This in turn causes tg3_start_xmit() to return NETDEV_TX_BUSY and print error messages. Fix the problem by putting a limit to how low TG3_TX_WAKEUP_THRESH can go. Signed-off-by: Benjamin Poirier --- I noticed the problem in a 3.0 kernel when setting `ethtool eth0 -G tx 50` and running a netperf TCP_STREAM test. The console fills up with [10597.596155] tg3 0000:06:00.0: eth0: BUG! Tx Ring full when queue awake! The problem in tg3 remains in current kernels though it does not reproduce as easily since "5640f76 net: use a per task frag allocator (v3.7-rc1)". I reproduced on current kernels by using the fail_page_alloc fault injection mechanism to force the creation of skbs with many order-0 frags. Note that the following script may also trigger another bug (NETDEV WATCHDOG), which is fixed in the next patch. $ cat /tmp/doit.sh F="/sys/kernel/debug/fail_page_alloc" echo -1 > "$F/times" echo 0 > "$F/verbose" echo 0 > "$F/ignore-gfp-wait" echo 1 > "$F/task-filter" echo 100 > "$F/probability" netperf -H 192.168.9.30 -l100 -t omni -- -d send & n=$! sleep 0.3 echo 1 > "/proc/$n/make-it-fail" sleep 10 kill "$n" --- drivers/net/ethernet/broadcom/tg3.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/drivers/net/ethernet/broadcom/tg3.c b/drivers/net/ethernet/broadcom/tg3.c index 3ac5d23..b11c0fd 100644 --- a/drivers/net/ethernet/broadcom/tg3.c +++ b/drivers/net/ethernet/broadcom/tg3.c @@ -202,7 +202,8 @@ static inline void _tg3_flag_clear(enum TG3_FLAGS flag, unsigned long *bits) #endif /* minimum number of free TX descriptors required to wake up TX process */ -#define TG3_TX_WAKEUP_THRESH(tnapi) ((tnapi)->tx_pending / 4) +#define TG3_TX_WAKEUP_THRESH(tnapi) max_t(u32, (tnapi)->tx_pending / 4, \ + MAX_SKB_FRAGS + 1) #define TG3_TX_BD_DMA_MAX_2K 2048 #define TG3_TX_BD_DMA_MAX_4K 4096