From: Olivier Matz <olivier.matz@6wind.com>
To: Andrzej Ostruszka <amo@semihalf.com>
Cc: dev@dpdk.org, upstream@semihalf.com
Subject: Re: [PATCH 1/1] ring: fix off by 1 mistake
Date: Thu, 6 Jan 2022 11:45:21 +0100 [thread overview]
Message-ID: <YdbIQcplKPN6rz4q@platinum> (raw)
In-Reply-To: <20220103142201.475552-2-amo@semihalf.com>
Hi Andrzej,
On Mon, Jan 03, 2022 at 03:22:01PM +0100, Andrzej Ostruszka wrote:
> ring: fix off by 1 mistake
I suggest something less scary for the title:
ring: optimize corner case for enqueue/dequeue
> When enqueueing/dequeueing to/from the ring we try to optimize by manual
> loop unrolling. The check for this optimization looks like:
>
> if (likely(idx + n < size)) {
>
> where 'idx' points to the first usable element (empty slot for enqueue,
> data for dequeue). The correct comparison here should be '<=' instead
> of '<'.
>
> This is not a functional error since we fall back to the loop with
> correct checks on indexes. Just a minor suboptimal behaviour for the
> case when we want to enqueue/dequeue exactly the number of elements that
> we have in the ring before wrapping to its beginning.
>
> Signed-off-by: Andrzej Ostruszka <amo@semihalf.com>
Reviewed-by: Olivier Matz <olivier.matz@6wind.com>
I'll tend to add:
Fixes: cc4b218790f6 ("ring: support configurable element size")
But the same error was in the ENQUEUE_PTRS()/DEQUEUE_PTRS() macros
since the beginning, so we may also add:
Fixes: 286bd05bf70d ("ring: optimisations")
This macro was removed in commit 2d6ed071a8b9 ("ring: use custom element
for fixed size API")
Thanks!
next prev parent reply other threads:[~2022-01-06 10:45 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-01-03 14:22 [PATCH 0/1] Minor mistake in ring (en|de)queueing Andrzej Ostruszka
2022-01-03 14:22 ` [PATCH 1/1] ring: fix off by 1 mistake Andrzej Ostruszka
2022-01-03 14:56 ` Morten Brørup
2022-01-06 10:45 ` Olivier Matz [this message]
2022-01-10 15:09 ` Ananyev, Konstantin
2022-01-11 11:49 ` Andrzej Ostruszka
2022-01-11 11:37 ` [PATCH] ring: optimize corner case for enqueue/dequeue Andrzej Ostruszka
2022-01-11 12:00 ` Morten Brørup
2022-01-11 13:46 ` Andrzej Ostruszka
2022-01-11 13:53 ` Morten Brørup
2022-02-05 16:48 ` David Marchand
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=YdbIQcplKPN6rz4q@platinum \
--to=olivier.matz@6wind.com \
--cc=amo@semihalf.com \
--cc=dev@dpdk.org \
--cc=upstream@semihalf.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;
as well as URLs for NNTP newsgroup(s).