From: Kent Gibson <warthog618@gmail.com>
To: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Cc: "Linus Walleij" <linus.walleij@linaro.org>,
"Bartosz Golaszewski" <bartosz.golaszewski@linaro.org>,
"Yury Norov" <yury.norov@gmail.com>,
linux-gpio@vger.kernel.org, linux-arm-kernel@lists.infradead.org,
linux-kernel@vger.kernel.org,
"Shubhrajyoti Datta" <shubhrajyoti.datta@amd.com>,
"Srinivas Neeli" <srinivas.neeli@amd.com>,
"Michal Simek" <michal.simek@amd.com>,
"Bartosz Golaszewski" <brgl@bgdev.pl>,
"Rasmus Villemoes" <linux@rasmusvillemoes.dk>,
"Marek Behún" <kabel@kernel.org>
Subject: Re: [PATCH v1 5/5] gpiolib: cdev: Utilize more bitmap APIs
Date: Wed, 27 Sep 2023 22:23:12 +0800 [thread overview]
Message-ID: <ZRQ60KBtY09uPxp6@sol> (raw)
In-Reply-To: <ZRQ1RpHEapodQ0xU@smile.fi.intel.com>
On Wed, Sep 27, 2023 at 04:59:34PM +0300, Andy Shevchenko wrote:
> On Wed, Sep 27, 2023 at 09:49:35PM +0800, Kent Gibson wrote:
> > On Wed, Sep 27, 2023 at 03:17:06PM +0300, Andy Shevchenko wrote:
> > > On Wed, Sep 27, 2023 at 09:32:11AM +0800, Kent Gibson wrote:
> > > > On Tue, Sep 26, 2023 at 08:20:07AM +0300, Andy Shevchenko wrote:
> > > > > Currently we have a few bitmap calls that are open coded in the library
> > > > > module. Let's convert them to use generic bitmap APIs instead.
> > > >
> > > > Firstly, I didn't consider using the bitmap module here as, in my mind at
> > > > least, that is intended for bitmaps wider than 64 bits, or with variable
> > > > width. In this case the bitmap is fixed at 64 bits, so bitops seemed more
> > > > appropriate.
> > > >
> > > > And I would argue that they aren't "open coded" - they are parallelized
> > > > to reduce the number of passes over the bitmap.
> > > > This change serialises them, e.g. the get used to require 2 passes over
> > > > the bitmap, it now requires 3 or 4. The set used to require 1 and now
> > > > requires 2.
> > > > And there are additional copies that the original doesn't require.
> > > > So your change looks less efficient to me - unless there is direct
> > > > hardware support for bitmap ops??
> > > >
> > > > Wrt the argument that the serialized form is clearer and more
> > > > maintainable, optimised code is frequently more cryptic - as noted in
> > > > bitmap.c itself, and this code has remained unchanged since it was merged
> > > > 3 years ago, so the only maintenance it has required is to be more
> > > > maintainable?? Ok then.
> > > >
> > > > Your patch is functionally equivalent and pass my uAPI tests, so
> > > >
> > > > Tested-by: Kent Gibson <warthog618@gmail.com>
> > >
> > > Thanks for testing!
> >
> > Not a problem - that is what test suites are for.
> >
> > > > but my preference is to leave it as is.
> > >
> > > As Yury mentioned we need to look at bitmap APIs and make them possible to have
> > > a compile-time optimizations. With that in mind, I would prefer bitmap APIs
> > > over open-coded stuff which is hardly to be understood (yes, I still point
> > > out that it takes a few hours to me, maybe because I'm stupid enough, to
> > > get what's the heck is going one there, esp. for the == 1 case).
> >
> > Really? With all the bits out in the open it seems pretty clear to me.
> > Clearer than scatter/gather in fact.
>
> Yes, you are biased. :-) Ask some stranger about this code and I am pretty sure
> there will be double-figures percentage of people who can tell that the current
> code is a bit voodoo.
>
It is the same as yours - just inside out. i.e. it performs the ops per
selected line, not each op on the whole bitmap of lines.
> > Sure, if there is suitable hardware support then bitmaps COULD be faster
> > than bitops. But without that, and that is the general case, it will be
> > slower. Do you have ANY cases where your implementation is currently
> > faster? Then you would have a stronger case.
>
> Why do we care here about performance? But if we do, I would check this on
> the 32-bit platform where 64-bit operations somewhat problematic / slow.
>
Yet you argue that bitmaps could be more performant?? Pick a side!
> If Yury gives an idea about performance tests I can consider to add this
> piece to compare with and we might see the difference.
>
> > And if you find the existing implementation unclear then the appropriate
> > solution is to better document it, as bitmaps itself does, not replace it
> > with something simpler and slower.
>
> Documentation will be needed either way. In general statistics it will be 50/50
> who (mis)understands this or new code. Pity that the original author of the code
> hadn't though about documenting this...
>
And who was the original author? I forget.
What you mean to say is it is a pity the reviewers at the time were
satisfied with the code as it stands, right?
Cos there is a process here.
As I recall reviewers were more often than not complaining about
pointless comments, not the lack of comments, so the natural bias as the
author is towards under-documenting...
> > > Yet, it opens a way to scale this in case we might have v3 ABI that let's say
> > > allows to work with 512 GPIOs at a time. With your code it will be much harder
> > > to achieve and see what you wrote about maintenance (in that case).
> >
> > v3 ABI?? libgpiod v2 is barely out the door!
> > Do you have any cases where 64 lines per request is limiting?
>
> IIRC it was SO question where the OP asks exactly about breaking the 64 lines
> limitation in the current ABI.
>
> > If that sort of speculation isn't premature optimisation then I don't know
> > what is.
>
> No, based on the real question / discussion, just have no link at hand.
> But it's quite a niche, I can agree.
>
Let me know if you find a ref to that discussion - I'm curious.
Cheers,
Kent.
WARNING: multiple messages have this Message-ID (diff)
From: Kent Gibson <warthog618@gmail.com>
To: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Cc: "Linus Walleij" <linus.walleij@linaro.org>,
"Bartosz Golaszewski" <bartosz.golaszewski@linaro.org>,
"Yury Norov" <yury.norov@gmail.com>,
linux-gpio@vger.kernel.org, linux-arm-kernel@lists.infradead.org,
linux-kernel@vger.kernel.org,
"Shubhrajyoti Datta" <shubhrajyoti.datta@amd.com>,
"Srinivas Neeli" <srinivas.neeli@amd.com>,
"Michal Simek" <michal.simek@amd.com>,
"Bartosz Golaszewski" <brgl@bgdev.pl>,
"Rasmus Villemoes" <linux@rasmusvillemoes.dk>,
"Marek Behún" <kabel@kernel.org>
Subject: Re: [PATCH v1 5/5] gpiolib: cdev: Utilize more bitmap APIs
Date: Wed, 27 Sep 2023 22:23:12 +0800 [thread overview]
Message-ID: <ZRQ60KBtY09uPxp6@sol> (raw)
In-Reply-To: <ZRQ1RpHEapodQ0xU@smile.fi.intel.com>
On Wed, Sep 27, 2023 at 04:59:34PM +0300, Andy Shevchenko wrote:
> On Wed, Sep 27, 2023 at 09:49:35PM +0800, Kent Gibson wrote:
> > On Wed, Sep 27, 2023 at 03:17:06PM +0300, Andy Shevchenko wrote:
> > > On Wed, Sep 27, 2023 at 09:32:11AM +0800, Kent Gibson wrote:
> > > > On Tue, Sep 26, 2023 at 08:20:07AM +0300, Andy Shevchenko wrote:
> > > > > Currently we have a few bitmap calls that are open coded in the library
> > > > > module. Let's convert them to use generic bitmap APIs instead.
> > > >
> > > > Firstly, I didn't consider using the bitmap module here as, in my mind at
> > > > least, that is intended for bitmaps wider than 64 bits, or with variable
> > > > width. In this case the bitmap is fixed at 64 bits, so bitops seemed more
> > > > appropriate.
> > > >
> > > > And I would argue that they aren't "open coded" - they are parallelized
> > > > to reduce the number of passes over the bitmap.
> > > > This change serialises them, e.g. the get used to require 2 passes over
> > > > the bitmap, it now requires 3 or 4. The set used to require 1 and now
> > > > requires 2.
> > > > And there are additional copies that the original doesn't require.
> > > > So your change looks less efficient to me - unless there is direct
> > > > hardware support for bitmap ops??
> > > >
> > > > Wrt the argument that the serialized form is clearer and more
> > > > maintainable, optimised code is frequently more cryptic - as noted in
> > > > bitmap.c itself, and this code has remained unchanged since it was merged
> > > > 3 years ago, so the only maintenance it has required is to be more
> > > > maintainable?? Ok then.
> > > >
> > > > Your patch is functionally equivalent and pass my uAPI tests, so
> > > >
> > > > Tested-by: Kent Gibson <warthog618@gmail.com>
> > >
> > > Thanks for testing!
> >
> > Not a problem - that is what test suites are for.
> >
> > > > but my preference is to leave it as is.
> > >
> > > As Yury mentioned we need to look at bitmap APIs and make them possible to have
> > > a compile-time optimizations. With that in mind, I would prefer bitmap APIs
> > > over open-coded stuff which is hardly to be understood (yes, I still point
> > > out that it takes a few hours to me, maybe because I'm stupid enough, to
> > > get what's the heck is going one there, esp. for the == 1 case).
> >
> > Really? With all the bits out in the open it seems pretty clear to me.
> > Clearer than scatter/gather in fact.
>
> Yes, you are biased. :-) Ask some stranger about this code and I am pretty sure
> there will be double-figures percentage of people who can tell that the current
> code is a bit voodoo.
>
It is the same as yours - just inside out. i.e. it performs the ops per
selected line, not each op on the whole bitmap of lines.
> > Sure, if there is suitable hardware support then bitmaps COULD be faster
> > than bitops. But without that, and that is the general case, it will be
> > slower. Do you have ANY cases where your implementation is currently
> > faster? Then you would have a stronger case.
>
> Why do we care here about performance? But if we do, I would check this on
> the 32-bit platform where 64-bit operations somewhat problematic / slow.
>
Yet you argue that bitmaps could be more performant?? Pick a side!
> If Yury gives an idea about performance tests I can consider to add this
> piece to compare with and we might see the difference.
>
> > And if you find the existing implementation unclear then the appropriate
> > solution is to better document it, as bitmaps itself does, not replace it
> > with something simpler and slower.
>
> Documentation will be needed either way. In general statistics it will be 50/50
> who (mis)understands this or new code. Pity that the original author of the code
> hadn't though about documenting this...
>
And who was the original author? I forget.
What you mean to say is it is a pity the reviewers at the time were
satisfied with the code as it stands, right?
Cos there is a process here.
As I recall reviewers were more often than not complaining about
pointless comments, not the lack of comments, so the natural bias as the
author is towards under-documenting...
> > > Yet, it opens a way to scale this in case we might have v3 ABI that let's say
> > > allows to work with 512 GPIOs at a time. With your code it will be much harder
> > > to achieve and see what you wrote about maintenance (in that case).
> >
> > v3 ABI?? libgpiod v2 is barely out the door!
> > Do you have any cases where 64 lines per request is limiting?
>
> IIRC it was SO question where the OP asks exactly about breaking the 64 lines
> limitation in the current ABI.
>
> > If that sort of speculation isn't premature optimisation then I don't know
> > what is.
>
> No, based on the real question / discussion, just have no link at hand.
> But it's quite a niche, I can agree.
>
Let me know if you find a ref to that discussion - I'm curious.
Cheers,
Kent.
_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
next prev parent reply other threads:[~2023-09-27 14:23 UTC|newest]
Thread overview: 60+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-09-26 5:20 [PATCH v1 0/5] bitmap: get rid of bitmap_remap() and bitmap_biremap() uses Andy Shevchenko
2023-09-26 5:20 ` Andy Shevchenko
2023-09-26 5:20 ` [PATCH v1 1/5] lib/test_bitmap: Excape space symbols when printing input string Andy Shevchenko
2023-09-26 5:20 ` Andy Shevchenko
2023-09-26 10:35 ` Kent Gibson
2023-09-26 10:35 ` Kent Gibson
2023-09-26 10:39 ` Kent Gibson
2023-09-26 10:39 ` Kent Gibson
2023-09-26 5:20 ` [PATCH v1 2/5] lib/bitmap: Introduce bitmap_scatter() and bitmap_gather() helpers Andy Shevchenko
2023-09-26 5:20 ` Andy Shevchenko
2023-09-27 0:25 ` Yury Norov
2023-09-27 0:25 ` Yury Norov
2023-09-27 2:10 ` Yury Norov
2023-09-27 2:10 ` Yury Norov
2023-09-27 12:10 ` Andy Shevchenko
2023-09-27 12:10 ` Andy Shevchenko
2023-09-27 12:02 ` Andy Shevchenko
2023-09-27 12:02 ` Andy Shevchenko
2023-10-02 4:06 ` Yury Norov
2023-10-02 4:06 ` Yury Norov
2023-10-02 8:23 ` Andy Shevchenko
2023-10-02 8:23 ` Andy Shevchenko
2023-09-26 5:20 ` [PATCH v1 3/5] gpio: xilinx: Switch to use new bitmap_scatter() helper Andy Shevchenko
2023-09-26 5:20 ` Andy Shevchenko
2023-09-26 5:20 ` [PATCH v1 4/5] gpio: xilinx: Replace bitmap_bitremap() calls Andy Shevchenko
2023-09-26 5:20 ` Andy Shevchenko
2023-09-26 10:41 ` Kent Gibson
2023-09-26 10:41 ` Kent Gibson
2023-09-26 11:11 ` Andy Shevchenko
2023-09-26 11:11 ` Andy Shevchenko
2023-09-26 11:17 ` Kent Gibson
2023-09-26 11:17 ` Kent Gibson
2023-09-26 5:20 ` [PATCH v1 5/5] gpiolib: cdev: Utilize more bitmap APIs Andy Shevchenko
2023-09-26 5:20 ` Andy Shevchenko
2023-09-27 0:46 ` Yury Norov
2023-09-27 0:46 ` Yury Norov
2023-09-27 6:48 ` Kent Gibson
2023-09-27 6:48 ` Kent Gibson
2023-09-27 1:32 ` Kent Gibson
2023-09-27 1:32 ` Kent Gibson
2023-09-27 12:17 ` Andy Shevchenko
2023-09-27 12:17 ` Andy Shevchenko
2023-09-27 13:49 ` Kent Gibson
2023-09-27 13:49 ` Kent Gibson
2023-09-27 13:59 ` Andy Shevchenko
2023-09-27 13:59 ` Andy Shevchenko
2023-09-27 14:23 ` Kent Gibson [this message]
2023-09-27 14:23 ` Kent Gibson
2023-10-02 9:05 ` Andy Shevchenko
2023-10-02 9:05 ` Andy Shevchenko
2023-10-02 9:25 ` Kent Gibson
2023-10-02 9:25 ` Kent Gibson
2023-10-02 9:32 ` Andy Shevchenko
2023-10-02 9:32 ` Andy Shevchenko
2023-10-02 9:42 ` Kent Gibson
2023-10-02 9:42 ` Kent Gibson
2023-09-26 8:52 ` [PATCH v1 0/5] bitmap: get rid of bitmap_remap() and bitmap_biremap() uses Linus Walleij
2023-09-26 8:52 ` Linus Walleij
2023-09-26 11:16 ` Andy Shevchenko
2023-09-26 11:16 ` Andy Shevchenko
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=ZRQ60KBtY09uPxp6@sol \
--to=warthog618@gmail.com \
--cc=andriy.shevchenko@linux.intel.com \
--cc=bartosz.golaszewski@linaro.org \
--cc=brgl@bgdev.pl \
--cc=kabel@kernel.org \
--cc=linus.walleij@linaro.org \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-gpio@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux@rasmusvillemoes.dk \
--cc=michal.simek@amd.com \
--cc=shubhrajyoti.datta@amd.com \
--cc=srinivas.neeli@amd.com \
--cc=yury.norov@gmail.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.