From: William Breathitt Gray <vilhelm.gray@gmail.com>
To: "Uwe Kleine-König" <u.kleine-koenig@pengutronix.de>
Cc: linux-iio@vger.kernel.org, David Lechner <david@lechnology.com>,
kernel@pengutronix.de
Subject: Re: [PATCH] counter: ti-eqep: Use container_of instead of struct counter_device::priv
Date: Fri, 17 Dec 2021 08:31:49 +0900 [thread overview]
Message-ID: <YbvMZUKj0V+W0pEv@shinobu> (raw)
In-Reply-To: <20211216104915.62qfwjal5bz3x7g7@pengutronix.de>
[-- Attachment #1: Type: text/plain, Size: 3557 bytes --]
On Thu, Dec 16, 2021 at 11:49:15AM +0100, Uwe Kleine-König wrote:
> hello William,
>
> On Thu, Dec 16, 2021 at 02:25:03PM +0900, William Breathitt Gray wrote:
> > On Mon, Dec 13, 2021 at 12:43:12PM +0100, Uwe Kleine-König wrote:
> > > Using counter->priv is a memory read and so more expensive than
> > > container_of which is only an addition. (In this case even a noop
> > > because the offset is 0.)
> > >
> > > So container_of is expected to be a tad faster, it's type-safe, and
> > > produces smaller code (ARCH=arm allmodconfig):
> > >
> > > $ source/scripts/bloat-o-meter drivers/counter/ti-eqep.o-pre drivers/counter/ti-eqep.o
> > > add/remove: 0/0 grow/shrink: 0/9 up/down: 0/-108 (-108)
> > > Function old new delta
> > > ti_eqep_position_enable_write 132 120 -12
> > > ti_eqep_position_enable_read 260 248 -12
> > > ti_eqep_position_ceiling_write 132 120 -12
> > > ti_eqep_position_ceiling_read 236 224 -12
> > > ti_eqep_function_write 220 208 -12
> > > ti_eqep_function_read 372 360 -12
> > > ti_eqep_count_write 312 300 -12
> > > ti_eqep_count_read 236 224 -12
> > > ti_eqep_action_read 664 652 -12
> > > Total: Before=4598, After=4490, chg -2.35%
> > >
> > > Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
> >
> > I'll pick this up and submit it with the rest of the Counter changes for
> > this cycle.
>
> This is great. The same transformation could be done for the other
> drivers using the priv pointer. Then priv could be removed from struct
> counter_device. Good idea?
Sure, that sounds reasonable. Create a patchset with the changes, CC the
respective driver maintainers, and we'll see if we can merge those too.
William Breathitt Gray
>
> A quick prototype patch yields:
>
> drivers/counter/104-quad-8.o
> add/remove: 0/0 grow/shrink: 5/17 up/down: 76/-172 (-96)
> Total: Before=11802, After=11706, chg -0.81%
> drivers/counter/ftm-quaddec.o
> add/remove: 0/0 grow/shrink: 0/5 up/down: 0/-60 (-60)
> Total: Before=5096, After=5036, chg -1.18%
> drivers/counter/intel-qep.o
> add/remove: 0/0 grow/shrink: 0/10 up/down: 0/-116 (-116)
> Total: Before=4867, After=4751, chg -2.38%
> drivers/counter/interrupt-cnt.o
> add/remove: 0/0 grow/shrink: 0/6 up/down: 0/-60 (-60)
> Total: Before=2841, After=2781, chg -2.11%
> drivers/counter/microchip-tcb-capture.o
> add/remove: 0/0 grow/shrink: 1/6 up/down: 12/-68 (-56)
> Total: Before=5920, After=5864, chg -0.95%
> drivers/counter/stm32-lptimer-cnt.o
> add/remove: 0/0 grow/shrink: 0/10 up/down: 0/-140 (-140)
> Total: Before=6458, After=6318, chg -2.17%
> drivers/counter/stm32-timer-cnt.o
> add/remove: 0/0 grow/shrink: 0/11 up/down: 0/-132 (-132)
> Total: Before=5504, After=5372, chg -2.40%
> drivers/counter/ti-eqep.o
> add/remove: 0/0 grow/shrink: 0/10 up/down: 0/-120 (-120)
> Total: Before=4598, After=4478, chg -2.61%
>
> (the ti-eqep object file got a bit smaller, probably because I removed
> the priv member from struct counter_device.)
>
> Best regards
> Uwe
>
> --
> Pengutronix e.K. | Uwe Kleine-König |
> Industrial Linux Solutions | https://www.pengutronix.de/ |
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]
prev parent reply other threads:[~2021-12-16 23:32 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-12-13 11:43 [PATCH] counter: ti-eqep: Use container_of instead of struct counter_device::priv Uwe Kleine-König
2021-12-13 15:50 ` David Lechner
2021-12-16 5:25 ` William Breathitt Gray
2021-12-16 10:49 ` Uwe Kleine-König
2021-12-16 23:31 ` William Breathitt Gray [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=YbvMZUKj0V+W0pEv@shinobu \
--to=vilhelm.gray@gmail.com \
--cc=david@lechnology.com \
--cc=kernel@pengutronix.de \
--cc=linux-iio@vger.kernel.org \
--cc=u.kleine-koenig@pengutronix.de \
/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