-
Notifications
You must be signed in to change notification settings - Fork 706
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
Fix ringbuffer ring size reporting #1492
Conversation
Signed-off-by: usamasaqib <usamasaqib.96@live.com>
e0bad69
to
dcc6137
Compare
func (rr *ringReader) size() int { | ||
return cap(rr.ring) | ||
return cap(rr.ring) / 2 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think you need to fix TestRingbufReader
to accommodate this change.
Here we Line 27 in c959fd7
I'm not yet sure about the proposed change. Maybe updating the documentation to |
As the person who added |
Hey @florianl, in the mmap call we set the size as As Bryce mentioned, |
Signed-off-by: Florian Lehner <florianl@users.noreply.github.com>
Thanks all! |
The data pages of a ring buffer are mapped twice in a contiguous virtual region to allow easy wrap around when writing data. The code returns the ring size as the capacity of this mmaped region. However, this is wrong since the kernel double maps the underlying pages.
This PR fixes this by reporting the ring size as half the capacity of the underlying mmap region.