From: Arnaldo Carvalho de Melo <acme@kernel.org>
To: Jonathan Cameron <Jonathan.Cameron@huawei.com>
Cc: "Andy Shevchenko" <andy.shevchenko@gmail.com>,
"David Lechner" <dlechner@baylibre.com>,
"Jonathan Cameron" <jic23@kernel.org>,
"Michael Hennerich" <michael.hennerich@analog.com>,
"Nuno Sá" <nuno.sa@analog.com>,
linux-iio@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH v2] iio: adc: ad7944: Add support for "3-wire mode"
Date: Tue, 19 Mar 2024 15:42:00 -0300 [thread overview]
Message-ID: <ZfnceCKWLmbkWIgb@x1> (raw)
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 <andy.shevchenko@gmail.com> wrote:
>
> > On Mon, Mar 18, 2024 at 2:41 PM Jonathan Cameron
> > <Jonathan.Cameron@huawei.com> 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
>
>
>
prev parent reply other threads:[~2024-03-19 18:42 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-03-14 17:43 [PATCH v2] iio: adc: ad7944: Add support for "3-wire mode" David Lechner
2024-03-16 14:11 ` Jonathan Cameron
2024-03-16 19:57 ` Andy Shevchenko
2024-03-16 23:10 ` David Lechner
2024-03-17 8:23 ` Andy Shevchenko
2024-03-18 14:33 ` David Lechner
2024-03-23 18:20 ` Jonathan Cameron
2024-03-18 12:40 ` Jonathan Cameron
2024-03-18 13:09 ` Andy Shevchenko
2024-03-18 14:17 ` David Lechner
2024-03-18 16:25 ` Andy Shevchenko
2024-03-18 14:29 ` Jonathan Cameron
2024-03-19 18:42 ` Arnaldo Carvalho de Melo [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=ZfnceCKWLmbkWIgb@x1 \
--to=acme@kernel.org \
--cc=Jonathan.Cameron@huawei.com \
--cc=andy.shevchenko@gmail.com \
--cc=dlechner@baylibre.com \
--cc=jic23@kernel.org \
--cc=linux-iio@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=michael.hennerich@analog.com \
--cc=nuno.sa@analog.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox