-
Notifications
You must be signed in to change notification settings - Fork 8.2k
sys: Add a lockfree mpsc and spsc queues #63470
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
Conversation
28fd29b to
1ae34c1
Compare
|
@mgielda can you please take a look see, unclear why this test would take so much longer in renode (I'm only vaguely familiar with it) than qemu. |
6cd6709 to
89f36a4
Compare
|
It will get confusing with the mpsc stuff and what we have already in |
Possibly, this was actually asked for awhile ago by @nordic-krch who also authored mpsc_pbuf I believe #57436 |
|
I'm not sure what to suggest but it would be good to organize it in a way that it is clear for the user. Currently we have:
|
doc/services/rtio/index.rst
Outdated
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.
Removing these categories from RTIO pages help with understanding RTIO: MPSC and SPSC were looking like part of the API, but are only used internally rather than two variants of RTIO.
|
Please rebase on |
|
@henrikbrixandersen CI failing now on an unrelated doc build error again it seems |
5c32393 to
475d913
Compare
ubieda
left a comment
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.
CI failures are unrelated to this PR. I'm able to reproduce it on main. Hence I'm approving this PR.
I'll report it on a GH issue to keep track of it.
|
Issue captured on #73606 |
Running lock free algorithms on renode seem to cause timeouts so exclude renode platforms. Signed-off-by: Tom Burdick <[email protected]>
Moves the rtio_ prefixed lockfree queues to sys alongside existing mpsc/spsc pbuf, ringbuf, and similar queue-like data structures. Signed-off-by: Tom Burdick <[email protected]>
The doc comment relating to mpsc atomics was worded poorly. Remove the poorly worded doc comment related to atomics and caches. Signed-off-by: Tom Burdick <[email protected]>
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.
note: I am only contributor, not collaborator, not maintainer, not a TSC
Now it is clearly visible that RTIO does not have SPSC as a dependency, reducing the learning curve.
| #include <zephyr/sys/spsc_lockfree.h> | ||
| #include <zephyr/sys/mpsc_lockfree.h> |
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.
The fact that they are both called _lockfree.h helps grouping them semantically, and suggest the kind of feature they provide.
| #define MPSC_INIT(symbol) \ | ||
| { \ | ||
| .head = (struct rtio_mpsc_node *)&symbol.stub, \ | ||
| .tail = (struct rtio_mpsc_node *)&symbol.stub, \ | ||
| .head = (struct mpsc_node *)&symbol.stub, \ | ||
| .tail = (struct mpsc_node *)&symbol.stub, \ | ||
| .stub = { \ | ||
| .next = NULL, \ | ||
| }, \ |
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.
In case consistency with SPSC and other few Zephyr APIs was aimed, MPSC_INITIALIZER() is also possible
But it was already like that in RTIO, and seems like mostly for internal use anyway.
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.
May I ask why there is no MPSC_DEFINE()?
The use-case might have been limited to these infocation, and never be defined alone outside of RTIO context. Now someone might want to define a global MPSC queue.
Though, not hard to call struct mpsc my_mpsc_queue = MSPC_INIT(my_mpsc_queue); over MPSC_DEFINE(my_mpsc_queue);. Just one fewer repetition of the symbol name...
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 it'd be a nice addition in a follow up, having rebased this and reworked it so many times now, I'd really like to see @nordic-krch re-approve and move it in before another mega rebase needs to happen again (causing lots of work).
| @@ -1,12 +1,11 @@ | |||
| /* | |||
| * Copyright (c) 2022 Intel Corporation | |||
| * Copyright (c) 2023 Intel Corporation | |||
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.
2024? Time flies!
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.
Sad but true
Moves the rtio_ prefixed lockfree queues to sys alongside existing
mpsc/spsc pbuf, ringbuf, and similar queue-like data structures.