Received: by 2002:ab2:620c:0:b0:1ef:ffd0:ce49 with SMTP id o12csp1070864lqt; Tue, 19 Mar 2024 11:42:14 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCWsQXLRm784BsjVsT0WywS9gcIAricblAYQKL0usw2cxJ+X4HYNsp9teHRqWjQp6E3NHHQJKikOc8tJOIT9rQ2JmNig1CP6w6KArK93cA== X-Google-Smtp-Source: AGHT+IHGFTcrZ99KLy3AqVzCkGBGx3pzEBhPKw6JFyKaQXLLFUWcIrAYo4r8MGcnX8ahU3Hg+rdW X-Received: by 2002:a05:6122:48d:b0:4d4:1a1a:6db7 with SMTP id o13-20020a056122048d00b004d41a1a6db7mr9509389vkn.2.1710873733850; Tue, 19 Mar 2024 11:42:13 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1710873733; cv=pass; d=google.com; s=arc-20160816; b=m3PEQMp2ATN5Ge9a06rDKv8IwkllJ5uGTsOx9Sxp2oxMTIgydU4hSzDzJgrN+vPZ0o 8wifGm2bt/1VozIdIkTEhdwawQaf0+l0aI33SG8HM0PQw2/TiJbLuJjyUs+i5jlMMulO LiJwzfRrcEpe8Am8HzohKBQdpQ5iC7OZwFiOWQrWeO2sYKEfF+9lgT5stPeFc6WXs9bZ bHN2u42Z1qVQ3u2V1J2oEvRbdCvHeCLEH/1tbJhPzDf5rn1h2flkk6NpGNnGFsZASJk8 WjMd6DxA2cAo8iwc/FbztLHqr7X0xlHQj+G1LXwm8w7PPVxQA/OyHy4CpNDjJRTJzwRf KYNw== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=in-reply-to:content-transfer-encoding:content-disposition :mime-version:list-unsubscribe:list-subscribe:list-id:precedence :references:message-id:subject:cc:to:from:date:dkim-signature; bh=UEaHn2TUfZsD0V061tY/X/MAVql5Uh39a4xAak6zI9E=; fh=QjqgJN8WX+95i2thXOXf9KIxTX+Z079bRaAXZuHcju0=; b=uXEchsPjznp7lfApPTdoz8ViI2/TqvH1P7jCkgncxOjgdI0sg7pRV/PK//aOmGJwXA pfTGSiMhl6/kz0NyTutx7DelMZGqbouoBf9xi0sY/EPKLQ+cMIocngoZPFiQ83U4PcLU i+5o4NFHA163HBWj/jh2dsrEDY4+61f721n/0dnjGm+Pk2ARDsiukXG8Qf/3ZFWhVTC+ +6Fi6OGo04bbWXxvj748t8Gw+mN5xxdLUV0u3HNmq0FWUjaTJiUY93B7+E7Kq5cwbZyB RigBTTn7SHjmDPgQBqNEpk/ELaxxY0i4d11pEOYr2AYD8ni2qh6bnCWhb2dJ5bkZaXfU kvqw==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=gpCpHlIb; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-108029-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-108029-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [147.75.199.223]) by mx.google.com with ESMTPS id g14-20020a0562140ace00b006915ad095d1si11421224qvi.26.2024.03.19.11.42.13 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 19 Mar 2024 11:42:13 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-108029-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) client-ip=147.75.199.223; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=gpCpHlIb; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-108029-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-108029-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ny.mirrors.kernel.org (Postfix) with ESMTPS id 8DF9A1C21F25 for ; Tue, 19 Mar 2024 18:42:13 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 855DC39AC4; Tue, 19 Mar 2024 18:42:06 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="gpCpHlIb" Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id A59382C690; Tue, 19 Mar 2024 18:42:05 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1710873725; cv=none; b=lgT52/UY3k+09pZWGqc0O5GfP2RXxv5VvLHqNiosvzI5lFJ3wmjl+bzI9XYFj7Sr6mNEEGyHD5u52sOnm8ojc0qa93sl9xpZ32vdKaZSYACYK53VE1jLkE21JPWgpdFJ/36F9wUQoZq+xb9hkyu6Yx1SpgDW39Ni9ItA55IBUqI= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1710873725; c=relaxed/simple; bh=/Xdo3nItTl5sMcBffTOyaNJrd79EpP5bGPedf1unGSA=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=nObDhreRQglCZEGmB5+bbvrQeFmgb0sL+Hbj4vRCLtg+0SjrAKwDRAq41rqBn12zcmPzyos6HZ0dJ0xF1KX4FJpF8FEEUP8OHdwWYyytESlAolBxn0lKeF70wAFbfAb3M4Zia/B+o94LuLIlCXXD59SLtjHLtOmKTUNgYt2UX3U= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=gpCpHlIb; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPSA id 42EFBC433C7; Tue, 19 Mar 2024 18:42:03 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1710873725; bh=/Xdo3nItTl5sMcBffTOyaNJrd79EpP5bGPedf1unGSA=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=gpCpHlIbdzMeUzAQj0R9Dd63LUg2B8fV6shgM8BsPWL8WNCK2ZzhCdiS5Qy50m6+o qAVh9yXmzUgpH/q908cwHMoKzYX4wVR57IzrSiBzz6WkKBoSqArJTZhQmpda7/WGI9 uOgGATTIYZ+u69a7N4xZZhoHLC9Lo9YcHmPfZZ7L3kI16r8M+Mb817M/YXPTNbY72/ lHvoC1EO78OvuYNODy66ib4kUH7CyGztsQ9U5AdYG9fxBW714VDPO3K4gS+MHSyZ82 qS33KTUcTUkHrL/98s8uOOO+m0pcxoKIOQZn7s0jWTrr6QpwH6ahbGxN3FHfJBbk/+ 0aJmkG6x3vb8g== Date: Tue, 19 Mar 2024 15:42:00 -0300 From: Arnaldo Carvalho de Melo To: Jonathan Cameron Cc: Andy Shevchenko , David Lechner , Jonathan Cameron , Michael Hennerich , Nuno =?iso-8859-1?Q?S=E1?= , linux-iio@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH v2] iio: adc: ad7944: Add support for "3-wire mode" Message-ID: References: <20240314-mainline-ad7944-3-wire-mode-v2-1-d469da0705d2@baylibre.com> <20240318124041.0000032d@Huawei.com> <20240318142923.000042f4@Huawei.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <20240318142923.000042f4@Huawei.com> On Mon, Mar 18, 2024 at 02:29:23PM +0000, Jonathan Cameron wrote: > On Mon, 18 Mar 2024 15:09:32 +0200 > Andy Shevchenko wrote: > > > On Mon, Mar 18, 2024 at 2:41 PM Jonathan Cameron > > wrote: > > > > > struct ad7944_adc { > > > > > struct spi_device *spi; > > > > > + enum ad7944_spi_mode spi_mode; > > > > > /* Chip-specific timing specifications. */ > > > > > const struct ad7944_timing_spec *timing_spec; > > > > > /* GPIO connected to CNV pin. */ > > > > > @@ -58,6 +75,9 @@ struct ad7944_adc { > > > > > } sample __aligned(IIO_DMA_MINALIGN); > > > > > }; > > > > > > > > Have you run `pahole` to see if there is a better place for a new member? > > > > > > I know this matters for structures where we see lots of them, but do we actually > > > care for one offs? Whilst it doesn't matter here I'd focus much more > > > on readability and like parameter grouping for cases like this than wasting > > > a few bytes. > > > > This is _also_ true, but think more about cache line contamination. > > Even not-so-important bytes may decrease the performance. In some > > cases it's tolerable, in some it is not (high-speed ADC). In general I > > assume that the developer has to understand many aspects of the > > software and cache line contamination may be last but definitely not > > least. > > > > Not totally sure what you are covering with contamination as many aspects > around caches and that's not really a standard term for any of them (as > far as I know). > > It's part of a multi cacheline allocation anyway (because it's tacked on the > end of the iio device struct, so fairly unlikely to share with other allocations > and definitely not on ARM because of the trailing __aligned(IIO_DMA_MINALIGN) > elements. > > If it matters more locally, then pahole is more likely to push you to pack You mean 'pahole --reorganize', right? Yeah, I need to take into account explicit __attribute__((__aligned__)) at the start of cachelines as a hint that the fields in a cacheline can't be moved outside of that cacheline or plain leave that cacheline members alone, as-is. I also need to get perf's data-type profiling as an input for 'pahole --reorganize', with that we may take into account the existing __aligned__ markings and combine it with what we get from data-type profiling. - Arnaldo > things together in a fashion that makes false sharing and similar perf issues > more likely if you are grouping things for packing purposes rather than > logical groups. > > If you just mean cache pressure then fair enough if we squeeze everything into > one cacheline and that doesn't cause false sharing. > 'Maybe' this will fit on x86. On Arm64 it's not going to > make any difference, just moving the padding around a bit within the line. > > So I'd argue premature optimization for a small, one off, structure. > > Jonathan > > >