From patchwork Thu Aug 28 01:04:15 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Benjamin Poirier X-Patchwork-Id: 383631 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 3B1791400B2 for ; Thu, 28 Aug 2014 11:06:48 +1000 (EST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1756998AbaH1BFb (ORCPT ); Wed, 27 Aug 2014 21:05:31 -0400 Received: from mail-pa0-f51.google.com ([209.85.220.51]:32808 "EHLO mail-pa0-f51.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752592AbaH1BFa (ORCPT ); Wed, 27 Aug 2014 21:05:30 -0400 Received: by mail-pa0-f51.google.com with SMTP id rd3so283683pab.10 for ; Wed, 27 Aug 2014 18:05:30 -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=dKv1KCIPqXbzZXyVtas0V6qBKVhQ6lIJYEQvo4wEbpaAPAuOm8QIYGJw5C3n+ujt+w rTYiIBhUziVuJublKT4mADT4VSOTwyzQV9pmHxSs3rnVSD95OWnWFjDF9JQOJbUvTsaB WaYe+RE6DjHtDnqZAEeVD1roye8sAfXyB0hbRmt773maRGVnZRRDfRNs6YW355ZShHjh I8/7cW3WRkggk8rXW5fw3/5RjyL3seIoC2u9qRRABc2gL/idOs512QSqYlZwMuVQVJNX zcs93nsFhK4mNEDgPgXgd9aB9VDodxPRfLTgI1gQ/fjv5FHARUVOmA89jQCg2/DrTY9n gW/g== X-Received: by 10.68.233.68 with SMTP id tu4mr759513pbc.65.1409187929995; Wed, 27 Aug 2014 18:05:29 -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 df10sm2752229pdb.25.2014.08.27.18.05.28 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 27 Aug 2014 18:05:29 -0700 (PDT) From: Benjamin Poirier To: Prashant Sreedharan , Michael Chan Cc: netdev@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH net v4 1/4] tg3: Limit minimum tx queue wakeup threshold Date: Wed, 27 Aug 2014 18:04:15 -0700 Message-Id: <1409187858-7698-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