Received: by 2002:ac0:a5a6:0:0:0:0:0 with SMTP id m35-v6csp394837imm; Wed, 29 Aug 2018 02:46:57 -0700 (PDT) X-Google-Smtp-Source: ANB0VdaXCOjx/jDVepAIBz4DNWnUxeaSaeK9WgyzyEe0hB9B05zFIcJd80DtNISie72j01q3DL9n X-Received: by 2002:a63:e54b:: with SMTP id z11-v6mr4964318pgj.328.1535536017607; Wed, 29 Aug 2018 02:46:57 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1535536017; cv=none; d=google.com; s=arc-20160816; b=axYARgKa14r0j9r5QcK7fLNmUGzJNgLDM7xcym0LjpdLophiSQ/P/cTolHh80ueLkS E8Tj/mOW2NOZkwiWa4XMJaXzadYUA/gjIc/xmPmXL8k+jXUO/fkgxG5v/z+Auo9R7ntJ 6g8rwEnUMN/O+2PVddtI1GQ1eG1ZQaBbBoOEt6RenUIp9XVmH0SrLwuG0BJymbxDCNqW J6lIJpn2Qvd3EmdFZ0pEqakQbtvHWZ67+87YRyD9TRxSGSSUjT4FrZySGN4ZYTST9zIH Wl03LCdDZYCvGqNCPxtcHGPHXrdm71gHA/A30urh0wHd/n52BJCtELs5Ym4txbzZlutJ +JTQ== 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 :user-agent:message-id:in-reply-to:date:references:subject:cc:to :from:arc-authentication-results; bh=rycgfHPXf/ARa8WguKbZGbK80ap9X3wCn3TRZBp+Tbg=; b=SsZhy96IwqhDiV2/GkeCYthHdpCbilWitqvGxuJ59nxnOZCT3jHg7BP+iVH4hV/TFB thgJD2/7ZMcBX6N+EBb0THP/Y1xWL97wP55lxWhm5Fw97F6Ne2lqLZ14SJpMdG6qa/6a VZPc8mePnwl0xrVTEGcI/ZP0DJ8K5X9RJ9EbBbsGo0B2VD3Z3E1uDdQnzpOt0fQLc5WN lqCLIxrUZ+erZdeKXgZXP/cOJdTSQblzvYpya9xWMhDsp6l1eAW2/GlouA5ZPHPuTHI9 W99FWbObCPr/NIuqagbJ9TjstmATTvAzXBOXlXqfWkEbGry8uTPSJ95fv4WqbOzgboYU N56Q== 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 k23-v6si3156854pgl.633.2018.08.29.02.46.42; Wed, 29 Aug 2018 02:46:57 -0700 (PDT) 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 S1728145AbeH2Nkp convert rfc822-to-8bit (ORCPT + 99 others); Wed, 29 Aug 2018 09:40:45 -0400 Received: from mail.bootlin.com ([62.4.15.54]:46393 "EHLO mail.bootlin.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727172AbeH2Nkp (ORCPT ); Wed, 29 Aug 2018 09:40:45 -0400 Received: by mail.bootlin.com (Postfix, from userid 110) id CF688207B1; Wed, 29 Aug 2018 11:44:40 +0200 (CEST) X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on mail.bootlin.com X-Spam-Level: X-Spam-Status: No, score=-1.0 required=5.0 tests=ALL_TRUSTED,SHORTCIRCUIT shortcircuit=ham autolearn=disabled version=3.4.0 Received: from localhost (242.171.71.37.rev.sfr.net [37.71.171.242]) by mail.bootlin.com (Postfix) with ESMTPSA id A15A7206EE; Wed, 29 Aug 2018 11:44:40 +0200 (CEST) From: Gregory CLEMENT To: Jisheng Zhang Cc: , "David S. Miller" , netdev@vger.kernel.org, linux-kernel@vger.kernel.org, Andrew Lunn , linux-arm-kernel@lists.infradead.org Subject: Re: [PATCH 5/5] net: mvneta: reduce smp_processor_id() calling in mvneta_tx_done_gbe References: <20180829162456.2bd69796@xhacker.debian> <20180829163021.70ce99ab@xhacker.debian> Date: Wed, 29 Aug 2018 11:44:39 +0200 In-Reply-To: <20180829163021.70ce99ab@xhacker.debian> (Jisheng Zhang's message of "Wed, 29 Aug 2018 16:30:21 +0800") Message-ID: <87wos9ik1k.fsf@bootlin.com> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/25.2 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8BIT Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi Jisheng, On mer., août 29 2018, Jisheng Zhang wrote: > In the loop of mvneta_tx_done_gbe(), we call the smp_processor_id() > each time, move the call out of the loop to optimize the code a bit. > > Before the patch, the loop looks like(under arm64): > > ldr x1, [x29,#120] > ... > ldr w24, [x1,#36] > ... > bl 0 <_raw_spin_lock> > str w24, [x27,#132] > ... > > After the patch, the loop looks like(under arm64): > > ... > bl 0 <_raw_spin_lock> > str w23, [x28,#132] > ... > where w23 is loaded so be ready before the loop. > > From another side, mvneta_tx_done_gbe() is called from mvneta_poll() > which is in non-preemptible context, so it's safe to call the > smp_processor_id() function once. This improvement should go to net-next. Besides this patch looks nice: Reviewed-by: Gregory CLEMENT Thanks, Gregory > > Signed-off-by: Jisheng Zhang > --- > drivers/net/ethernet/marvell/mvneta.c | 3 ++- > 1 file changed, 2 insertions(+), 1 deletion(-) > > diff --git a/drivers/net/ethernet/marvell/mvneta.c b/drivers/net/ethernet/marvell/mvneta.c > index 7d98f7828a30..62e81e267e13 100644 > --- a/drivers/net/ethernet/marvell/mvneta.c > +++ b/drivers/net/ethernet/marvell/mvneta.c > @@ -2507,12 +2507,13 @@ static void mvneta_tx_done_gbe(struct mvneta_port *pp, u32 cause_tx_done) > { > struct mvneta_tx_queue *txq; > struct netdev_queue *nq; > + int cpu = smp_processor_id(); > > while (cause_tx_done) { > txq = mvneta_tx_done_policy(pp, cause_tx_done); > > nq = netdev_get_tx_queue(pp->dev, txq->id); > - __netif_tx_lock(nq, smp_processor_id()); > + __netif_tx_lock(nq, cpu); > > if (txq->count) > mvneta_txq_done(pp, txq); > -- > 2.18.0 > -- Gregory Clement, Bootlin Embedded Linux and Kernel engineering http://bootlin.com