Skip to content

[PATCH v3] linux-gen: stash: add optimized implementations per put_mode/get_mode#2358

Merged
MatiasElo merged 10 commits into
OpenDataPlane:masterfrom
MatiasElo:dev/stash_opt
Jun 11, 2026
Merged

[PATCH v3] linux-gen: stash: add optimized implementations per put_mode/get_mode#2358
MatiasElo merged 10 commits into
OpenDataPlane:masterfrom
MatiasElo:dev/stash_opt

Conversation

@MatiasElo

@MatiasElo MatiasElo commented Jun 4, 2026

Copy link
Copy Markdown
Collaborator

V2:

  • Moved all ring headers into a separate directory
  • Added "full" MPSC and SPMC ring implementations
  • Added support for using SPSC rings

@odpbuild odpbuild changed the title linux-gen: stash: add optimized implementations per put_mode/get_mode [PATCH v1] linux-gen: stash: add optimized implementations per put_mode/get_mode Jun 4, 2026
Comment thread platform/linux-generic/include/odp_ring_mpmc_internal.h Outdated
Comment thread platform/linux-generic/odp_stash.c Outdated
Comment thread platform/linux-generic/odp_stash.c
@odpbuild odpbuild changed the title [PATCH v1] linux-gen: stash: add optimized implementations per put_mode/get_mode [PATCH v2] linux-gen: stash: add optimized implementations per put_mode/get_mode Jun 9, 2026
Comment thread platform/linux-generic/include/ring/odp_ring_mpmc_internal.h Outdated
uint32_t size = ring_mask + 1;

/* Load acquire of r_tail ensures it is read after w_head, so that
* w_head - r_tail <= size. */

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

As in _RING_MPSC_DEQ_MULTI, this comment is inaccurate and misleading. w_head is only accessed by the producer thread so the loaded value is always the last written value, regardless of how the load gets ordered with respect to the load of r_tail. The value written to w_head never exceeds old_head + num_free, which equals size + r_rtail, so w_head - r_tail cannot exceed size.

@MatiasElo MatiasElo Jun 11, 2026

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Comment fixed in V3.

uint32_t head, tail, new_head, i;

/* Load acquire of w_tail ensures it is read after r_head, so that head
* value is always behind or equal to tail value. */

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Same comment about the load acquire here as for _RING_MPSC_RST_DEQ_MULTI

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Comment fixed in V3.

Comment thread platform/linux-generic/include/ring/odp_ring_mpmc_rst_internal.h
Comment thread platform/linux-generic/odp_stash.c
MatiasElo added 10 commits June 11, 2026 15:35
Move ring headers into a separate directory, so they don't  clutter the
main header directory.

Signed-off-by: Matias Elo <matias.elo@nokia.com>
Reviewed-by: Janne Peltonen <janne.peltonen@nokia.com>
Add dedicated MPSC and SPMC ring variants based on the MPMC ring
implementation. No functional changes to the MPMC implementation.

Signed-off-by: Matias Elo <matias.elo@nokia.com>
Reviewed-by: Janne Peltonen <janne.peltonen@nokia.com>
Utilize MPSC and SPMC ring variants for non-strict stash implementation
when put_mode or get_mode is ODP_STASH_OP_ST. This reduces unnecessary
synchronization overhead.

Signed-off-by: Matias Elo <matias.elo@nokia.com>
Reviewed-by: Janne Peltonen <janne.peltonen@nokia.com>
Add uint64_t variant of single thread ring. Also, remove deprecated
comments about 'max_num' having to be smaller than ring size and add batch
variants of enqueue and dequeue functions.

Signed-off-by: Matias Elo <matias.elo@nokia.com>
Reviewed-by: Janne Peltonen <janne.peltonen@nokia.com>
Utilize single thread ring for stash implementation in ODP_STASH_OP_LOCAL
mode. This removes unnecessary synchronization overhead.

Signed-off-by: Matias Elo <matias.elo@nokia.com>
Reviewed-by: Janne Peltonen <janne.peltonen@nokia.com>
Add dedicated MPSC and SPMC restricted ring variants based on the MPMC
restricted ring implementation. No functional changes to the current MPMC
implementation.

Signed-off-by: Matias Elo <matias.elo@nokia.com>
Reviewed-by: Janne Peltonen <janne.peltonen@nokia.com>
Utilize MPSC and SPMC restricted ring variants for strict stash
implementation when put_mode or get_mode is ODP_STASH_OP_ST. This reduces
unnecessary multi-producer/consumer synchronization overhead. Also, rename
MPMC restricted ring wrappers and data to match the current naming style.

Signed-off-by: Matias Elo <matias.elo@nokia.com>
Reviewed-by: Janne Peltonen <janne.peltonen@nokia.com>
Drop the inline specifier from the ring helper functions. These are only
referenced through function pointers, so inlining has no effect and the
qualifier is misleading.

Signed-off-by: Matias Elo <matias.elo@nokia.com>
Reviewed-by: Janne Peltonen <janne.peltonen@nokia.com>
Add uint64_t variant of SPSC ring. Also, add batch variants of enqueue and
dequeue functions, and remove deprecated comments about 'max_num' having to
be smaller than ring size

Signed-off-by: Matias Elo <matias.elo@nokia.com>
Reviewed-by: Janne Peltonen <janne.peltonen@nokia.com>
Utilize SPSC ring implementation for stashes that have both put_mode and
get_mode set to ODP_STASH_OP_ST. This reduces unnecessary synchronization
overhead.

Signed-off-by: Matias Elo <matias.elo@nokia.com>
Reviewed-by: Janne Peltonen <janne.peltonen@nokia.com>
@odpbuild odpbuild changed the title [PATCH v2] linux-gen: stash: add optimized implementations per put_mode/get_mode [PATCH v3] linux-gen: stash: add optimized implementations per put_mode/get_mode Jun 11, 2026
@MatiasElo MatiasElo enabled auto-merge (rebase) June 11, 2026 12:59
@MatiasElo MatiasElo merged commit 5646182 into OpenDataPlane:master Jun 11, 2026
158 checks passed
@MatiasElo MatiasElo deleted the dev/stash_opt branch June 11, 2026 13:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants