-
Notifications
You must be signed in to change notification settings - Fork 16
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Bug: loop counter in ringbuf.h function __store_ring() and __load_ring() is wrong #1
Comments
liuqun
changed the title
Found a bug in ringbuf.h
Bug: loop counter in ringbuf.h function __store_ring() and __load_ring() is wrong
Aug 10, 2019
liuqun
added a commit
to liuqun/portable-lib
that referenced
this issue
Aug 10, 2019
Fix up wrong loop counter in function __store_ring() and __load_ring() in file "fast/ringbuf.h". See also: Bug report at opencoff#1 Signed-off-by: Liu Qun <[email protected]>
liuqun
added a commit
to liuqun/portable-lib
that referenced
this issue
Aug 10, 2019
Fix up wrong loop counter in function __store_ring() and __load_ring() in file "fast/ringbuf.h". See also: Bug report at opencoff#1 Signed-off-by: Liu Qun <[email protected]>
Thank you for finding this issue. I patched it - but slightly different;
I moved the unrolled-loop-count to inside the "am I wrapped or not" if
() block. Please take a look at the latest commit.
Best,
--
刘群 wrote on 8/10/19 8:19 AM:
…
https://github.com/opencoff/portable-lib/blob/10c32868e57c65b314e24834be6c62b1e856e74e/inc/fast/ringbuf.h#L237-L277
*
Bug: When |n=1|, function |__store_ring(ring, head, elements, n)|
actually writes 4 elements into the ring.
*
Reason: |loop| should = |n>>2| not |n&0x03|
Buggy code is at line 240:
https://github.com/opencoff/portable-lib/blob/10c32868e57c65b314e24834be6c62b1e856e74e/inc/fast/ringbuf.h#L240
*
Solution:
The correct logic should let |loop = n % 4| or using bit-shift
operator '>>':
|unsigned loop = n >> 2; |
—
You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub
<#1?email_source=notifications&email_token=ACB7AW3MNRZXRQNKEDMMRSLQDZTWPA5CNFSM4IKYZZ4KYY3PNVWWK3TUL52HS4DFUVEXG43VMWVGG33NNVSW45C7NFSM4HEQTEKQ>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/ACB7AWZXAEEPPYRV43EEAO3QDZTWPANCNFSM4IKYZZ4A>.
|
Fixed by 9b47975 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Both
__store_ring()
and__load_ring()
have a same bug.function
__store_ring
:portable-lib/inc/fast/ringbuf.h
Lines 237 to 277 in 10c3286
Bug: When
n=1
, function__store_ring(ring, head, elements, n)
actually writes 4 elements into the ring.Reason:
loop
should =n>>2
notn&0x03
Buggy code is at line 240:
portable-lib/inc/fast/ringbuf.h
Line 240 in 10c3286
Solution:
The correct logic should be:
see also https://github.com/DPDK/dpdk/blob/07f08a96f5255a0375dce2683db4fb489bbaa8a0/lib/librte_ring/rte_ring.h#L240-L250
The text was updated successfully, but these errors were encountered: