From: Rasmus Villemoes <ravi@prevas.dk>
To: Simon Glass <sjg@chromium.org>
Cc: U-Boot Mailing List <u-boot@lists.denx.de>,
Alexander Sverdlin <alexander.sverdlin@siemens.com>,
Caleb Connolly <caleb.connolly@linaro.org>,
Francis Laniel <francis.laniel@amarulasolutions.com>,
Heinrich Schuchardt <xypron.glpk@gmx.de>,
Ilias Apalodimas <ilias.apalodimas@linaro.org>,
Ion Agorria <ion@agorria.com>,
Jerome Forissier <jerome.forissier@linaro.org>,
Marek Vasut <marex@denx.de>,
Martyn Welch <martyn.welch@collabora.com>,
Mattijs Korpershoek <mkorpershoek@baylibre.com>,
Neil Armstrong <neil.armstrong@linaro.org>,
Patrice Chotard <patrice.chotard@foss.st.com>,
Peter Robinson <pbrobinson@gmail.com>,
Quentin Schulz <quentin.schulz@cherry.de>,
Raymond Mao <raymond.mao@linaro.org>,
Robert Marko <robert.marko@sartura.hr>,
Sam Protsenko <semen.protsenko@linaro.org>,
Sughosh Ganu <sughosh.ganu@linaro.org>,
Sumit Garg <sumit.garg@linaro.org>,
Svyatoslav Ryhel <clamor95@gmail.com>,
Tom Rini <trini@konsulko.com>
Subject: Re: [PATCH 0/8] membuff: Add tests and update to support a flag for empty/full
Date: Thu, 06 Mar 2025 15:21:20 +0100 [thread overview]
Message-ID: <87zfhy44v3.fsf@prevas.dk> (raw)
In-Reply-To: <CAFLszTjyJW05xpjg23B2KHMi9-tZVZhRd0Zpr3A7yfcQJc+4MQ@mail.gmail.com> (Simon Glass's message of "Wed, 5 Mar 2025 06:53:04 -0700")
On Wed, Mar 05 2025, Simon Glass <sjg@chromium.org> wrote:
> Hi Rasmus,
>
> On Tue, 4 Mar 2025 at 11:55, Rasmus Villemoes <ravi@prevas.dk> wrote:
>>
>> On Tue, Mar 04 2025, Simon Glass <sjg@chromium.org> wrote:
>>
>> > Hi Rasmus,
>> >
>> > On Fri, 18 Oct 2024 at 08:55, Simon Glass <sjg@chromium.org> wrote:
>> >>
>> >> Hi Rasmus,
>> >>
>> >> On Fri, 18 Oct 2024 at 01:05, Rasmus Villemoes <ravi@prevas.dk> wrote:
>> >> >
>> >> >
>> >> > If you want to do the churn of renaming anyway, I suggest doing it by
>> >> > adding an implementation using the proper scheme under the new name,
>> >> > switch users over, and dropping the old. IMO, this series as-is brings
>> >> > no value (except for the tests, of course).
>> >>
>> >> OK. Do you think this series gets us closer to that, or further away?
>> >
>> > I didn't get a response to this (which is not a problem, I miss things
>> > all the time). Anyway I don't like the power-of-two restriction and
>> > you can see my other responses above. I've applied this to my tree as
>> > I want to have the tests in place.
>>
>> I stand by my earlier comments that this is the wrong way to implement a
>> circular buffer. I hope Tom doesn't pull this.
>
> OK. Are you saying that you think it should only support power-of-two
> sizes,
Yes, because that's the natural way to implement such a simple data
structure on real hardware, and I don't agree that it limits its
usefulness in any way. See how the linux kernel implements unix pipes,
and their kfifo helper.
> or something else? What specifically do you want?
I don't "want" anything in particular. I'm merely voicing my opinion
that I consider this approach to implementing a circular buffer
inferior.
> This series:
> - adds tests
Yes, always a good thing.
> - renames to membuf
While we can agree that is better than with two f's, I don't see it as a
huge virtue.
> - shows how we could switch to using an empty/full flag instead of
> leaving an empty slot, so we can see the code-size image
As I've said previously, I believe that actually makes the whole thing
even worse. Not using the natural wrapping/masking is already
error-prone enough, but needing to have two parallel implementations
living in the same source files with #ifdeffery; please, no. Do one or
the other, unconditionally.
> - does all this without requiring the size to be a power of two (which
> limits its usefulness IMO)
On that, we'll just have to agree to disagree.
Rasmus
PS: Something like
https://gist.github.com/Villemoes/332ac7a5dfc983c58ad40773c7bc6385 is
what I consider a simple and readable implementation (it may be buggy,
of course).
Frankly, the triple-pointer use in membuff.c frightens me, and that the
implementation of something as simple as membuff_avail() involves a
struct copy and calling membuff_getraw() in a loop makes it really hard
to reason about and verify.
next prev parent reply other threads:[~2025-03-06 14:21 UTC|newest]
Thread overview: 23+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-10-18 3:00 [PATCH 0/8] membuff: Add tests and update to support a flag for empty/full Simon Glass
2024-10-18 3:00 ` [PATCH 1/8] membuff: Rename functions to have membuf_ prefix Simon Glass
2025-03-04 15:37 ` Simon Glass
2024-10-18 3:00 ` [PATCH 2/8] membuff: Rename the files to membuf Simon Glass
2024-10-18 3:00 ` [PATCH 3/8] membuf: Rename struct Simon Glass
2025-03-04 15:37 ` Simon Glass
2024-10-18 3:00 ` [PATCH 4/8] membuf: Include stdbool Simon Glass
2025-03-04 15:37 ` Simon Glass
2024-10-18 3:00 ` [PATCH 5/8] membuf: Correct implementation of membuf_dispose() Simon Glass
2025-03-04 15:37 ` Simon Glass
2024-10-18 3:00 ` [PATCH 6/8] membuf: Add some tests Simon Glass
2025-03-04 15:37 ` Simon Glass
2024-10-18 3:00 ` [PATCH 7/8] membuf: Minor code-style improvements Simon Glass
2025-03-04 15:36 ` Simon Glass
2024-10-18 3:00 ` [PATCH 8/8] membuf: Support a flag for being full Simon Glass
2025-03-04 15:36 ` Simon Glass
2024-10-18 7:05 ` [PATCH 0/8] membuff: Add tests and update to support a flag for empty/full Rasmus Villemoes
2024-10-18 14:55 ` Simon Glass
2025-03-04 15:35 ` Simon Glass
2025-03-04 18:55 ` Rasmus Villemoes
2025-03-05 13:53 ` Simon Glass
2025-03-06 14:21 ` Rasmus Villemoes [this message]
2025-03-06 16:07 ` Simon Glass
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=87zfhy44v3.fsf@prevas.dk \
--to=ravi@prevas.dk \
--cc=alexander.sverdlin@siemens.com \
--cc=caleb.connolly@linaro.org \
--cc=clamor95@gmail.com \
--cc=francis.laniel@amarulasolutions.com \
--cc=ilias.apalodimas@linaro.org \
--cc=ion@agorria.com \
--cc=jerome.forissier@linaro.org \
--cc=marex@denx.de \
--cc=martyn.welch@collabora.com \
--cc=mkorpershoek@baylibre.com \
--cc=neil.armstrong@linaro.org \
--cc=patrice.chotard@foss.st.com \
--cc=pbrobinson@gmail.com \
--cc=quentin.schulz@cherry.de \
--cc=raymond.mao@linaro.org \
--cc=robert.marko@sartura.hr \
--cc=semen.protsenko@linaro.org \
--cc=sjg@chromium.org \
--cc=sughosh.ganu@linaro.org \
--cc=sumit.garg@linaro.org \
--cc=trini@konsulko.com \
--cc=u-boot@lists.denx.de \
--cc=xypron.glpk@gmx.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