Minor mistake in ring (en|de)queueing
Get series with b4
b4 am [email protected]Versions newest first
- v1 Latest1 patch 4 repliesIn review
Patches in v1 No applies recorded yet
| # | Subject and files | Size | Replies | Applied |
|---|---|---|---|---|
| 1/1 | ring: fix off by 1 mistakelib/ | +6 | 9 replies |
Reviews trailers per patch
The patch has a Reviewed-by or Acked-by.
| Patch | Morten Brørup | Olivier Matz | Konstantin Ananyev |
|---|---|---|---|
| 1/1 | R-b R-b R-b | R-b R-b | A-b A-b |
Trailers given in replies are filled; those carried in the patches from earlier versions are outlined with dashes. Scroll the table sideways for all 3 reviewers.
Cover letter [PATCH 0/1] Minor mistake in ring (en|de)queueing
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(-)
Signature · 1 line
2.34.1.448.ga2b2bfdf31-goog