|SUCCESS| ring: add cache guard after ring elements table

dpdklab at iol.unh.edu dpdklab at iol.unh.edu
Tue Apr 21 19:27:56 CEST 2026


Test-Label: ai-code-review
Test-Status: SUCCESS
https://dpdk.org/patch/163220

_AI Code Review_

=== Patch Review: series.patch (via Claude) ===
Review date: 2026-04-21

Commit: [git sha unavailable - reviewing patch file]
Author: Morten Brorup <mb at smartsharesystems.com>
Subject: [PATCH] ring: add cache guard after ring elements table

This patch adds a cache guard after the ring elements table to prevent
false sharing from hardware prefetchers.

> diff --git a/lib/ring/rte_ring.c b/lib/ring/rte_ring.c
> index f10050a1c4..9ccc62cd42 100644
> --- a/lib/ring/rte_ring.c
> +++ b/lib/ring/rte_ring.c
> @@ -73,8 +73,11 @@ rte_ring_get_memsize_elem(unsigned int esize, unsigned int count)
>  		return -EINVAL;
>  	}
>  
> +	static_assert(sizeof(struct rte_ring) == RTE_CACHE_LINE_ROUNDUP(sizeof(struct rte_ring)),
> +			"Size of struct rte_ring not cache line aligned");
>  	sz = sizeof(struct rte_ring) + (ssize_t)count * esize;
>  	sz = RTE_ALIGN(sz, RTE_CACHE_LINE_SIZE);
> +	sz += RTE_CACHE_GUARD_LINES * RTE_CACHE_LINE_SIZE;
>  	return sz;
>  }

Does this code introduce a memory allocation mismatch? The
rte_ring_get_memsize_elem() function calculates the memory size including
the guard, but does the actual allocation in rte_ring_init() or
rte_ring_create_elem() account for this extra space when initializing or
using the ring? If the ring access code assumes the elements table ends
at offset sizeof(struct rte_ring) + count * esize, could this cause the
guard region to be overwritten?

Can the static_assert placement cause compilation issues? Placing a
static_assert inside a function body after the opening brace but before
all variable declarations may violate C90/C99 requirements that DPDK
supports. Should this assertion be moved to file scope or after all
local variable declarations?

Does this patch break ABI compatibility? Adding extra memory to the ring
allocation changes the memory layout that existing applications might
depend on. Should this change be documented in the release notes or
guarded by an ABI version check?


More information about the test-report mailing list