From patchwork Wed May 15 09:18:48 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nicolas Ferre X-Patchwork-Id: 2570901 Return-Path: X-Original-To: patchwork-linux-arm@patchwork.kernel.org Delivered-To: patchwork-process-083081@patchwork1.kernel.org Received: from casper.infradead.org (casper.infradead.org [85.118.1.10]) by patchwork1.kernel.org (Postfix) with ESMTP id 3D6903FDBC for ; Wed, 15 May 2013 09:22:14 +0000 (UTC) Received: from merlin.infradead.org ([2001:4978:20e::2]) by casper.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1UcXtO-0006RE-SH; Wed, 15 May 2013 09:21:03 +0000 Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1UcXss-0003RJ-Ff; Wed, 15 May 2013 09:20:30 +0000 Received: from eusmtp01.atmel.com ([212.144.249.243]) by merlin.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1UcXsp-0003Q2-Ge for linux-arm-kernel@lists.infradead.org; Wed, 15 May 2013 09:20:28 +0000 Received: from tenerife.corp.atmel.com (10.161.101.13) by eusmtp01.atmel.com (10.161.101.31) with Microsoft SMTP Server id 14.2.342.3; Wed, 15 May 2013 11:20:03 +0200 From: Nicolas Ferre To: "David S. Miller" , Subject: [PATCH 3/3 v3] net/macb: Try to optimize struct macb layout Date: Wed, 15 May 2013 11:18:48 +0200 Message-ID: X-Mailer: git-send-email 1.8.0 In-Reply-To: References: MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20130515_052027_804279_ABFC26B1 X-CRM114-Status: GOOD ( 11.22 ) X-Spam-Score: -2.5 (--) X-Spam-Report: SpamAssassin version 3.3.2 on merlin.infradead.org summary: Content analysis details: (-2.5 points) pts rule name description ---- ---------------------- -------------------------------------------------- -0.0 SPF_PASS SPF: sender matches SPF record -0.6 RP_MATCHES_RCVD Envelope sender domain matches handover relay domain -1.9 BAYES_00 BODY: Bayes spam probability is 0 to 1% [score: 0.0000] Cc: Havard Skinnemoen , monstr@monstr.eu, Nicolas Ferre , linux-kernel@vger.kernel.org, michal.simek@xilinx.com, hein_tibosch@yahoo.es, s.trumtrar@pengutronix.de, Jean-Christophe PLAGNIOL-VILLARD , linux-arm-kernel@lists.infradead.org X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org From: Havard Skinnemoen Move TX-related fields to the top of the struct so that they end up on the same cache line. Move the NAPI struct below that since it is used from the interrupt handler. This field is also marked as ___cacheline_aligned_in_smp. RX-related fields go below those. Function pointers and capability mask are immediately after that as they are also used in the hot path. Move the spinlock before regs since they are usually used together. Signed-off-by: Havard Skinnemoen [nicolas.ferre@atmel.com: adapt to newer kernel] Signed-off-by: Nicolas Ferre --- drivers/net/ethernet/cadence/macb.h | 29 +++++++++++++++-------------- 1 file changed, 15 insertions(+), 14 deletions(-) diff --git a/drivers/net/ethernet/cadence/macb.h b/drivers/net/ethernet/cadence/macb.h index f407615..6c8e38a2 100644 --- a/drivers/net/ethernet/cadence/macb.h +++ b/drivers/net/ethernet/cadence/macb.h @@ -555,46 +555,47 @@ struct macb_or_gem_ops { }; struct macb { + spinlock_t lock; void __iomem *regs; + unsigned int tx_head; + unsigned int tx_tail; + struct macb_dma_desc *tx_ring; + struct macb_tx_skb *tx_skb; + dma_addr_t tx_ring_dma; + struct work_struct tx_error_task; + + struct napi_struct napi ____cacheline_aligned_in_smp; + unsigned int rx_tail; unsigned int rx_prepared_head; struct macb_dma_desc *rx_ring; struct sk_buff **rx_skbuff; void *rx_buffers; size_t rx_buffer_size; + dma_addr_t rx_ring_dma; + dma_addr_t rx_buffers_dma; - unsigned int tx_head, tx_tail; - struct macb_dma_desc *tx_ring; - struct macb_tx_skb *tx_skb; + struct macb_or_gem_ops macbgem_ops; + + u32 caps; - spinlock_t lock; struct platform_device *pdev; struct clk *pclk; struct clk *hclk; struct net_device *dev; - struct napi_struct napi; - struct work_struct tx_error_task; struct net_device_stats stats; union { struct macb_stats macb; struct gem_stats gem; } hw_stats; - dma_addr_t rx_ring_dma; - dma_addr_t tx_ring_dma; - dma_addr_t rx_buffers_dma; - - struct macb_or_gem_ops macbgem_ops; - struct mii_bus *mii_bus; struct phy_device *phy_dev; unsigned int link; unsigned int speed; unsigned int duplex; - u32 caps; - phy_interface_t phy_interface; /* AT91RM9200 transmit */