Skip to content

Conversation

@teburd
Copy link
Contributor

@teburd teburd commented Oct 3, 2023

Moves the rtio_ prefixed lockfree queues to sys alongside existing
mpsc/spsc pbuf, ringbuf, and similar queue-like data structures.

@teburd teburd force-pushed the lockfree_queues branch 2 times, most recently from 28fd29b to 1ae34c1 Compare October 4, 2023 02:19
@teburd
Copy link
Contributor Author

teburd commented Oct 4, 2023

@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.

@nashif
Copy link
Member

nashif commented Oct 12, 2023

It will get confusing with the mpsc stuff and what we have already in include/zephyr/sys/mpsc_pbuf.h, probably need a better structure for all of this, did not look at content, just the file names :)

@teburd
Copy link
Contributor Author

teburd commented Oct 12, 2023

It will get confusing with the mpsc stuff and what we have already in include/zephyr/sys/mpsc_pbuf.h, probably need a better structure for all of this, did not look at content, just the file names :)

Possibly, this was actually asked for awhile ago by @nordic-krch who also authored mpsc_pbuf I believe #57436

@teburd teburd marked this pull request as ready for review October 13, 2023 16:25
@teburd teburd added this to the v3.6.0 milestone Oct 13, 2023
@zephyrbot zephyrbot added area: SPI SPI bus area: C++ area: I2C area: RTIO platform: Microchip SAM Microchip SAM Platform (formerly Atmel SAM) labels Oct 13, 2023
@nordic-krch
Copy link
Contributor

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:

  • mpsc - which is a fifo list of user data. It just organizes user data. more like slist but thread safe.
  • spsc - which is a container for storing fixed size data (up to n -elements). Zero copy approach (acquire, produce....)
  • spsc_pbuf - similar to spsc but hold variable length data (packets thus packet buffer pbuf). Zero copy approach.
  • mpsc_pbuf - more or less the same as spsc_pbuf but more complex since support multiproducer. Zero copy approach.
  • ring_buffer - also container but targeting raw data (no packets).
  • ...
    IMO, it would be more intuitive to divide it into lists (of pointers) and buffers (containers). From user perspective it's not important if it is lockfree or not but what can it do (organize my data vs store the data).

nordic-krch
nordic-krch previously approved these changes May 28, 2024
Comment on lines -219 to -228
Copy link
Contributor

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.

ubieda
ubieda previously approved these changes May 28, 2024
@henrikbrixandersen
Copy link
Member

Please rebase on main and resolve any merge conflicts.

@teburd teburd dismissed stale reviews from ubieda and nordic-krch via ff8d099 May 29, 2024 13:20
@teburd teburd force-pushed the lockfree_queues branch from 29daab6 to ff8d099 Compare May 29, 2024 13:20
ubieda
ubieda previously approved these changes May 29, 2024
@teburd
Copy link
Contributor Author

teburd commented May 29, 2024

@henrikbrixandersen CI failing now on an unrelated doc build error again it seems

@teburd teburd force-pushed the lockfree_queues branch from ff8d099 to c0c51b1 Compare May 29, 2024 14:56
@teburd teburd added this to the v3.7.0 milestone May 30, 2024
@teburd teburd force-pushed the lockfree_queues branch from c0c51b1 to d59c3cd Compare May 30, 2024 14:33
@teburd teburd force-pushed the lockfree_queues branch 3 times, most recently from 5c32393 to 475d913 Compare June 1, 2024 15:00
Copy link
Member

@ubieda ubieda left a 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.

@ubieda
Copy link
Member

ubieda commented Jun 1, 2024

Issue captured on #73606

@teburd teburd force-pushed the lockfree_queues branch from 475d913 to 72fe378 Compare June 3, 2024 20:18
teburd added 3 commits June 3, 2024 15:18
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]>
@teburd teburd requested review from josuah and nordic-krch June 4, 2024 13:56
Copy link
Contributor

@josuah josuah left a 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.

Comment on lines +12 to +13
#include <zephyr/sys/spsc_lockfree.h>
#include <zephyr/sys/mpsc_lockfree.h>
Copy link
Contributor

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.

Comment on lines +99 to 105
#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, \
}, \
Copy link
Contributor

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

https://github.com/zephyrproject-rtos/zephyr/pull/63470/files#diff-690e89323e13a9e22d9b6744504481620011234df581bbab923629217e0c529dR82

But it was already like that in RTIO, and seems like mostly for internal use anyway.

Copy link
Contributor

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.

https://github.com/zephyrproject-rtos/zephyr/pull/63470/files#diff-a0e010388d2114551593a77dfc3d6a51c2714c375411f3206af13cf6fee084f2R800-R801

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...

Copy link
Contributor Author

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
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

2024? Time flies!

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sad but true

@carlescufi carlescufi merged commit c5e591b into zephyrproject-rtos:main Jun 6, 2024
@teburd teburd deleted the lockfree_queues branch June 7, 2024 13:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area: Base OS Base OS Library (lib/os) area: C++ area: I2C area: Kernel area: RTIO area: Samples Samples area: SPI SPI bus platform: Microchip SAM Microchip SAM Platform (formerly Atmel SAM) platform: NXP Drivers NXP Semiconductors, drivers

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

9 participants