Received: by 2002:a25:8b91:0:0:0:0:0 with SMTP id j17csp4010071ybl; Fri, 20 Dec 2019 21:16:36 -0800 (PST) X-Google-Smtp-Source: APXvYqxSqxLGaVDfvQWTjQMRVw8am9w5a5S5tX4Jvn+6QIiBuxUGjpCnC1Q9yBZCH1o0c9xsmclJ X-Received: by 2002:a9d:754a:: with SMTP id b10mr19180022otl.273.1576905396301; Fri, 20 Dec 2019 21:16:36 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1576905396; cv=none; d=google.com; s=arc-20160816; b=lr8AS0rjkNJdte2aSNoXtUqhLRrfBCRVxZ1XIlI8Gu8SPuysu6guTx7jGUXZ857Auc mRXgVbzn1lEPS3bPSekAEm3my3ck/bBwuMF3FjRmmJ1QfpyjncCVfDt2jrJWxOItwrIA fnnblt4SzDbtT5FZn+DjDufVNA31FJGvwCblXkFn7JzrPV33gpNblonfDbrfdsjBBYoD 88LxnqieRtowuwFPhkk1SlJ3gQPDm/2IVrD6O0Ek+ww1S999nIAAb0q42GOgM5twL9so uQ7h9uNBQcpjO8M0qFiDC7HBYYxo3YO3ZX5TL8OLVgtoVUxdB2/AFAHATHx+hv93K3TL +oXg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:from:subject:cc:to:message-id:date; bh=4z3YfzGhhy6PritBkJ3E2VO9E2F2h7TOiULfpVhYBnM=; b=pUyoQHB5zjOxbdDN3iw5jUj7ldDkw13Bxj6ti2tKqHJrhFXrghiOvc5wJ5OLJ9Ui4H FqfYlRGrkIJqPZb9TAQUCpd7uA4xiFB3jk3V9uwX2uMSiYscsepEZ4DIwZS9kpeUajxk ZJ8ydeDr8GrswjNRk6QdgT5aZUFyNPKEBivVPausuOZaOB9y1PHmoe9R1b6NsY5JEFsp o95Rk1YfmTMsB44HhnblhwKKPJbn+hwAZkbimF1yYTRFR5GqI73chWDKSB5vBAOaXREe 7z0VPtbKNvp/qelOeTHWrs0iRf0aWk2+ZQfuzn1enSE7kmq56/AJuo6GUgM9ADCgBc2q tHiA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id w29si7337371oth.313.2019.12.20.21.16.24; Fri, 20 Dec 2019 21:16:36 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726060AbfLUFPr (ORCPT + 99 others); Sat, 21 Dec 2019 00:15:47 -0500 Received: from shards.monkeyblade.net ([23.128.96.9]:56838 "EHLO shards.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725774AbfLUFPr (ORCPT ); Sat, 21 Dec 2019 00:15:47 -0500 Received: from localhost (unknown [IPv6:2601:601:9f00:1c3::3d5]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (Client did not present a certificate) (Authenticated sender: davem-davemloft) by shards.monkeyblade.net (Postfix) with ESMTPSA id 195D2153CA713; Fri, 20 Dec 2019 21:15:44 -0800 (PST) Date: Fri, 20 Dec 2019 21:15:43 -0800 (PST) Message-Id: <20191220.211543.940622133336540668.davem@davemloft.net> To: xiaojiangfeng@huawei.com Cc: yisen.zhuang@huawei.com, salil.mehta@huawei.com, zhangfei.gao@linaro.org, arnd@arndb.de, dingtianhong@huawei.com, netdev@vger.kernel.org, linux-kernel@vger.kernel.org, jakub.kicinski@netronome.com, leeyou.li@huawei.com, nixiaoming@huawei.com Subject: Re: [PATCH v4] net: hisilicon: Fix a BUG trigered by wrong bytes_compl From: David Miller In-Reply-To: <1576721287-68102-1-git-send-email-xiaojiangfeng@huawei.com> References: <1576721287-68102-1-git-send-email-xiaojiangfeng@huawei.com> X-Mailer: Mew version 6.8 on Emacs 26.1 Mime-Version: 1.0 Content-Type: Text/Plain; charset=us-ascii Content-Transfer-Encoding: 7bit X-Greylist: Sender succeeded SMTP AUTH, not delayed by milter-greylist-4.5.12 (shards.monkeyblade.net [149.20.54.216]); Fri, 20 Dec 2019 21:15:44 -0800 (PST) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Jiangfeng Xiao Date: Thu, 19 Dec 2019 10:08:07 +0800 > When doing stress test, we get the following trace: ... > Pre-modification code: > int hip04_mac_start_xmit(struct sk_buff *skb, struct net_device *ndev) > { > [...] > [1] priv->tx_head = TX_NEXT(tx_head); > [2] count++; > [3] netdev_sent_queue(ndev, skb->len); > [...] > } > An rx interrupt occurs if hip04_mac_start_xmit just executes to the line 2, > tx_head has been updated, but corresponding 'skb->len' has not been > added to dql_queue. > > And then > hip04_mac_interrupt->__napi_schedule->hip04_rx_poll->hip04_tx_reclaim > > In hip04_tx_reclaim, because tx_head has been updated, > bytes_compl will plus an additional "skb-> len" > which has not been added to dql_queue. And then > trigger the BUG_ON(bytes_compl > num_queued - dql->num_completed). > > To solve the problem described above, we put > "netdev_sent_queue(ndev, skb->len);" > before > "priv->tx_head = TX_NEXT(tx_head);" > > Fixes: a41ea46a9a12 ("net: hisilicon: new hip04 ethernet driver") > Signed-off-by: Jiangfeng Xiao Applied, thanks.