From patchwork Sun May 15 12:38:29 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Shuyu Wei X-Patchwork-Id: 9096341 Return-Path: X-Original-To: patchwork-linux-rockchip@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 4D7FABF29F for ; Sun, 15 May 2016 12:39:05 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 697762028D for ; Sun, 15 May 2016 12:39:04 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.9]) (using TLSv1.2 with cipher AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 9C61720263 for ; Sun, 15 May 2016 12:39:03 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1b1vK0-00007j-OU; Sun, 15 May 2016 12:39:00 +0000 Received: from mail-pf0-x244.google.com ([2607:f8b0:400e:c00::244]) by bombadil.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1b1vJz-00006x-AU for linux-rockchip@lists.infradead.org; Sun, 15 May 2016 12:38:59 +0000 Received: by mail-pf0-x244.google.com with SMTP id 145so13309693pfz.1 for ; Sun, 15 May 2016 05:38:38 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to:user-agent; bh=uK4mX1ILRWVMT/Tup6W9zbwwoF5vN1B8DEkODq6/fjM=; b=XiLW6Bitd81MR/SIjL/wiVGqCSfGpR0LgBS+cIjVpri+U6qJh2Y2JOD82mRpBANy/k uRV/aHomdl4NHAf+a08WZJ6DU3yN1ti28xDLLTikIJKczlYnslbJQk3l18YBwUJDStaG V+0Pk9tWllBjLAU/yngOUtToyhL0wHaN4hEM7CEAxj3skob5Vq/1BrxsjhPZW6HAAQgn Yfl5PTle2Vh9YO2xMWrnOI7FrQPGYnRbWS3QauVxIhardNn2Wt9k+fB/JRNGMyyWqWNH Pg2I4QMgJkLSAKbE2IVDnjMLqiuGzXLGHBc66jXmIkNvhY5XRzVAO/QMfkGL+Cj8dd9A Zdsw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to:user-agent; bh=uK4mX1ILRWVMT/Tup6W9zbwwoF5vN1B8DEkODq6/fjM=; b=QnCY+qMep8B310nqbgb+hiDTr4JWjTK73BG/k80LKLn7jwcUXCSAGRCoAkV6aOVp6I jaQYUoXNYfBts8dJJImGxxCKlzjWFQzqRqrpgIkFnTYZ56VMJjzCg1uHFQwlfMBVGEKO Q/03t8CRcRCTas0526ix8y6rtMPx4ZT6n0WOeieZla1pf4tbvCt5akjasYkrJaO7X0/Y QgkEXHldnkimhH8GmOXSnCr1GLYehkMxHw5nzAqGnc5Fla5tHUnWJ2s4rUsZEhpfECEc MjFbzD1NEJVl2t5FAe+qZHbtO6MJD8rCjUZfkcR9Da62V0o9aq6qf8559U4d2ipoz1yO oAvw== X-Gm-Message-State: AOPr4FXW6bKWJ69ghi3BbduuGEPJ42aKf5UBCGv041OGvvBLRQDhPJRGAcarH/YtJSFAFQ== X-Received: by 10.98.5.5 with SMTP id 5mr37492169pff.58.1463315918317; Sun, 15 May 2016 05:38:38 -0700 (PDT) Received: from debian-dorm ([222.71.85.161]) by smtp.gmail.com with ESMTPSA id z17sm40390088pfi.61.2016.05.15.05.38.35 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 15 May 2016 05:38:37 -0700 (PDT) Date: Sun, 15 May 2016 20:38:29 +0800 From: Shuyu Wei To: Francois Romieu Subject: Re: [PATCH] ethernet:arc: Fix racing of TX ring buffer Message-ID: <20160515123829.GA2831@debian-dorm> References: <20160514161602.GA3347@debian-dorm> <20160514200356.GA14105@electric-eye.fr.zoreil.com> <20160514231044.GA2968@debian-dorm> <20160515091953.GA19983@electric-eye.fr.zoreil.com> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <20160515091953.GA19983@electric-eye.fr.zoreil.com> User-Agent: Mutt/1.6.0 (2016-04-01) X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20160515_053859_409384_3C5A7F70 X-CRM114-Status: GOOD ( 14.92 ) X-Spam-Score: -2.5 (--) X-BeenThere: linux-rockchip@lists.infradead.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: Upstream kernel work for Rockchip platforms List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: linux-rockchip@lists.infradead.org, netdev@vger.kernel.org, heiko@sntech.de, davem@davemloft.net, wxt@rock-chips.com Sender: "Linux-rockchip" Errors-To: linux-rockchip-bounces+patchwork-linux-rockchip=patchwork.kernel.org@lists.infradead.org X-Spam-Status: No, score=-5.5 required=5.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, RCVD_IN_DNSWL_MED, RP_MATCHES_RCVD, T_DKIM_INVALID, UNPARSEABLE_RELAY autolearn=ham version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP On Sun, May 15, 2016 at 11:19:53AM +0200, Francois Romieu wrote: > > static void arc_emac_tx_clean(struct net_device *ndev) > { > [...] > for (i = 0; i < TX_BD_NUM; i++) { > unsigned int *txbd_dirty = &priv->txbd_dirty; > struct arc_emac_bd *txbd = &priv->txbd[*txbd_dirty]; > struct buffer_state *tx_buff = &priv->tx_buff[*txbd_dirty]; > struct sk_buff *skb = tx_buff->skb; > unsigned int info = le32_to_cpu(txbd->info); > > if ((info & FOR_EMAC) || !txbd->data || !skb) > break; > ^^^^^ > > -> the "break" statement prevents reading all txbds. At most one extra > descriptor is read and this driver isn't in the Mpps business. > You are right, I forgot the break statement. > > I tried your advice, Tx throughput can only reach 5.52MB/s. > > Even with the original code above ? Yes, I left tx_clean unmodified, and took your advice below. I tested it again just now, this time throughput do reach 9.8MB/s, Maybe last time cpu is not idle. I still have a question, is it possible that tx_clean() run between priv->tx_buff[*txbd_curr].skb = skb and dma_wmb()? --- a/drivers/net/ethernet/arc/emac_main.c +++ b/drivers/net/ethernet/arc/emac_main.c @@ -685,13 +685,15 @@ static int arc_emac_tx(struct sk_buff *skb, struct net_device *ndev) wmb(); skb_tx_timestamp(skb); + priv->tx_buff[*txbd_curr].skb = skb; + + dma_wmb(); *info = cpu_to_le32(FOR_EMAC | FIRST_OR_LAST_MASK | len); /* Make sure info word is set */ wmb(); - priv->tx_buff[*txbd_curr].skb = skb; /* Increment index to point to the next BD */ *txbd_curr = (*txbd_curr + 1) % TX_BD_NUM;