DPDK patches and discussions
 help / color / mirror / Atom feed
* [PATCH 0/1] Minor mistake in ring (en|de)queueing
@ 2022-01-03 14:22 Andrzej Ostruszka
  2022-01-03 14:22 ` [PATCH 1/1] ring: fix off by 1 mistake Andrzej Ostruszka
  0 siblings, 1 reply; 11+ messages in thread
From: Andrzej Ostruszka @ 2022-01-03 14:22 UTC (permalink / raw)
  To: dev; +Cc: upstream, Andrzej Ostruszka

Hi all,

Recently I was going through the ring implementation and I believe I've
found a small mistake.  Not a functional error, just a slightly
suboptimal behaviour for the specific case when we want to enqueue
exactly the number of elements that we can before wrapping to the ring
beginning (the same goes for dequeueing).

Imagine we have a ring of size 16 depicted below with indexes underneath
and consumer/producer pointing as shown.

|  ******        |
 0123456789ABCDEF
   ^     ^
   c     p

Now if we try to enqueue 8 elements we will end up at the check:

	if (likely(idx + n < size)) {

where idx (=8) is a producer head and n=8.  We will fail this check
even though we have the case of 8 elements available without wrapping to
the beginning of the ring.

I hope I'm not completely off the base here :), if I'm not then the
subsequent patch attempts to fix this.

Wit regards
Andrzej Ostruszka

Andrzej Ostruszka (1):
  ring: fix off by 1 mistake

 lib/ring/rte_ring_elem_pvt.h | 12 ++++++------
 1 file changed, 6 insertions(+), 6 deletions(-)

-- 
2.34.1.448.ga2b2bfdf31-goog


^ permalink raw reply	[flat|nested] 11+ messages in thread

end of thread, other threads:[~2022-02-05 16:49 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
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
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

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).