From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753178Ab2LQNwd (ORCPT ); Mon, 17 Dec 2012 08:52:33 -0500 Received: from webmail.solarflare.com ([12.187.104.25]:50240 "EHLO webmail.solarflare.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752961Ab2LQNwc (ORCPT ); Mon, 17 Dec 2012 08:52:32 -0500 Message-ID: <1355752345.2676.2.camel@bwh-desktop.uk.solarflarecom.com> Subject: Re: [PATCH 3/3 v2] net/macb: Try to optimize struct macb layout From: Ben Hutchings To: Nicolas Ferre CC: "David S. Miller" , , , , Joachim Eastwood , Jean-Christophe PLAGNIOL-VILLARD , Havard Skinnemoen Date: Mon, 17 Dec 2012 13:52:25 +0000 In-Reply-To: References: Organization: Solarflare Content-Type: text/plain; charset="UTF-8" X-Mailer: Evolution 3.2.3 (3.2.3-3.fc16) Content-Transfer-Encoding: 7bit MIME-Version: 1.0 X-Originating-IP: [10.17.20.137] Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, 2012-12-17 at 14:01 +0100, Nicolas Ferre wrote: > 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. RX-related fields go below those. > 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 | 25 +++++++++++++------------ > 1 file changed, 13 insertions(+), 12 deletions(-) > > diff --git a/drivers/net/ethernet/cadence/macb.h b/drivers/net/ethernet/cadence/macb.h > index cef146f..aeeb729 100644 > --- a/drivers/net/ethernet/cadence/macb.h > +++ b/drivers/net/ethernet/cadence/macb.h > @@ -548,38 +548,39 @@ 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; [...] If this driver may be used on SMP systems them 'napi' should be declared with the suffix ___cacheline_aligned_in_smp. Ben. -- Ben Hutchings, Staff Engineer, Solarflare Not speaking for my employer; that's the marketing department's job. They asked us to note that Solarflare product names are trademarked.