Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S934071AbbKSKzw (ORCPT ); Thu, 19 Nov 2015 05:55:52 -0500 Received: from mail1.bemta12.messagelabs.com ([216.82.251.5]:55179 "EHLO mail1.bemta12.messagelabs.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1756555AbbKSKzu (ORCPT ); Thu, 19 Nov 2015 05:55:50 -0500 X-Env-Sender: Marc_Gonzalez@sigmadesigns.com X-Msg-Ref: server-4.tower-163.messagelabs.com!1447930547!7889968!1 X-Originating-IP: [195.215.56.170] X-StarScan-Received: X-StarScan-Version: 7.19.2; banners=-,-,- X-VirusChecked: Checked Subject: Re: [PATCH] clocksource: Store reg field within struct clocksource To: Russell King - ARM Linux , Thomas Gleixner CC: Daniel Lezcano , LKML , Mans Rullgard , Viresh Kumar , Nicolas Pitre , Tony Lindgren , Sebastian Frias References: <564C8086.80804@sigmadesigns.com> <20151118172114.GS8644@n2100.arm.linux.org.uk> <20151119103645.GV8644@n2100.arm.linux.org.uk> From: Marc Gonzalez Message-ID: <564DAAB2.6040706@sigmadesigns.com> Date: Thu, 19 Nov 2015 11:55:46 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:41.0) Gecko/20100101 Firefox/41.0 SeaMonkey/2.38 MIME-Version: 1.0 In-Reply-To: <20151119103645.GV8644@n2100.arm.linux.org.uk> Content-Type: text/plain; charset="ISO-8859-1" Content-Transfer-Encoding: 7bit X-Originating-IP: [172.27.0.114] Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 2718 Lines: 70 On 19/11/2015 11:36, Russell King - ARM Linux wrote: > On Thu, Nov 19, 2015 at 11:33:47AM +0100, Thomas Gleixner wrote: >> Russell, >> >> On Wed, 18 Nov 2015, Russell King - ARM Linux wrote: >> >>> On Wed, Nov 18, 2015 at 02:43:34PM +0100, Marc Gonzalez wrote: >>>> Since 'struct clocksource' is ____cacheline_aligned, gcc must insert >>>> a lot of padding between reg and clksrc in 'struct clocksource_mmio' >>>> (for example, L1_CACHE_BYTES = 64 on ARMv7). >>>> >>>> Storing reg within 'struct clocksource' removes unnecessary padding, >>>> and reg can then be grouped with other hot data. A nice side-effect >>>> of this patch is making container_of() unnecessary, which makes the >>>> code a bit simpler. >>>> >>>> On 32-bit platforms, reg fits in the padding between read and mask, >>>> meaning no downside from storing it there. >>> >>> Just swap the order of 'reg' and 'clksrc'. >> >> That might reduce the memory footprint, but it does not bring the >> iomem pointer closer to the other hotpath clocksource data. So we >> still need to touch at minimum two cache lines for reading the time. >> >> With Marc's change we have all hotpath data in a single cacheline. > > Right, and what it's doing is polluting struct clocksource with lots > of ifdefs which determine how much data is contained in there. Seems > to me to be totally insane. What I find puzzling is that you would consider the read field to be a bona fide member of struct clocksource, but reg (the address passed to read) does not belong inside the struct? If you just object to the ifdef, then perhaps 'reg' can be included unconditionally. diff --git a/include/linux/clocksource.h b/include/linux/clocksource.h index 278dd279a7a8..50725fd23ab0 100644 --- a/include/linux/clocksource.h +++ b/include/linux/clocksource.h @@ -69,6 +69,7 @@ struct clocksource { * clocksource itself is cacheline aligned. */ cycle_t (*read)(struct clocksource *cs); + void __iomem *reg; cycle_t mask; u32 mult; u32 shift; > The basic cause of this problem is the ____cacheline_aligned annotation > which effectively prevents wrapping struct clocksource to provide > implementation specific data. True. But note that placing reg inside struct clocksource comes for free on 32-bit platforms (it just replaces padding). > Maybe your idea is that struct clocksource should be bloated with all > implementation specific data in the long term? reg is not implementation-specific data, right? Regards. -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/