-
Notifications
You must be signed in to change notification settings - Fork 6.9k
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
Multiple defects in "Multi Producer Single Consumer Packet Buffer" library #38268
Comments
@palchak-google the case you described is not a bug. packet buffer has I will look into improving the documentation to state that clearly. |
See the description for allocation when packet is claimed: https://docs.zephyrproject.org/latest/reference/data_structures/mpsc_pbuf.html#allocation-with-overwrite |
See #38380 |
Let's address each of the three issues: Issue #1: Packets are dropped prior to reaching maximum capacity: Your claim is that a minimum of one word of data storage will always consumed by the packet buffer for internal bookkeeping, and the documentation will be changed to reflect this. If the implementation is always going to require at least one extra word be available to differentiate full from empty, why not just put that word into the It's common for some types of circular buffer to require the reservation of an extra slot, typically those implemented in hardware or lock-free implementations that rely on atomic pointer operations. This implementation is neither of those, so consuming the user's data storage is unnecessary. Just put the additional bookkeeping data where the rest of the bookkeeping data is: in the Issue #2: Excess packets are dropped when full: Let's pretend that it's necessary for the implementation to consume at least one word of the data storage. Even if such a scenario, the implementation is still dropping more packets than necessary. Here's a visualization of the state of the packet buffer for the exact sequence of operations posted previously.
In this visualization, the following characters are used: Second line indicates pointers: Let's focus on the actions that follow the line Now packet The correct behavior should be as follows:
Packet Incidentally, it's also not clear to me why both read pointers get moved when packet Issue #3: Interface is not const correct: This is still a defect. No documentation changes will fix this. |
Looking over the previous comment, I realized that the sequence of operations is not exactly the same as was posted in the first comment. In the most recent sequence, two packets ( This additional push operation exposed a fourth defect in the implementation, as observed by the final state of the buffer. After packet Also, both packets I think this defect is related to the odd handling of the read pointer when packet |
@palchak-google - are you able to submit a PR for this? |
@palchak-google i will take a look into that, agree that there is a bug. |
This issue has been marked as stale because it has been open (more than) 60 days with no activity. Remove the stale label or add a comment saying that you would like to have the label removed otherwise this issue will automatically be closed in 14 days. Note, that you can always re-open a closed issue at any time. |
This issue has been marked as stale because it has been open (more than) 60 days with no activity. Remove the stale label or add a comment saying that you would like to have the label removed otherwise this issue will automatically be closed in 14 days. Note, that you can always re-open a closed issue at any time. |
I would lower priority of this. Issue has been partially solved (const in API) and remaining issues are for long time in PRs without much reviewer interest. Issue found here does not impact logging since stress tests are passing in #42001. |
This issue has been marked as stale because it has been open (more than) 60 days with no activity. Remove the stale label or add a comment saying that you would like to have the label removed otherwise this issue will automatically be closed in 14 days. Note, that you can always re-open a closed issue at any time. |
Describe the bug
The following defects exist in the mpsc_pbuf library:
To Reproduce
Here is the a short test procedure that exposes these defects:
Logs and console output
Here is the output from running this test code on a
native_posix
target:Expected behavior
In this test scenario, a buffer with capacity to store four packets is constructed. However, only three packets can be pushed into the buffer before the buffer starts dropping packets. A total of six packets are pushed into the buffer, but in the end only two packets can be successfully retrieved from the buffer.
Impact
These defects, in particular # 1 and # 1, render the mpsc_pbuf unsuitable for applications that requires defined behavior or reliable ordering and delivery of packets
Environment (please complete the following information):
native_posix
target (Linux)The text was updated successfully, but these errors were encountered: