[PATCH v17 2/2] eal: RTE_PTR_ADD/SUB API improvements
David Marchand
david.marchand at redhat.com
Tue Feb 3 10:51:39 CET 2026
On Mon, 2 Feb 2026 at 06:25, <scott.k.mitch1 at gmail.com> wrote:
>
> From: Scott Mitchell <scott.k.mitch1 at gmail.com>
>
> RTE_PTR_ADD and RTE_PTR_SUB APIs have a few limitations:
> 1. ptr cast to uintptr_t drops pointer provenance and
> prevents compiler optimizations
> 2. return cast discards qualifiers (const, volatile)
> which may hide correctness/concurrency issues.
> 3. Accepts both "pointers" and "integers as pointers" which
> overloads the use case and constrains the implementation
> to address other challenges.
>
> This patch splits the API on two dimensions:
> 1. pointer types
> 2. integer types that represent pointers
>
> This split allows addressing each of the challenges above
> and provides distinct APIs for the distinct use cases.
> Examples:
> 1. Clang is able to optimize and improve __rte_raw_cksum
> (which uses RTE_PTR_ADD) by ~40% (100 bytes) to ~8x (1.5k bytes)
> TSC cycles/byte.
> 2. Refactoring discovered cases that dropped qualifiers (volatile)
> that the new API exposes.
>
> Signed-off-by: Scott Mitchell <scott.k.mitch1 at gmail.com>
> ---
> app/test-pmd/cmdline_flow.c | 4 +-
> app/test/meson.build | 1 +
> app/test/test_common.c | 20 +-
> app/test/test_ptr_add_sub.c | 199 +++++++++++++++++
Do we *need* a new file for testing new macros?
So far, everything went to test_common.c.
--
David Marchand
More information about the dev
mailing list